display unicode filename in menu
This commit is contained in:
parent
de8379aab8
commit
a4593da4d4
@ -24,12 +24,8 @@
|
||||
#if defined(__amigaos4__) || defined(__AROS__) || defined(__MORPHOS__) || defined(__amigaos__)
|
||||
#include <proto/dos.h>
|
||||
#include <sys/types.h>
|
||||
#include <dirent.h>
|
||||
#elif defined(__WIN32__)
|
||||
#include <dirent.h>
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <dirent.h>
|
||||
#endif
|
||||
|
||||
// On Debian, this is already implied in dirent.h
|
||||
@ -76,6 +72,7 @@
|
||||
#include "special.h"
|
||||
#include "tiles.h"
|
||||
#include "setup.h"
|
||||
#include "unicode.h"
|
||||
|
||||
#if defined(__amigaos4__) || defined(__AROS__) || defined(__MORPHOS__) || defined(__amigaos__)
|
||||
#include <proto/dos.h>
|
||||
@ -3114,6 +3111,7 @@ void Load_picture(enum CONTEXT_TYPE type)
|
||||
int new_mode;
|
||||
T_IO_Context context;
|
||||
static char filename [MAX_PATH_CHARACTERS];
|
||||
static word filename_unicode[MAX_PATH_CHARACTERS];
|
||||
static char directory[MAX_PATH_CHARACTERS];
|
||||
T_Selector_settings * selector;
|
||||
|
||||
@ -3121,18 +3119,21 @@ void Load_picture(enum CONTEXT_TYPE type)
|
||||
{
|
||||
case CONTEXT_MAIN_IMAGE:
|
||||
strcpy(filename, Main.backups->Pages->Filename);
|
||||
Unicode_strlcpy(filename_unicode, Main.backups->Pages->Filename_unicode, MAX_PATH_CHARACTERS);
|
||||
strcpy(directory, Main.backups->Pages->File_directory);
|
||||
Init_context_layered_image(&context, filename, directory);
|
||||
selector = &Main.selector;
|
||||
break;
|
||||
case CONTEXT_BRUSH:
|
||||
strcpy(filename, Brush_filename);
|
||||
filename_unicode[0] = 0;
|
||||
strcpy(directory, Brush_file_directory);
|
||||
Init_context_brush(&context, filename, directory);
|
||||
selector = &Brush_selector;
|
||||
break;
|
||||
case CONTEXT_PALETTE:
|
||||
strcpy(filename, "");
|
||||
filename_unicode[0] = 0;
|
||||
strcpy(directory, Main.backups->Pages->File_directory);
|
||||
Init_context_layered_image(&context, filename, directory);
|
||||
context.Type = CONTEXT_PALETTE;
|
||||
@ -3142,6 +3143,7 @@ void Load_picture(enum CONTEXT_TYPE type)
|
||||
default:
|
||||
return; // DO NOTHING
|
||||
}
|
||||
context.File_name_unicode = filename_unicode;
|
||||
confirm=Button_Load_or_Save(selector, 1, &context);
|
||||
|
||||
if (confirm)
|
||||
|
||||
@ -2302,6 +2302,8 @@ byte Button_Load_or_Save(T_Selector_settings *settings, byte load, T_IO_Context
|
||||
if (has_clicked_ok)
|
||||
{
|
||||
strcpy(context->File_name, Selector_filename);
|
||||
if (context->File_name_unicode)
|
||||
Unicode_strlcpy(context->File_name_unicode, Selector_filename_unicode, MAX_PATH_CHARACTERS);
|
||||
strcpy(context->File_directory, Selector->Directory);
|
||||
if (!load)
|
||||
context->Format = Selector->Format_filter;
|
||||
|
||||
@ -51,6 +51,7 @@
|
||||
#include "brush.h"
|
||||
#include "setup.h"
|
||||
#include "filesel.h"
|
||||
#include "unicode.h"
|
||||
|
||||
// -- PKM -------------------------------------------------------------------
|
||||
void Test_PKM(T_IO_Context *);
|
||||
@ -803,11 +804,16 @@ void Load_image(T_IO_Context *context)
|
||||
{
|
||||
strcpy(Main.backups->Pages->Filename,context->Original_file_name);
|
||||
strcpy(Main.backups->Pages->File_directory,context->Original_file_directory);
|
||||
Main.backups->Pages->Filename_unicode[0] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy(Main.backups->Pages->Filename,context->File_name);
|
||||
strcpy(Main.backups->Pages->File_directory,context->File_directory);
|
||||
if (context->File_name_unicode)
|
||||
Unicode_strlcpy(Main.backups->Pages->Filename_unicode, context->File_name_unicode, MAX_PATH_CHARACTERS);
|
||||
else
|
||||
Main.backups->Pages->Filename_unicode[0] = 0;
|
||||
}
|
||||
|
||||
// On considère que l'image chargée n'est plus modifiée
|
||||
|
||||
@ -56,6 +56,7 @@ typedef struct
|
||||
// File properties
|
||||
|
||||
char * File_name;
|
||||
word * File_name_unicode;
|
||||
char * File_directory;
|
||||
byte Format;
|
||||
|
||||
|
||||
19
src/main.c
19
src/main.c
@ -462,6 +462,7 @@ int Init_program(int argc,char * argv[])
|
||||
int file_in_command_line;
|
||||
T_Gradient_array initial_gradients;
|
||||
static char main_filename [MAX_PATH_CHARACTERS];
|
||||
static word main_filename_unicode[MAX_PATH_CHARACTERS];
|
||||
static char main_directory[MAX_PATH_CHARACTERS];
|
||||
static char spare_filename [MAX_PATH_CHARACTERS];
|
||||
static char spare_directory[MAX_PATH_CHARACTERS];
|
||||
@ -914,6 +915,24 @@ int Init_program(int argc,char * argv[])
|
||||
// no break ! proceed with the other file now
|
||||
case 1:
|
||||
Init_context_layered_image(&context, main_filename, main_directory);
|
||||
#ifdef ENABLE_FILENAMES_ICONV
|
||||
{
|
||||
char * input = main_filename;
|
||||
size_t inbytesleft = strlen(main_filename);
|
||||
char * output = (char *)main_filename_unicode;
|
||||
size_t outbytesleft = sizeof(main_filename_unicode) - 2;
|
||||
if (cd_utf16 != (iconv_t)-1)
|
||||
{
|
||||
size_t r = iconv(cd_utf16, &input, &inbytesleft, &output, &outbytesleft);
|
||||
if (r != (size_t)-1)
|
||||
{
|
||||
output[0] = '\0';
|
||||
output[1] = '\0';
|
||||
context.File_name_unicode = main_filename_unicode;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Load_image(&context);
|
||||
Destroy_context(&context);
|
||||
Redraw_layered_image();
|
||||
|
||||
@ -774,6 +774,7 @@ int Init_all_backup_lists(enum IMAGE_MODES image_mode, int width, int height)
|
||||
Main.backups->Pages->Height=height;
|
||||
strcpy(Main.backups->Pages->File_directory,Main.selector.Directory);
|
||||
strcpy(Main.backups->Pages->Filename,"NO_NAME.GIF");
|
||||
Main.backups->Pages->Filename_unicode[0] = 0;
|
||||
|
||||
|
||||
for (i=0; i<Main.backups->Pages->Nb_layers; i++)
|
||||
@ -819,6 +820,8 @@ int Init_all_backup_lists(enum IMAGE_MODES image_mode, int width, int height)
|
||||
strcpy(Spare.backups->Pages->Comment,"");
|
||||
strcpy(Spare.backups->Pages->File_directory,Main.selector.Directory);
|
||||
strcpy(Spare.backups->Pages->Filename,"NO_NAME2.GIF");
|
||||
Spare.backups->Pages->Filename_unicode[0] = 0;
|
||||
|
||||
Spare.backups->Pages->File_format=DEFAULT_FILEFORMAT;
|
||||
// Copy this informations in the global Spare_ variables
|
||||
Download_infos_page_spare(Spare.backups->Pages);
|
||||
|
||||
@ -409,6 +409,7 @@ typedef struct T_Page
|
||||
|
||||
char File_directory[MAX_PATH_CHARACTERS];///< Directory that contains the file.
|
||||
char Filename[MAX_PATH_CHARACTERS]; ///< Filename without directory.
|
||||
word Filename_unicode[MAX_PATH_CHARACTERS]; ///< Filename without directory.
|
||||
byte File_format; ///< File format, in enum ::FILE_FORMATS
|
||||
struct T_Page *Next; ///< Pointer to the next backup
|
||||
struct T_Page *Prev; ///< Pointer to the previous backup
|
||||
@ -571,6 +572,8 @@ typedef struct
|
||||
char file_directory[MAX_PATH_CHARACTERS];
|
||||
/// Filename (without directory) of the image currently edited as page.
|
||||
char filename[MAX_PATH_CHARACTERS];
|
||||
/// Filename in unicode
|
||||
word filename_unicode[MAX_PATH_CHARACTERS];
|
||||
/// File format of the image currently edited as page. It's a value of enum ::FILE_FORMATS
|
||||
byte fileformat;
|
||||
/// File selector settings
|
||||
|
||||
@ -41,6 +41,7 @@
|
||||
#include "readline.h"
|
||||
#include "sdlscreen.h"
|
||||
#include "palette.h"
|
||||
#include "unicode.h"
|
||||
|
||||
T_Toolbar_button Buttons_Pool[NB_BUTTONS];
|
||||
T_Menu_Bar Menu_bars[MENUBAR_COUNT] =
|
||||
@ -697,7 +698,49 @@ void Print_general(short x,short y,const char * str,byte text_color,byte backgro
|
||||
for (index=0;str[index]!='\0';index++)
|
||||
{
|
||||
// Pointeur sur le premier pixel du caractère
|
||||
font_pixel=Menu_font+(((unsigned char)str[index])<<6);
|
||||
font_pixel=Menu_font+((unsigned char)str[index]<<6);
|
||||
for (x_pos=0;x_pos<8;x_pos+=1)
|
||||
for (repeat_menu_x_factor=0;repeat_menu_x_factor<Menu_factor_X*Pixel_width;repeat_menu_x_factor++)
|
||||
Horizontal_line_buffer[real_x++]=*(font_pixel+x_pos+y_pos)?text_color:background_color;
|
||||
}
|
||||
for (repeat_menu_y_factor=0;repeat_menu_y_factor<Menu_factor_Y;repeat_menu_y_factor++)
|
||||
Display_line_fast(x,real_y++,index*Menu_factor_X*8,Horizontal_line_buffer);
|
||||
}
|
||||
}
|
||||
|
||||
void Print_general_unicode(short x,short y,const word * str,byte text_color,byte background_color)
|
||||
{
|
||||
word index;
|
||||
int x_pos;
|
||||
int y_pos;
|
||||
byte *font_pixel;
|
||||
short real_x;
|
||||
short real_y;
|
||||
byte repeat_menu_x_factor;
|
||||
byte repeat_menu_y_factor;
|
||||
unsigned int c;
|
||||
|
||||
real_y=y;
|
||||
for (y_pos=0;y_pos<8<<3;y_pos+=1<<3)
|
||||
{
|
||||
real_x=0; // Position dans le buffer
|
||||
for (index=0;str[index]!=0;index++)
|
||||
{
|
||||
c = str[index];
|
||||
// Pointeur sur le premier pixel du caractère
|
||||
if (c < 256)
|
||||
font_pixel=Menu_font+(c<<6);
|
||||
else
|
||||
{
|
||||
T_Unicode_Font * ufont;
|
||||
font_pixel=Menu_font + (1<<6); // dummy character
|
||||
for (ufont = Unicode_fonts; ufont != NULL; ufont = ufont->Next)
|
||||
if (ufont->FirstChar <= c && c <= ufont->LastChar)
|
||||
{
|
||||
font_pixel = ufont->FontData + ((c - ufont->FirstChar) << 6);
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (x_pos=0;x_pos<8;x_pos+=1)
|
||||
for (repeat_menu_x_factor=0;repeat_menu_x_factor<Menu_factor_X*Pixel_width;repeat_menu_x_factor++)
|
||||
Horizontal_line_buffer[real_x++]=*(font_pixel+x_pos+y_pos)?text_color:background_color;
|
||||
@ -822,13 +865,33 @@ void Print_filename(void)
|
||||
{
|
||||
word max_size;
|
||||
word string_size;
|
||||
char display_string[256];
|
||||
|
||||
// Determine maximum size, in characters
|
||||
max_size = 12 + (Screen_width / Menu_factor_X - 320) / 8;
|
||||
|
||||
// Erase whole area
|
||||
Block(Screen_width-max_size*8*Menu_factor_X,
|
||||
Menu_status_Y,Menu_factor_X*max_size*8,Menu_factor_Y<<3,MC_Light);
|
||||
|
||||
// Partial copy of the name
|
||||
if (Main.backups->Pages->Filename_unicode[0] != 0)
|
||||
{
|
||||
word display_string[256];
|
||||
Unicode_strlcpy(display_string, Main.backups->Pages->Filename_unicode, 256);
|
||||
string_size = Unicode_strlen(display_string);
|
||||
display_string[max_size]=0;
|
||||
|
||||
if (string_size > max_size)
|
||||
{
|
||||
string_size = max_size;
|
||||
display_string[string_size-1]=(byte)ELLIPSIS_CHARACTER;
|
||||
}
|
||||
// Print
|
||||
Print_general_unicode(Screen_width-(string_size<<3)*Menu_factor_X,Menu_status_Y,display_string,MC_Black,MC_Light);
|
||||
}
|
||||
else
|
||||
{
|
||||
char display_string[256];
|
||||
#ifdef ENABLE_FILENAMES_ICONV
|
||||
char * input = Main.backups->Pages->Filename;
|
||||
size_t inbytesleft = strlen(input);
|
||||
@ -842,20 +905,17 @@ void Print_filename(void)
|
||||
strncpy(display_string, Main.backups->Pages->Filename, sizeof(display_string)-1);
|
||||
display_string[sizeof(display_string)-1] = '\0';
|
||||
}
|
||||
}
|
||||
string_size = strlen(display_string);
|
||||
display_string[max_size]='\0';
|
||||
string_size = strlen(display_string);
|
||||
display_string[max_size]='\0';
|
||||
|
||||
if (string_size > max_size)
|
||||
{
|
||||
string_size = max_size;
|
||||
display_string[string_size-1]=ELLIPSIS_CHARACTER;
|
||||
if (string_size > max_size)
|
||||
{
|
||||
string_size = max_size;
|
||||
display_string[string_size-1]=ELLIPSIS_CHARACTER;
|
||||
}
|
||||
// Print
|
||||
Print_general(Screen_width-(string_size<<3)*Menu_factor_X,Menu_status_Y,display_string,MC_Black,MC_Light);
|
||||
}
|
||||
// Erase whole area
|
||||
Block(Screen_width-max_size*8*Menu_factor_X,
|
||||
Menu_status_Y,Menu_factor_X*max_size*8,Menu_factor_Y<<3,MC_Light);
|
||||
// Print
|
||||
Print_general(Screen_width-(string_size<<3)*Menu_factor_X,Menu_status_Y,display_string,MC_Black,MC_Light);
|
||||
}
|
||||
|
||||
// Fonction d'affichage d'une chaine numérique avec une fonte très fine
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user