GrafX2 2.9.3227
The ultimate 256-color painting program
|
#include <assert.h>
#include <stdlib.h>
#include <fcntl.h>
#include <string.h>
#include <strings.h>
#include <unistd.h>
#include <ctype.h>
#include <wctype.h>
#include <sys/types.h>
#include "const.h"
#include "struct.h"
#include "global.h"
#include "misc.h"
#include "osdep.h"
#include "errors.h"
#include "io.h"
#include "windows.h"
#include "screen.h"
#include "loadsave.h"
#include "mountlist.h"
#include "engine.h"
#include "readline.h"
#include "input.h"
#include "help.h"
#include "unicode.h"
#include "filesel.h"
#include "fileseltools.h"
Data Structures | |
struct | Read_dir_pdata |
Macros | |
#define | NORMAL_FILE_COLOR MC_Light |
#define | NORMAL_DIRECTORY_COLOR MC_Dark |
#define | NORMAL_BACKGROUND_COLOR MC_Black |
#define | SELECTED_FILE_COLOR MC_White |
#define | SELECTED_DIRECTORY_COLOR MC_Light |
#define | SELECTED_BACKGROUND_COLOR MC_Dark |
#define | FILENAME_COMPARE strcmp |
#define | FILENAME_COMPARE_UNICODE Unicode_strcmp |
#define | MAX_QUICKSEARCH_LEN 50 |
Functions | |
static void | Recount_files (T_Fileselector *list) |
Update T_Fileselector::Nb_files T_Fileselector::Nb_directories T_Fileselector::Nb_elements counts. More... | |
void | Free_fileselector_list (T_Fileselector *list) |
This function free all item in the list, but not the list itself. More... | |
int | Check_extension (const char *filename_ext, const char *filter) |
Checks if a file has the requested file extension. More... | |
static void | Read_dir_callback (void *pdata, const char *file_name, const word *unicode_name, byte is_file, byte is_directory, byte is_hidden) |
void | Read_list_of_files (T_Fileselector *list, byte selected_format) |
void | Read_list_of_drives (T_Fileselector *list, byte name_length) |
void | Sort_list_of_files (T_Fileselector *list) |
Sort a file/directory list. More... | |
T_Fileselector_item * | Get_item_by_index (T_Fileselector *list, unsigned short index) |
Fast access to a list item. More... | |
void | Display_file_list (T_Fileselector *list, short offset_first, short selector_offset) |
Display of the file/directory list items. More... | |
static void | Get_selected_item (T_Fileselector *list, T_Selector_settings *selector, enum FSOBJECT_TYPE *type) |
Get the label of a list item. More... | |
void | Selector_scroll_down (short *offset_first, short *selector_offset) |
void | Selector_scroll_up (short *offset_first, short *selector_offset) |
void | Selector_page_down (short *offset_first, short *selector_offset, short lines) |
void | Selector_page_up (short *offset_first, short *selector_offset, short lines) |
void | Selector_end (short *offset_first, short *selector_offset) |
void | Selector_home (short *offset_first, short *selector_offset) |
short | Compute_click_offset_in_fileselector (void) |
static void | Display_bookmark (T_Dropdown_button *Button, int bookmark_number) |
static void | Print_current_directory (void) |
Shows Selector->Directory on 37 chars. More... | |
void | Print_filename_in_fileselector (void) |
static void | Prepare_and_display_filelist (short Position, short offset, T_Scroller_button *button, int setfilename) |
Displays the file list with sliders, etc. More... | |
static void | Reload_list_of_files (byte filter, T_Scroller_button *button) |
void | Scroll_fileselector (T_Scroller_button *file_scroller) |
short | Find_file_in_fileselector (T_Fileselector *list, const char *fname) |
Look for a file name in a file selector list. More... | |
static void | Highlight_file (short index) |
Set the position and index of the file list according to the selected index. More... | |
static short | Find_filename_match (const T_Fileselector *list, const word *fname) |
Find the item best matching the searched filename. More... | |
void | Reset_quicksearch (void) |
Reset the current quicksearch string. More... | |
static short | Quicksearch (const T_Fileselector *selector) |
Select the item based on what the user type. More... | |
void | Locate_list_item (T_List_button *list, short selected_item) |
int | Quicksearch_list (T_List_button *list, T_Fileselector *selector) |
byte | Button_Load_or_Save (T_Selector_settings *settings, byte load, T_IO_Context *context) |
Launch the Load/Save dialog (file selector) More... | |
Variables | |
static byte | New_preview_is_needed |
true if the preview timer need to be restarted More... | |
static T_Fileselector | Filelist |
static T_Selector_settings * | Selector |
Selector settings to use, for all functions called by Load_or_save. More... | |
static enum FSOBJECT_TYPE | Selected_type |
Type of the selected entry in the file selector. More... | |
static word | quicksearch_filename [MAX_QUICKSEARCH_LEN+1] = { 0 } |
Current quicksearch string. More... | |
#define NORMAL_FILE_COLOR MC_Light |
#define NORMAL_DIRECTORY_COLOR MC_Dark |
#define NORMAL_BACKGROUND_COLOR MC_Black |
#define SELECTED_FILE_COLOR MC_White |
#define SELECTED_DIRECTORY_COLOR MC_Light |
#define SELECTED_BACKGROUND_COLOR MC_Dark |
#define FILENAME_COMPARE strcmp |
#define FILENAME_COMPARE_UNICODE Unicode_strcmp |
#define MAX_QUICKSEARCH_LEN 50 |
|
static |
Update T_Fileselector::Nb_files T_Fileselector::Nb_directories T_Fileselector::Nb_elements counts.
Also update the list index T_Fileselector::Index
list | the linked list to update |
References T_Fileselector::First, FSOBJECT_FILE, T_Fileselector::Index, T_Fileselector::Nb_directories, T_Fileselector::Nb_elements, T_Fileselector::Nb_files, T_Fileselector_item::Next, NULL, and T_Fileselector_item::Type.
Referenced by Free_fileselector_list(), Read_list_of_drives(), Read_list_of_files(), and Sort_list_of_files().
void Free_fileselector_list | ( | T_Fileselector * | list | ) |
This function free all item in the list, but not the list itself.
list | the linked list |
References T_Fileselector::First, T_Fileselector_item::Next, NULL, Recount_files(), T_Fileselector_item::Unicode_full_name, and T_Fileselector_item::Unicode_short_name.
Referenced by Button_Load_or_Save(), Button_Skins(), Read_list_of_drives(), and Read_list_of_files().
int Check_extension | ( | const char * | filename_ext, |
const char * | filter | ||
) |
Checks if a file has the requested file extension.
The extension string can end with a ';' (remainder is ignored). This function allows wildcard '?', and '*' if it's the only character.
References NULL.
Referenced by Read_dir_callback().
|
static |
References Add_element_to_list(), Check_extension(), Config, Read_dir_pdata::filter, Format_filename(), Format_filename_unicode(), FSOBJECT_DIR, FSOBJECT_FILE, ICON_NONE, Read_dir_pdata::list, T_Fileselector::Nb_directories, T_Fileselector::Nb_files, NULL, PARENT_DIR, Position_last_dot(), Position_last_dot_unicode(), T_Config::Show_hidden_directories, T_Config::Show_hidden_files, T_Fileselector_item::Unicode_full_name, T_Fileselector_item::Unicode_short_name, and Unicode_strdup().
Referenced by Read_list_of_files().
void Read_list_of_files | ( | T_Fileselector * | list, |
byte | selected_format | ||
) |
References Add_element_to_list(), T_Format::Extensions, Read_dir_pdata::filter, T_Fileselector::First, For_each_directory_entry(), Format_filename(), Free_fileselector_list(), FSOBJECT_DIR, T_Fileselector_item::Full_name, Get_current_directory(), Get_fileformat(), ICON_NONE, Read_dir_pdata::list, T_Fileselector::Nb_directories, T_Fileselector::Nb_files, T_Fileselector_item::Next, NULL, PARENT_DIR, Read_dir_callback(), Recount_files(), and T_Fileselector_item::Type.
Referenced by Button_Load_or_Save(), and Reload_list_of_files().
void Read_list_of_drives | ( | T_Fileselector * | list, |
byte | name_length | ||
) |
References Add_element_to_list(), Format_filename(), Free_fileselector_list(), FSOBJECT_DRIVE, GFX2_DEBUG, GFX2_Log(), icon, ICON_CDROM, ICON_FLOPPY_3_5, ICON_HDD, ICON_NETWORK, ICON_NONE, Read_dir_pdata::list, mount_entry::me_devname, mount_entry::me_dummy, mount_entry::me_mountdir, mount_entry::me_next, mount_entry::me_remote, mount_entry::me_type, mount_entry::me_type_malloced, T_Fileselector::Nb_directories, T_Fileselector::Nb_files, NULL, read_file_system_list(), and Recount_files().
Referenced by Button_Load_or_Save().
void Sort_list_of_files | ( | T_Fileselector * | list | ) |
Sort a file/directory list.
The sord is done in that order : Directories first, in alphabetical order, then Files, in alphabetical order.
List counts and index are updated.
list | the linked list |
References FILENAME_COMPARE, FILENAME_COMPARE_UNICODE, T_Fileselector::First, T_Fileselector_item::Full_name, T_Fileselector_item::Next, NULL, PARENT_DIR, T_Fileselector_item::Previous, Recount_files(), T_Fileselector_item::Type, and T_Fileselector_item::Unicode_full_name.
Referenced by Button_Load_or_Save(), Button_Skins(), and Reload_list_of_files().
T_Fileselector_item * Get_item_by_index | ( | T_Fileselector * | list, |
unsigned short | index | ||
) |
Fast access to a list item.
list | the linked list |
index | the item index to access |
References T_Fileselector::First, T_Fileselector::Index, T_Fileselector::Nb_elements, T_Fileselector_item::Next, and NULL.
Referenced by Button_Load_or_Save(), Button_Skins(), Display_file_list(), Draw_one_skin_name(), and Get_selected_item().
void Display_file_list | ( | T_Fileselector * | list, |
short | offset_first, | ||
short | selector_offset | ||
) |
Display of the file/directory list items.
list | the file list |
offset_first | offset between the 1st visible file and the first file in list. |
selector_offset | offset between the 1st visible file and the selected file. |
References Get_item_by_index(), T_Fileselector_item::Icon, ICON_NONE, T_Fileselector::Nb_elements, T_Fileselector_item::Next, NORMAL_BACKGROUND_COLOR, NORMAL_DIRECTORY_COLOR, NORMAL_FILE_COLOR, Print_in_window(), Print_in_window_unicode(), SELECTED_BACKGROUND_COLOR, SELECTED_DIRECTORY_COLOR, SELECTED_FILE_COLOR, T_Fileselector_item::Short_name, T_Fileselector_item::Type, T_Fileselector_item::Unicode_short_name, and Window_display_icon_sprite().
Referenced by Button_Load_or_Save(), Prepare_and_display_filelist(), Selector_end(), Selector_home(), Selector_page_down(), Selector_page_up(), Selector_scroll_down(), and Selector_scroll_up().
|
static |
Get the label of a list item.
selector->filename and selector->filename_unicode are updated
list | the file list |
selector | the current File selector |
type | NULL or a pointer to receive the type : 0 = file, 1 = directory, 2 = drive. |
References T_Selector_settings::filename, T_Selector_settings::filename_unicode, T_Fileselector_item::Full_name, Get_item_by_index(), T_Fileselector::Nb_elements, NULL, T_Selector_settings::Offset, T_Selector_settings::Position, T_Fileselector_item::Type, T_Fileselector_item::Unicode_full_name, and Unicode_strdup().
Referenced by Button_Load_or_Save(), Prepare_and_display_filelist(), and Scroll_fileselector().
void Selector_scroll_down | ( | short * | offset_first, |
short * | selector_offset | ||
) |
References Display_file_list(), Filelist, and T_Fileselector::Nb_elements.
Referenced by Button_Load_or_Save().
void Selector_scroll_up | ( | short * | offset_first, |
short * | selector_offset | ||
) |
References Display_file_list(), and Filelist.
Referenced by Button_Load_or_Save().
void Selector_page_down | ( | short * | offset_first, |
short * | selector_offset, | ||
short | lines | ||
) |
References Display_file_list(), Filelist, and T_Fileselector::Nb_elements.
Referenced by Button_Load_or_Save().
void Selector_page_up | ( | short * | offset_first, |
short * | selector_offset, | ||
short | lines | ||
) |
References Display_file_list(), and Filelist.
Referenced by Button_Load_or_Save().
void Selector_end | ( | short * | offset_first, |
short * | selector_offset | ||
) |
References Display_file_list(), Filelist, and T_Fileselector::Nb_elements.
Referenced by Button_Load_or_Save().
void Selector_home | ( | short * | offset_first, |
short * | selector_offset | ||
) |
References Display_file_list(), and Filelist.
Referenced by Button_Load_or_Save().
short Compute_click_offset_in_fileselector | ( | void | ) |
References Filelist, Menu_factor_Y, Mouse_Y, T_Fileselector::Nb_elements, and Window_pos_Y.
Referenced by Button_Load_or_Save().
|
static |
References T_Dropdown_button::Active_button, T_Config::Bookmark_directory, T_Config::Bookmark_label, Config, label, LEFT_SIDE, MC_Black, MC_Dark, MC_Light, Portable_Installation_Detected, T_Dropdown_button::Pos_X, T_Dropdown_button::Pos_Y, Print_in_window(), Print_in_window_limited(), Print_in_window_limited_unicode(), RIGHT_SIDE, Unicode_strlen(), Window_dropdown_add_item(), Window_dropdown_clear_items(), and Window_rectangle().
Referenced by Button_Load_or_Save().
|
static |
Shows Selector->Directory on 37 chars.
References T_Selector_settings::Directory, T_Selector_settings::Directory_unicode, ELLIPSIS_CHARACTER, MAX_DISPLAYABLE_PATH, MC_Black, MC_Light, NULL, PATH_SEPARATOR, Print_in_window(), Print_in_window_unicode(), Selector, Unicode_strlcpy(), Unicode_strlen(), Update_window_area, and Window_rectangle().
Referenced by Prepare_and_display_filelist().
void Print_filename_in_fileselector | ( | void | ) |
References T_Selector_settings::filename, T_Selector_settings::filename_unicode, MC_Black, MC_Light, NULL, Print_in_window_limited(), Print_in_window_unicode(), Selector, Unicode_strlcpy(), Update_window_area, and Window_rectangle().
Referenced by Button_Load_or_Save(), Prepare_and_display_filelist(), and Scroll_fileselector().
|
static |
Displays the file list with sliders, etc.
also optionally updates the current file name (Selector_filename)
Position | the current position in the file list |
offset | the offset of the selected item in the file list |
button | the scrollbar/slider GUI control |
setfilename | option to update Selector_filename |
References Compute_slider_cursor_length(), Display_file_list(), Filelist, Get_selected_item(), MC_Black, T_Scroller_button::Nb_elements, T_Fileselector::Nb_elements, T_Scroller_button::Position, Print_current_directory(), Print_filename_in_fileselector(), Selected_type, Selector, Update_window_area, Window_draw_slider(), and Window_rectangle().
Referenced by Button_Load_or_Save(), and Reload_list_of_files().
|
static |
void Scroll_fileselector | ( | T_Scroller_button * | file_scroller | ) |
short Find_file_in_fileselector | ( | T_Fileselector * | list, |
const char * | fname | ||
) |
Look for a file name in a file selector list.
list | The file selector list |
fname | The file name to search for |
References T_Fileselector::First, T_Fileselector_item::Full_name, T_Fileselector_item::Next, and NULL.
Referenced by Button_Load_or_Save(), and Button_Skins().
|
static |
Set the position and index of the file list according to the selected index.
index | index of selected file |
References Filelist, T_Fileselector::Nb_elements, T_Selector_settings::Offset, T_Selector_settings::Position, and Selector.
Referenced by Button_Load_or_Save().
|
static |
Find the item best matching the searched filename.
used by quicksearch
References Config, T_Config::Find_file_fast, T_Fileselector::First, T_Fileselector_item::Full_name, T_Fileselector_item::Next, NULL, T_Fileselector_item::Type, and T_Fileselector_item::Unicode_full_name.
Referenced by Quicksearch().
void Reset_quicksearch | ( | void | ) |
Reset the current quicksearch string.
References quicksearch_filename.
Referenced by Button_Load_or_Save(), and Quicksearch().
|
static |
Select the item based on what the user type.
References Find_filename_match(), Key_ANSI, Key_UNICODE, MAX_QUICKSEARCH_LEN, quicksearch_filename, Reset_quicksearch(), and Unicode_strlen().
Referenced by Button_Load_or_Save(), and Quicksearch_list().
void Locate_list_item | ( | T_List_button * | list, |
short | selected_item | ||
) |
References T_List_button::Cursor_position, T_List_button::List_start, T_Scroller_button::Nb_elements, T_Scroller_button::Nb_visibles, and T_List_button::Scroller.
Referenced by Quicksearch_list().
int Quicksearch_list | ( | T_List_button * | list, |
T_Fileselector * | selector | ||
) |
byte Button_Load_or_Save | ( | T_Selector_settings * | settings, |
byte | load, | ||
T_IO_Context * | context | ||
) |
Launch the Load/Save dialog (file selector)
settings | the settings associated with this file selector |
load | 1 for a load dialog, 0 for a save |
context | the IO context |
References Back_color, T_Config::Bookmark_directory, T_Config::Bookmark_label, BUTTON_HELP, BUTTON_LOAD, BUTTON_SAVE, Calculate_relative_path(), Change_directory(), Check_timer(), Close_window(), T_IO_Context::Comment, T_Format::Comment, COMMENT_SIZE, Compute_click_offset_in_fileselector(), Compute_optimal_menu_colors(), Config, Confirmation_box(), CONTEXT_BRUSH, CONTEXT_MAIN_IMAGE, CONTEXT_PALETTE, CONTEXT_PREVIEW_PALETTE, Data_directory, T_Format::Default_extension, DEFAULT_FILEFORMAT, Destroy_context(), T_Selector_settings::Directory, Directory_exists(), T_Selector_settings::Directory_unicode, Display_bookmark(), Display_cursor(), Display_file_list(), Display_menu(), Error, Extract_filename(), T_IO_Context::File_directory, File_exists(), File_formats, T_IO_Context::File_name, T_IO_Context::File_name_unicode, Filelist, T_Selector_settings::filename, FILENAME_COMPARE, T_Selector_settings::filename_unicode, Find_file_in_fileselector(), Find_last_separator(), T_Fileselector::First, T_IO_Context::Format, format, FORMAT_ALL_FILES, FORMAT_CLIPBOARD, T_Selector_settings::Format_filter, Free_fileselector_list(), FSOBJECT_DIR, FSOBJECT_DRIVE, FSOBJECT_FILE, T_Fileselector_item::Full_name, Get_current_directory(), Get_fileformat(), Get_item_by_index(), Get_selected_item(), Get_Unicode_Filename(), GFX2_DEBUG, GFX2_INFO, GFX2_Log(), GFX2_WARNING, Hide_cursor, Highlight_file(), ICON_STAR, Init_chrono(), Init_context_preview(), INPUT_TYPE_FILENAME, INPUT_TYPE_STRING, Is_shortcut(), Key, KEY_BACKSPACE, KEY_DELETE, KEY_DOWN, KEY_END, KEY_ESC, KEY_HOME, KEY_MOUSEWHEELDOWN, KEY_MOUSEWHEELUP, KEY_NONE, KEY_PAGEDOWN, KEY_PAGEUP, KEY_RETURN, KEY_UNKNOWN, KEY_UP, T_Format::Label, LEFT_SIDE, Load, Load_image(), Main, MC_Black, MC_Dark, MC_Light, Menu_factor_Y, Menu_Y_before_window, Mouse_K, NB_BOOKMARKS, T_Fileselector::Nb_directories, T_Fileselector::Nb_elements, Nb_known_formats(), New_preview_is_needed, NULL, T_Selector_settings::Offset, Open_window(), T_Document::palette, T_Format::Palette_only, PARENT_DIR, T_Selector_settings::Position, Position_last_dot(), Position_last_dot_unicode(), Prepare_and_display_filelist(), PREVIEW_HEIGHT, PREVIEW_WIDTH, Print_filename_in_fileselector(), Print_in_window(), Quicksearch(), Quit_is_required, Read_list_of_drives(), Read_list_of_files(), Readline(), Readline_ex(), Readline_ex_unicode(), Reload_list_of_files(), Remove_directory(), Remove_path(), Reset_quicksearch(), RIGHT_SIDE, T_Format::Save, Save, Save_image(), Scroll_fileselector(), Selected_type, Selector, Selector_end(), Selector_home(), Selector_page_down(), Selector_page_up(), Selector_scroll_down(), Selector_scroll_up(), Set_palette(), SHORTCUT_COPY, SHORTCUT_PASTE, Sort_list_of_files(), SPECIAL_LOAD_BRUSH, SPECIAL_SAVE_BRUSH, T_Config::Timer_delay, Timer_state, T_IO_Context::Type, T_Fileselector_item::Type, Unicode_char_strlcat(), Unicode_char_strlcpy(), Unicode_strdup(), Unicode_strlcpy(), Unicode_strlen(), Unselect_button(), Update_window_area, Wait_end_of_click(), Window_attribute2, Window_clicked_button(), Window_display_frame_in(), Window_display_icon_sprite(), Window_dropdown_add_item(), Window_height, Window_help(), Window_pos_Y, Window_rectangle(), Window_set_dropdown_button(), Window_set_input_button(), Window_set_normal_button(), Window_set_scroller_button(), Window_set_special_button(), Window_width, and Windows_open.
Referenced by Load_picture(), and Save_picture().
|
static |
true if the preview timer need to be restarted
Referenced by Button_Load_or_Save(), and Scroll_fileselector().
|
static |
|
static |
Selector settings to use, for all functions called by Load_or_save.
Referenced by Button_Load_or_Save(), Highlight_file(), Prepare_and_display_filelist(), Print_current_directory(), Print_filename_in_fileselector(), Reload_list_of_files(), and Scroll_fileselector().
|
static |
Type of the selected entry in the file selector.
Referenced by Button_Load_or_Save(), Prepare_and_display_filelist(), and Scroll_fileselector().
|
static |
Current quicksearch string.
Referenced by Quicksearch(), and Reset_quicksearch().