doc rewrites into full sentences.

master
Allen Webster 2016-07-02 10:15:15 -04:00
parent 6f81e5d3d5
commit c1986f6f44
12 changed files with 2400 additions and 1438 deletions

File diff suppressed because it is too large Load Diff

View File

@ -26,8 +26,35 @@ typedef struct Offset_String{
} Offset_String; } Offset_String;
#endif #endif
// These are regular hooks, any of them can be set to any function
// that matches the HOOK_SIG pattern.
enum Hook_ID{
hook_start,
hook_file_out_of_sync,
// never below this
hook_type_count
};
// These are for special hooks, each must bind to specialized signatures
// that do not necessarily have access to the app pointer.
enum Special_Hook_ID{
_hook_scroll_rule = hook_type_count,
_hook_new_file,
_hook_open_file,
_hook_command_caller,
_hook_input_filter,
};
#define CommandEqual(c1,c2) ((unsigned long long)(c1) == (unsigned long long)(c2))
#define CUSTOM_COMMAND_SIG(name) void name(struct Application_Links *app)
typedef CUSTOM_COMMAND_SIG(Custom_Command_Function);
#include "4coder_types.h" #include "4coder_types.h"
#define COMMAND_CALLER_HOOK(name) int name(struct Application_Links *app, Generic_Command cmd)
typedef COMMAND_CALLER_HOOK(Command_Caller_Hook_Function);
inline Key_Event_Data inline Key_Event_Data
key_event_data_zero(){ key_event_data_zero(){
Key_Event_Data data={0}; Key_Event_Data data={0};
@ -51,50 +78,26 @@ make_range(int p1, int p2){
} }
return(range); return(range);
} }
// These are regular hooks, any of them can be set to any function
// that matches the HOOK_SIG pattern.
enum Hook_ID{
hook_start,
hook_file_out_of_sync,
// never below this
hook_type_count
};
// These are for special hooks, each must bind to specialized signatures
// that do not necessarily have access to the app pointer.
enum Special_Hook_ID{
_hook_scroll_rule = hook_type_count,
_hook_new_file,
_hook_open_file,
_hook_command_caller,
_hook_input_filter,
};
inline Buffer_Summary inline Buffer_Summary
buffer_summary_zero(){ buffer_summary_zero(){
Buffer_Summary summary={0}; Buffer_Summary summary={0};
return(summary); return(summary);
} }
inline View_Summary inline View_Summary
view_summary_zero(){ view_summary_zero(){
View_Summary summary={0}; View_Summary summary={0};
return(summary); return(summary);
} }
#define CommandEqual(c1,c2) ((unsigned long long)(c1) == (unsigned long long)(c2))
#define VIEW_ROUTINE_SIG(name) void name(struct Application_Links *app, int view_id) #define VIEW_ROUTINE_SIG(name) void name(struct Application_Links *app, int view_id)
#define GET_BINDING_DATA(name) int name(void *data, int size) #define GET_BINDING_DATA(name) int name(void *data, int size)
#define CUSTOM_COMMAND_SIG(name) void name(struct Application_Links *app)
#define HOOK_SIG(name) int name(struct Application_Links *app) #define HOOK_SIG(name) int name(struct Application_Links *app)
#define OPEN_FILE_HOOK_SIG(name) int name(struct Application_Links *app, int buffer_id) #define OPEN_FILE_HOOK_SIG(name) int name(struct Application_Links *app, int buffer_id)
#define SCROLL_RULE_SIG(name) int name(float target_x, float target_y, float *scroll_x, float *scroll_y, int view_id, int is_new_target, float dt) #define SCROLL_RULE_SIG(name) int name(float target_x, float target_y, float *scroll_x, float *scroll_y, int view_id, int is_new_target, float dt)
#define INPUT_FILTER_SIG(name) void name(Mouse_State *mouse) #define INPUT_FILTER_SIG(name) void name(Mouse_State *mouse)
typedef VIEW_ROUTINE_SIG(View_Routine_Function); typedef VIEW_ROUTINE_SIG(View_Routine_Function);
typedef CUSTOM_COMMAND_SIG(Custom_Command_Function);
typedef GET_BINDING_DATA(Get_Binding_Data_Function); typedef GET_BINDING_DATA(Get_Binding_Data_Function);
typedef HOOK_SIG(Hook_Function); typedef HOOK_SIG(Hook_Function);
@ -102,13 +105,6 @@ typedef OPEN_FILE_HOOK_SIG(Open_File_Hook_Function);
typedef SCROLL_RULE_SIG(Scroll_Rule_Function); typedef SCROLL_RULE_SIG(Scroll_Rule_Function);
typedef INPUT_FILTER_SIG(Input_Filter_Function); typedef INPUT_FILTER_SIG(Input_Filter_Function);
union Generic_Command{
Command_ID cmdid;
Custom_Command_Function *command;
};
#define COMMAND_CALLER_HOOK(name) int name(struct Application_Links *app, Generic_Command cmd)
typedef COMMAND_CALLER_HOOK(Command_Caller_Hook_Function);

View File

@ -1,50 +1,50 @@
#define EXEC_COMMAND_SIG(n) void n(Application_Links *app, uint64_t command_id) #define EXEC_COMMAND_SIG(n) bool32 n(Application_Links *app, Command_ID command_id)
#define EXEC_SYSTEM_COMMAND_SIG(n) int n(Application_Links *app, View_Summary *view, Buffer_Identifier buffer, char *path, int path_len, char *command, int command_len, unsigned int flags) #define EXEC_SYSTEM_COMMAND_SIG(n) bool32 n(Application_Links *app, View_Summary *view, Buffer_Identifier buffer, char *path, int32_t path_len, char *command, int32_t command_len, Command_Line_Input_Flag flags)
#define CLIPBOARD_POST_SIG(n) void n(Application_Links *app, char *str, int len) #define CLIPBOARD_POST_SIG(n) void n(Application_Links *app, int32_t clipboard_id, char *str, int32_t len)
#define CLIPBOARD_COUNT_SIG(n) int n(Application_Links *app) #define CLIPBOARD_COUNT_SIG(n) int32_t n(Application_Links *app, int32_t clipboard_id)
#define CLIPBOARD_INDEX_SIG(n) int n(Application_Links *app, int index, char *out, int len) #define CLIPBOARD_INDEX_SIG(n) int32_t n(Application_Links *app, int32_t clipboard_id, int32_t item_index, char *out, int32_t len)
#define GET_BUFFER_FIRST_SIG(n) Buffer_Summary n(Application_Links *app, unsigned int access) #define GET_BUFFER_FIRST_SIG(n) Buffer_Summary n(Application_Links *app, Access_Flag access)
#define GET_BUFFER_NEXT_SIG(n) void n(Application_Links *app, Buffer_Summary *buffer, unsigned int access) #define GET_BUFFER_NEXT_SIG(n) void n(Application_Links *app, Buffer_Summary *buffer, Access_Flag access)
#define GET_BUFFER_SIG(n) Buffer_Summary n(Application_Links *app, int buffer_id, unsigned int access) #define GET_BUFFER_SIG(n) Buffer_Summary n(Application_Links *app, Buffer_ID buffer_id, Access_Flag access)
#define GET_BUFFER_BY_NAME_SIG(n) Buffer_Summary n(Application_Links *app, char *name, int len, unsigned int access) #define GET_BUFFER_BY_NAME_SIG(n) Buffer_Summary n(Application_Links *app, char *name, int32_t len, Access_Flag access)
#define BUFFER_BOUNDARY_SEEK_SIG(n) int n(Application_Links *app, Buffer_Summary *buffer, int start_pos, int seek_forward, unsigned int flags) #define BUFFER_BOUNDARY_SEEK_SIG(n) int32_t n(Application_Links *app, Buffer_Summary *buffer, int32_t start_pos, bool32 seek_forward, Seek_Boundary_Flag flags)
#define BUFFER_READ_RANGE_SIG(n) int n(Application_Links *app, Buffer_Summary *buffer, int start, int end, char *out) #define BUFFER_READ_RANGE_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer, int32_t start, int32_t end, char *out)
#define BUFFER_REPLACE_RANGE_SIG(n) int n(Application_Links *app, Buffer_Summary *buffer, int start, int end, char *str, int len) #define BUFFER_REPLACE_RANGE_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer, int32_t start, int32_t end, char *str, int32_t len)
#define BUFFER_SET_SETTING_SIG(n) int n(Application_Links *app, Buffer_Summary *buffer, int setting, int value) #define BUFFER_SET_SETTING_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer, Buffer_Setting_ID setting, int32_t value)
#define BUFFER_AUTO_INDENT_SIG(n) int n(Application_Links *app, Buffer_Summary *buffer, int start, int end, int tab_width, unsigned int flags) #define BUFFER_AUTO_INDENT_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer, int32_t start, int32_t end, int32_t tab_width, Auto_Indent_Flag flags)
#define CREATE_BUFFER_SIG(n) Buffer_Summary n(Application_Links *app, char *filename, int filename_len, unsigned int flags) #define CREATE_BUFFER_SIG(n) Buffer_Summary n(Application_Links *app, char *filename, int32_t filename_len, Buffer_Create_Flag flags)
#define SAVE_BUFFER_SIG(n) int n(Application_Links *app, Buffer_Summary *buffer, char *filename, int filename_len, unsigned int flags) #define SAVE_BUFFER_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer, char *filename, int32_t filename_len, uint32_t flags)
#define KILL_BUFFER_SIG(n) int n(Application_Links *app, Buffer_Identifier buffer, int view_id, unsigned int flags) #define KILL_BUFFER_SIG(n) bool32 n(Application_Links *app, Buffer_Identifier buffer, View_ID view_id, Buffer_Kill_Flag flags)
#define GET_VIEW_FIRST_SIG(n) View_Summary n(Application_Links *app, unsigned int access) #define GET_VIEW_FIRST_SIG(n) View_Summary n(Application_Links *app, Access_Flag access)
#define GET_VIEW_NEXT_SIG(n) void n(Application_Links *app, View_Summary *view, unsigned int access) #define GET_VIEW_NEXT_SIG(n) void n(Application_Links *app, View_Summary *view, Access_Flag access)
#define GET_VIEW_SIG(n) View_Summary n(Application_Links *app, int view_id, unsigned int access) #define GET_VIEW_SIG(n) View_Summary n(Application_Links *app, View_ID view_id, Access_Flag access)
#define GET_ACTIVE_VIEW_SIG(n) View_Summary n(Application_Links *app, unsigned int access) #define GET_ACTIVE_VIEW_SIG(n) View_Summary n(Application_Links *app, Access_Flag access)
#define SET_ACTIVE_VIEW_SIG(n) int n(Application_Links *app, View_Summary *view) #define SET_ACTIVE_VIEW_SIG(n) bool32 n(Application_Links *app, View_Summary *view)
#define VIEW_SET_SETTING_SIG(n) int n(Application_Links *app, View_Summary *view, int setting, int value) #define VIEW_SET_SETTING_SIG(n) bool32 n(Application_Links *app, View_Summary *view, View_Setting_ID setting, int32_t value)
#define VIEW_SET_SPLIT_PROPORTION_SIG(n) int n(Application_Links *app, View_Summary *view, float t) #define VIEW_SET_SPLIT_PROPORTION_SIG(n) bool32 n(Application_Links *app, View_Summary *view, float t)
#define VIEW_COMPUTE_CURSOR_SIG(n) int n(Application_Links *app, View_Summary *view, Buffer_Seek seek, Full_Cursor *cursor_out) #define VIEW_COMPUTE_CURSOR_SIG(n) bool32 n(Application_Links *app, View_Summary *view, Buffer_Seek seek, Full_Cursor *cursor_out)
#define VIEW_SET_CURSOR_SIG(n) int n(Application_Links *app, View_Summary *view, Buffer_Seek seek, int set_preferred_x) #define VIEW_SET_CURSOR_SIG(n) bool32 n(Application_Links *app, View_Summary *view, Buffer_Seek seek, bool32 set_preferred_x)
#define VIEW_SET_MARK_SIG(n) int n(Application_Links *app, View_Summary *view, Buffer_Seek seek) #define VIEW_SET_MARK_SIG(n) bool32 n(Application_Links *app, View_Summary *view, Buffer_Seek seek)
#define VIEW_SET_HIGHLIGHT_SIG(n) int n(Application_Links *app, View_Summary *view, int start, int end, int turn_on) #define VIEW_SET_HIGHLIGHT_SIG(n) bool32 n(Application_Links *app, View_Summary *view, int32_t start, int32_t end, bool32 turn_on)
#define VIEW_SET_BUFFER_SIG(n) int n(Application_Links *app, View_Summary *view, int buffer_id, unsigned int flags) #define VIEW_SET_BUFFER_SIG(n) bool32 n(Application_Links *app, View_Summary *view, Buffer_ID buffer_id, Set_Buffer_Flag flags)
#define VIEW_POST_FADE_SIG(n) int n(Application_Links *app, View_Summary *view, float seconds, int start, int end, unsigned int color) #define VIEW_POST_FADE_SIG(n) bool32 n(Application_Links *app, View_Summary *view, float seconds, int32_t start, int32_t end, int_color color)
#define GET_USER_INPUT_SIG(n) User_Input n(Application_Links *app, unsigned int get_type, unsigned int abort_type) #define GET_USER_INPUT_SIG(n) User_Input n(Application_Links *app, Input_Type_Flag get_type, Input_Type_Flag abort_type)
#define GET_COMMAND_INPUT_SIG(n) User_Input n(Application_Links *app) #define GET_COMMAND_INPUT_SIG(n) User_Input n(Application_Links *app)
#define GET_MOUSE_STATE_SIG(n) Mouse_State n(Application_Links *app) #define GET_MOUSE_STATE_SIG(n) Mouse_State n(Application_Links *app)
#define START_QUERY_BAR_SIG(n) int n(Application_Links *app, Query_Bar *bar, unsigned int flags) #define START_QUERY_BAR_SIG(n) bool32 n(Application_Links *app, Query_Bar *bar, uint32_t flags)
#define END_QUERY_BAR_SIG(n) void n(Application_Links *app, Query_Bar *bar, unsigned int flags) #define END_QUERY_BAR_SIG(n) void n(Application_Links *app, Query_Bar *bar, uint32_t flags)
#define PRINT_MESSAGE_SIG(n) void n(Application_Links *app, char *str, int len) #define PRINT_MESSAGE_SIG(n) void n(Application_Links *app, char *str, int32_t len)
#define CHANGE_THEME_SIG(n) void n(Application_Links *app, char *name, int len) #define CHANGE_THEME_SIG(n) void n(Application_Links *app, char *name, int32_t len)
#define CHANGE_FONT_SIG(n) void n(Application_Links *app, char *name, int len) #define CHANGE_FONT_SIG(n) void n(Application_Links *app, char *name, int32_t len)
#define SET_THEME_COLORS_SIG(n) void n(Application_Links *app, Theme_Color *colors, int count) #define SET_THEME_COLORS_SIG(n) void n(Application_Links *app, Theme_Color *colors, int32_t count)
#define GET_THEME_COLORS_SIG(n) void n(Application_Links *app, Theme_Color *colors, int count) #define GET_THEME_COLORS_SIG(n) void n(Application_Links *app, Theme_Color *colors, int32_t count)
#define DIRECTORY_GET_HOT_SIG(n) int n(Application_Links *app, char *out, int capacity) #define DIRECTORY_GET_HOT_SIG(n) int32_t n(Application_Links *app, char *out, int32_t capacity)
#define GET_FILE_LIST_SIG(n) File_List n(Application_Links *app, char *dir, int len) #define GET_FILE_LIST_SIG(n) File_List n(Application_Links *app, char *dir, int32_t len)
#define FREE_FILE_LIST_SIG(n) void n(Application_Links *app, File_List list) #define FREE_FILE_LIST_SIG(n) void n(Application_Links *app, File_List list)
#define FILE_EXISTS_SIG(n) int n(Application_Links *app, char *filename, int len) #define FILE_EXISTS_SIG(n) bool32 n(Application_Links *app, char *filename, int len)
#define DIRECTORY_CD_SIG(n) int n(Application_Links *app, char *dir, int *len, int capacity, char *rel_path, int rel_len) #define DIRECTORY_CD_SIG(n) bool32 n(Application_Links *app, char *dir, int *len, int capacity, char *rel_path, int rel_len)
#define GET_4ED_PATH_SIG(n) int n(Application_Links *app, char *out, int capacity) #define GET_4ED_PATH_SIG(n) bool32 n(Application_Links *app, char *out, int32_t capacity)
#define SHOW_MOUSE_CURSOR_SIG(n) void n(Application_Links *app, int show) #define SHOW_MOUSE_CURSOR_SIG(n) void n(Application_Links *app, Mouse_Cursor_Show_Type show)
extern "C"{ extern "C"{
typedef EXEC_COMMAND_SIG(Exec_Command_Function); typedef EXEC_COMMAND_SIG(Exec_Command_Function);
typedef EXEC_SYSTEM_COMMAND_SIG(Exec_System_Command_Function); typedef EXEC_SYSTEM_COMMAND_SIG(Exec_System_Command_Function);

View File

@ -236,7 +236,7 @@ clipboard_copy(Application_Links *app, int start, int end, Buffer_Summary *buffe
if (size <= app->memory_size){ if (size <= app->memory_size){
app->buffer_read_range(app, &buffer, start, end, str); app->buffer_read_range(app, &buffer, start, end, str);
app->clipboard_post(app, str, size); app->clipboard_post(app, 0, str, size);
if (buffer_out){*buffer_out = buffer;} if (buffer_out){*buffer_out = buffer;}
result = true; result = true;
} }
@ -285,7 +285,7 @@ View_Paste_Index *view_paste_index = view_paste_index_ - 1;
CUSTOM_COMMAND_SIG(paste){ CUSTOM_COMMAND_SIG(paste){
unsigned int access = AccessOpen; unsigned int access = AccessOpen;
int count = app->clipboard_count(app); int count = app->clipboard_count(app, 0);
if (count > 0){ if (count > 0){
View_Summary view = app->get_active_view(app, access); View_Summary view = app->get_active_view(app, access);
@ -294,7 +294,7 @@ CUSTOM_COMMAND_SIG(paste){
int paste_index = 0; int paste_index = 0;
view_paste_index[view.view_id].index = paste_index; view_paste_index[view.view_id].index = paste_index;
int len = app->clipboard_index(app, paste_index, 0, 0); int len = app->clipboard_index(app, 0, paste_index, 0, 0);
char *str = 0; char *str = 0;
if (len <= app->memory_size){ if (len <= app->memory_size){
@ -302,7 +302,7 @@ CUSTOM_COMMAND_SIG(paste){
} }
if (str){ if (str){
app->clipboard_index(app, paste_index, str, len); app->clipboard_index(app, 0, paste_index, str, len);
Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access); Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access);
int pos = view.cursor.pos; int pos = view.cursor.pos;
@ -321,7 +321,7 @@ CUSTOM_COMMAND_SIG(paste){
CUSTOM_COMMAND_SIG(paste_next){ CUSTOM_COMMAND_SIG(paste_next){
unsigned int access = AccessOpen; unsigned int access = AccessOpen;
int count = app->clipboard_count(app); int count = app->clipboard_count(app, 0);
if (count > 0){ if (count > 0){
View_Summary view = app->get_active_view(app, access); View_Summary view = app->get_active_view(app, access);
@ -334,7 +334,7 @@ CUSTOM_COMMAND_SIG(paste_next){
int paste_index = view_paste_index[view.view_id].index + 1; int paste_index = view_paste_index[view.view_id].index + 1;
view_paste_index[view.view_id].index = paste_index; view_paste_index[view.view_id].index = paste_index;
int len = app->clipboard_index(app, paste_index, 0, 0); int len = app->clipboard_index(app, 0, paste_index, 0, 0);
char *str = 0; char *str = 0;
if (len <= app->memory_size){ if (len <= app->memory_size){
@ -342,7 +342,7 @@ CUSTOM_COMMAND_SIG(paste_next){
} }
if (str){ if (str){
app->clipboard_index(app, paste_index, str, len); app->clipboard_index(app, 0, paste_index, str, len);
Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access); Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access);
Range range = get_range(&view); Range range = get_range(&view);
@ -970,9 +970,9 @@ isearch(Application_Links *app, int start_reversed){
int step_forward = 0; int step_forward = 0;
int step_backward = 0; int step_backward = 0;
if (CommandEqual(in.command, search) || if ((in.command.command == search) ||
in.key.keycode == key_page_down || in.key.keycode == key_down) step_forward = 1; in.key.keycode == key_page_down || in.key.keycode == key_down) step_forward = 1;
if (CommandEqual(in.command, reverse_search) || if ((in.command.command == reverse_search) ||
in.key.keycode == key_page_up || in.key.keycode == key_up) step_backward = 1; in.key.keycode == key_page_up || in.key.keycode == key_up) step_backward = 1;
int start_pos = pos; int start_pos = pos;
@ -1365,6 +1365,39 @@ CUSTOM_COMMAND_SIG(write_and_auto_tab){
// Default Building Stuff // Default Building Stuff
// //
// NOTE(allen|a4.0.9): This is provided to establish a default method of getting
// a "build directory". This function tries to setup the build directory in the
// directory of the given buffer, it cannot it get's the 4coder hot directory.
// This behavior is a little different than previous versions of 4coder.
//
// There is requirement that a custom build system in 4coder actually use the
// directory given by this function.
static int
get_build_directory(Application_Links *app, Buffer_Summary *buffer, String *dir_out){
int result = false;
if (buffer->file_name){
if (!match(buffer->file_name, buffer->buffer_name)){
String dir = make_string(buffer->file_name,
buffer->file_name_len,
buffer->file_name_len+1);
remove_last_folder(&dir);
append(dir_out, dir);
result = true;
}
}
if (!result){
int len = app->directory_get_hot(app, dir_out->str,
dir_out->memory_size - dir_out->size);
if (len + dir_out->size < dir_out->memory_size){
result = true;
}
}
return(result);
}
CUSTOM_COMMAND_SIG(build_search_regular){ CUSTOM_COMMAND_SIG(build_search_regular){
// NOTE(allen|a3.3): An example of traversing the filesystem through parent // NOTE(allen|a3.3): An example of traversing the filesystem through parent
// directories looking for a file, in this case a batch file to execute. // directories looking for a file, in this case a batch file to execute.
@ -1401,14 +1434,15 @@ CUSTOM_COMMAND_SIG(build_search_regular){
// This doesn't actually change the hot directory of 4coder, it's only effect is to // This doesn't actually change the hot directory of 4coder, it's only effect is to
// modify the string you passed in to reflect the change in directory if that change was possible. // modify the string you passed in to reflect the change in directory if that change was possible.
int old_size; int old_size = 0;
int size = app->memory_size/2; int size = app->memory_size/2;
unsigned int access = AccessAll; unsigned int access = AccessAll;
View_Summary view = app->get_active_view(app, access); View_Summary view = app->get_active_view(app, access);
Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access);
String dir = make_string(app->memory, 0, size); String dir = make_string(app->memory, 0, size);
dir.size = app->directory_get_hot(app, dir.str, dir.memory_size); get_build_directory(app, &buffer, &dir);
String command = make_string((char*)app->memory + size, 0, size); String command = make_string((char*)app->memory + size, 0, size);

View File

@ -1,8 +1,25 @@
/* DOC(Key_Code is the type alias for key codes.) */ /* DOC(bool32 is an alias name to signal that an integer parameter or field is for
true/false vales.) */
typedef int32_t bool32;
/* DOC(int_color is an alias name to signal that an integer parameter or field is for
a color value, colors are specified as 24 bit integers in 3 channels: 0xRRGGBB.) */
typedef uint32_t int_color;
/* DOC(Key_Code is the alias for key codes including raw codes and codes translated
to textual input that takes modifiers into account.) */
typedef unsigned char Key_Code; typedef unsigned char Key_Code;
/* DOC(Buffer_ID is used to name a 4coder buffer. Each buffer has a unique id but
when a buffer is closed it's id may be recycled by future, different buffers.) */
typedef int32_t Buffer_ID;
/* DOC(View_ID is used to name a 4coder view. Each view has a unique id in
the range [1,16].) */
typedef int32_t View_ID;
#define ENUM(type,name) typedef type name; enum name##_ #define ENUM(type,name) typedef type name; enum name##_
#define FLAGENUM(name) typedef uint32_t name; enum name##_ #define FLAGENUM(name) typedef uint32_t name; enum name##_
@ -269,14 +286,26 @@ ENUM(int32_t, Mouse_Cursor_Show_Type){
// MouseCursorShow_WhenActive,// TODO(allen): coming soon // MouseCursorShow_WhenActive,// TODO(allen): coming soon
}; };
/* DOC(
Generic_Command acts as a name for a command, and can name an
internal command or a custom command.
)*/
union Generic_Command{
/*DOC(If this Generic_Command represents an internal command the cmdid field
will have a value less than cmdid_count, and this field is the command id for the command.)*/
Command_ID cmdid;
/*DOC(If this Generic_Command does not represent an internal command the command
field is the pointer to the custom command..)*/
Custom_Command_Function *command;
};
/* DOC( /* DOC(
Key_Event_Data describes a key event, including the Key_Event_Data describes a key event, including the
translation to a character, the translation to translation to a character, the translation to
a character ignoring the state of caps lock, and a character ignoring the state of caps lock, and
an array of all the modifiers that were pressed an array of all the modifiers that were pressed
at the time of the event. at the time of the event.
) )*/
*/
struct Key_Event_Data{ struct Key_Event_Data{
/* DOC(This field is the raw keycode which is always non-zero in valid key events.) */ /* DOC(This field is the raw keycode which is always non-zero in valid key events.) */
Key_Code keycode; Key_Code keycode;
@ -405,39 +434,39 @@ struct Buffer_Summary{
This field indicates whether the Buffer_Summary describes a buffer that is open in 4coder. This field indicates whether the Buffer_Summary describes a buffer that is open in 4coder.
When this field is false the summary is referred to as a "null summary". When this field is false the summary is referred to as a "null summary".
) */ ) */
int exists; bool32 exists;
/* DOC(If this is not a null summary, this field indicates whether the buffer has finished loading.) */ /* DOC(If this is not a null summary, this field indicates whether the buffer has finished loading.) */
int ready; bool32 ready;
/* DOC( /* DOC(
If this is not a null summary this field is the id of the associated buffer. If this is not a null summary this field is the id of the associated buffer.
If this is a null summary then buffer_id is 0. If this is a null summary then buffer_id is 0.
) */ ) */
int buffer_id; int32_t buffer_id;
/* /*
DOC(If this is not a null summary, this field contains flags describing the protection status of the buffer.) DOC(If this is not a null summary, this field contains flags describing the protection status of the buffer.)
DOC_SEE(Access_Flag) DOC_SEE(Access_Flag)
*/ */
unsigned int lock_flags; Access_Flag lock_flags;
/* DOC(If this is not a null summary, this field specifies the size of the text in the buffer.) */ /* DOC(If this is not a null summary, this field specifies the size of the text in the buffer.) */
int size; int32_t size;
/* DOC(If this is not a null summary, this field specifies the file name associated to this buffer.) */ /* DOC(If this is not a null summary, this field specifies the file name associated to this buffer.) */
char *file_name; char *file_name;
/* DOC(This field specifies the length of the file_name string.) */ /* DOC(This field specifies the length of the file_name string.) */
int file_name_len; int32_t file_name_len;
/* DOC(If this is not a null summary, this field specifies the name of the buffer.) */ /* DOC(If this is not a null summary, this field specifies the name of the buffer.) */
char *buffer_name; char *buffer_name;
/* DOC(This field specifies the length of the buffer_name string.) */ /* DOC(This field specifies the length of the buffer_name string.) */
int buffer_name_len; int32_t buffer_name_len;
/* DOC(This is a hold over from an old system, consider it deprecated.) */ /* DOC(This is a hold over from an old system, consider it deprecated.) */
int buffer_cursor_pos; int32_t buffer_cursor_pos;
/* DOC(If this is not a null summary, this field indicates whether the buffer is set to lex tokens.) */ /* DOC(If this is not a null summary, this field indicates whether the buffer is set to lex tokens.) */
int is_lexed; bool32 is_lexed;
/* DOC(If this is not a null summary, this field specifies the id of the command map for this buffer.) */ /* DOC(If this is not a null summary, this field specifies the id of the command map for this buffer.) */
int map_id; int32_t map_id;
}; };
/* DOC( /* DOC(
@ -448,19 +477,19 @@ struct View_Summary{
This field indicates whether the View_Summary describes a view that is open in 4coder. This field indicates whether the View_Summary describes a view that is open in 4coder.
When this field is false the summary is referred to as a "null summary". When this field is false the summary is referred to as a "null summary".
) */ ) */
int exists; bool32 exists;
/* DOC( /* DOC(
If this is not a null summary, this field is the id of the associated view. If this is not a null summary, this field is the id of the associated view.
If this is a null summary then view_id is 0. If this is a null summary then view_id is 0.
) */ ) */
int view_id; int32_t view_id;
/* DOC(If this is not a null summary, and this view looks at a buffer, this is the id of the buffer.) */ /* DOC(If this is not a null summary, and this view looks at a buffer, this is the id of the buffer.) */
int buffer_id; int32_t buffer_id;
/* /*
DOC(If this is not a null summary, this field contains flags describing the protection status of the view.) DOC(If this is not a null summary, this field contains flags describing the protection status of the view.)
DOC_SEE(Access_Flag) DOC_SEE(Access_Flag)
*/ */
unsigned int lock_flags; Access_Flag lock_flags;
/* /*
DOC(If this is not a null summary, this describes the position of the cursor.) DOC(If this is not a null summary, this describes the position of the cursor.)
@ -477,9 +506,9 @@ struct View_Summary{
/* DOC(If this is not a null summary, this specifies the height of a line rendered in the view.) */ /* DOC(If this is not a null summary, this specifies the height of a line rendered in the view.) */
float line_height; float line_height;
/* DOC(If this is not a null summary, this indicates that the view is set to render with unwrapped lines.) */ /* DOC(If this is not a null summary, this indicates that the view is set to render with unwrapped lines.) */
int unwrapped_lines; bool32 unwrapped_lines;
/* DOC(If this is not a null summary, this indicates that the view is set to highlight white space.) */ /* DOC(If this is not a null summary, this indicates that the view is set to highlight white space.) */
int show_whitespace; bool32 show_whitespace;
/* DOC(This feature is not fully implemented yet.) */ /* DOC(This feature is not fully implemented yet.) */
i32_Rect file_region; i32_Rect file_region;
@ -487,15 +516,18 @@ struct View_Summary{
GUI_Scroll_Vars scroll_vars; GUI_Scroll_Vars scroll_vars;
}; };
/* DOC(User_Input describes a user input event which can be either a key press or mouse event.) */ /*
DOC(User_Input describes a user input event which can be either a key press or mouse event.)
DOC_SEE(User_Input_Type_ID)
DOC_SEE(Generic_Command)
*/
struct User_Input{ struct User_Input{
/* /*
DOC(This field specifies whether the event was a key press or mouse event.) DOC(This field specifies whether the event was a key press or mouse event.)
DOC_SEE(User_Input_Type_ID)
*/ */
int type; User_Input_Type_ID type;
/* DOC(This field indicates that an abort event has occurred and the command needs to shut down.) */ /* DOC(This field indicates that an abort event has occurred and the command needs to shut down.) */
int abort; bool32 abort;
union{ union{
/* DOC(This field describes a key press event.) */ /* DOC(This field describes a key press event.) */
Key_Event_Data key; Key_Event_Data key;
@ -504,9 +536,8 @@ struct User_Input{
}; };
/* /*
DOC(If this event would trigger a command, this field specifies what the command would be.) DOC(If this event would trigger a command, this field specifies what the command would be.)
TODO
*/ */
unsigned long long command; Generic_Command command;
}; };
/* DOC(Query_Bar is a struct used to store information in the user's control /* DOC(Query_Bar is a struct used to store information in the user's control
@ -527,11 +558,11 @@ struct Event_Message{
/* /*
DOC(Theme_Color stores a style tag/color pair, for the purpose of setting and getting colors in the theme .) DOC(Theme_Color stores a style tag/color pair, for the purpose of setting and getting colors in the theme .)
DOC_SEE(Style_Tag) DOC_SEE(Style_Tag)
DOC_SEE(int_color)
*/ */
struct Theme_Color{ struct Theme_Color{
Style_Tag tag; Style_Tag tag;
/* DOC(This field specifies a color in a 24, bit 3 channel RGB integer.) */ int_color color;
uint32_t color;
}; };

View File

@ -1318,7 +1318,7 @@ app_hardcode_styles(Models *models){
++style; ++style;
///////////////// /////////////////
style_set_name(style, make_lit_string("Magic")); style_set_name(style, make_lit_string("Hjortshoej"));
style->main.back_color = 0xFFF0F0F0; style->main.back_color = 0xFFF0F0F0;
style->main.margin_color = 0xFF9E9E9E; style->main.margin_color = 0xFF9E9E9E;
@ -2402,7 +2402,7 @@ App_Step_Sig(app_step){
User_Input user_in; User_Input user_in;
user_in.type = UserInputKey; user_in.type = UserInputKey;
user_in.key = key; user_in.key = key;
user_in.command = (unsigned long long)cmd_bind.custom; user_in.command.command = cmd_bind.custom;
user_in.abort = 0; user_in.abort = 0;
if ((EventOnEsc & abort_flags) && key.keycode == key_esc){ if ((EventOnEsc & abort_flags) && key.keycode == key_esc){
@ -2453,7 +2453,7 @@ App_Step_Sig(app_step){
User_Input user_in; User_Input user_in;
user_in.type = UserInputMouse; user_in.type = UserInputMouse;
user_in.mouse = input->mouse; user_in.mouse = input->mouse;
user_in.command = 0; user_in.command.cmdid = 0;
user_in.abort = 0; user_in.abort = 0;
if (abort_flags & EventOnMouseMove){ if (abort_flags & EventOnMouseMove){

File diff suppressed because it is too large Load Diff

View File

@ -163,9 +163,7 @@ file_viewing_data_zero(){
} }
struct Recent_File_Data{ struct Recent_File_Data{
u64 unique_buffer_id;
GUI_Scroll_Vars scroll; GUI_Scroll_Vars scroll;
Full_Cursor cursor; Full_Cursor cursor;
i32 mark; i32 mark;
f32 preferred_x; f32 preferred_x;
@ -1600,7 +1598,7 @@ view_move_cursor_to_view(View *view, GUI_Scroll_Vars scroll){
} }
internal void internal void
view_move_view_to_cursor(View *view, GUI_Scroll_Vars *scroll){ view_move_view_to_cursor(View *view, GUI_Scroll_Vars *scroll, b32 center_view){
f32 max_x = view_file_width(view); f32 max_x = view_file_width(view);
f32 cursor_y = view_get_cursor_y(view); f32 cursor_y = view_get_cursor_y(view);
@ -1613,10 +1611,20 @@ view_move_view_to_cursor(View *view, GUI_Scroll_Vars *scroll){
Cursor_Limits limits = view_cursor_limits(view); Cursor_Limits limits = view_cursor_limits(view);
if (cursor_y > target_y + limits.max){ if (cursor_y > target_y + limits.max){
target_y = CEIL32(cursor_y - limits.max + limits.delta); if (center_view){
target_y = ROUND32(cursor_y - limits.max*.5f);
}
else{
target_y = CEIL32(cursor_y - limits.max + limits.delta);
}
} }
if (cursor_y < target_y + limits.min){ if (cursor_y < target_y + limits.min){
target_y = FLOOR32(cursor_y - limits.delta - limits.min); if (center_view){
target_y = ROUND32(cursor_y - limits.max*.5f);
}
else{
target_y = FLOOR32(cursor_y - limits.delta - limits.min);
}
} }
target_y = clamp(0, target_y, scroll_vars.max_y); target_y = clamp(0, target_y, scroll_vars.max_y);
@ -1645,13 +1653,6 @@ file_view_nullify_file(View *view){
internal void internal void
view_set_file(View *view, Editing_File *file, Models *models){ view_set_file(View *view, Editing_File *file, Models *models){
#if 0
// TODO(allen): This belongs somewhere else.
Font_Info *fnt_info = get_font_info(models->font_set, models->global_font.font_id);
view->font_advance = fnt_info->advance;
view->line_height = fnt_info->height;
#endif
if (view->file_data.file != 0){ if (view->file_data.file != 0){
touch_file(&models->working_set, view->file_data.file); touch_file(&models->working_set, view->file_data.file);
} }
@ -1662,18 +1663,16 @@ view_set_file(View *view, Editing_File *file, Models *models){
if (file){ if (file){
view->file_data.unwrapped_lines = file->settings.unwrapped_lines; view->file_data.unwrapped_lines = file->settings.unwrapped_lines;
u64 unique_buffer_id = file->unique_buffer_id;
Recent_File_Data *recent = &view->recent; Recent_File_Data *recent = &view->recent;
*recent = recent_file_data_zero();
view->recent = recent_file_data_zero();
recent->unique_buffer_id = unique_buffer_id;
if (file_is_ready(file)){ if (file_is_ready(file)){
view_measure_wraps(&models->mem.general, view); view_measure_wraps(&models->mem.general, view);
view->recent.cursor = view_compute_cursor_from_pos(view, file->state.cursor_pos); recent->cursor = view_compute_cursor_from_pos(view, file->state.cursor_pos);
view->recent.scroll.max_y = view_compute_max_target_y(view); recent->scroll.max_y = view_compute_max_target_y(view);
recent->preferred_x = view_get_cursor_x(view);
view_move_view_to_cursor(view, &view->recent.scroll); view_move_view_to_cursor(view, &recent->scroll, true);
view->reinit_scrolling = 1; view->reinit_scrolling = 1;
} }
} }
@ -3581,7 +3580,7 @@ view_end_cursor_scroll_updates(View *view){
if (view->gui_target.did_file){ if (view->gui_target.did_file){
view->recent.scroll.max_y = view_compute_max_target_y(view); view->recent.scroll.max_y = view_compute_max_target_y(view);
} }
view_move_view_to_cursor(view, view->current_scroll); view_move_view_to_cursor(view, view->current_scroll, false);
gui_post_scroll_vars(&view->gui_target, view->current_scroll, view->scroll_region); gui_post_scroll_vars(&view->gui_target, view->current_scroll, view->scroll_region);
break; break;
@ -4385,28 +4384,26 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su
&keys, &view->list_i, &update); &keys, &view->list_i, &update);
} }
{ begin_exhaustive_loop(&loop, hdir);
begin_exhaustive_loop(&loop, hdir); for (i = 0; i < loop.count; ++i){
for (i = 0; i < loop.count; ++i){ file_info = get_exhaustive_info(system, &models->working_set, &loop, i);
file_info = get_exhaustive_info(system, &models->working_set, &loop, i);
if (file_info.name_match){
id.id[0] = (u64)(file_info.info);
if (file_info.name_match){ String filename = make_string(file_info.info->filename,
id.id[0] = (u64)(file_info.info); file_info.info->filename_len,
file_info.info->filename_len+1);
String filename = make_string(file_info.info->filename,
file_info.info->filename_len, if (gui_do_file_option(target, id, filename,
file_info.info->filename_len+1); file_info.is_folder, file_info.message)){
if (file_info.is_folder){
if (gui_do_file_option(target, id, filename, set_last_folder(&hdir->string, file_info.info->filename, '/');
file_info.is_folder, file_info.message)){ do_new_directory = 1;
if (file_info.is_folder){ }
set_last_folder(&hdir->string, file_info.info->filename, '/'); else if (use_item_in_list){
do_new_directory = 1; complete = 1;
} copy(&comp_dest, loop.full_path);
else if (use_item_in_list){
complete = 1;
copy(&comp_dest, loop.full_path);
}
} }
} }
} }
@ -4938,8 +4935,6 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su
{ {
Recent_File_Data *recent = &view_ptr->recent; Recent_File_Data *recent = &view_ptr->recent;
SHOW_GUI_U64 (2, h_align, "absolute buffer id", recent->unique_buffer_id);
SHOW_GUI_BLANK (2);
SHOW_GUI_SCROLL(2, h_align, "scroll:", recent->scroll); SHOW_GUI_SCROLL(2, h_align, "scroll:", recent->scroll);
SHOW_GUI_BLANK (2); SHOW_GUI_BLANK (2);
SHOW_GUI_CURSOR(2, h_align, "cursor:", recent->cursor); SHOW_GUI_CURSOR(2, h_align, "cursor:", recent->cursor);

File diff suppressed because it is too large Load Diff

View File

@ -61,9 +61,10 @@ CUSTOM_COMMAND_SIG(build_in_build_panel){
# define build_search build_in_build_panel # define build_search build_in_build_panel
#endif #endif
#define GET_COMP_BUFFER() app->get_buffer_by_name(app, literal("*compilation*"), AccessAll);
CUSTOM_COMMAND_SIG(close_build_panel){ CUSTOM_COMMAND_SIG(close_build_panel){
Buffer_Summary buffer = Buffer_Summary buffer = GET_COMP_BUFFER();
app->get_buffer_by_name(app, literal("*compilation*"), AccessAll);
if (buffer.exists){ if (buffer.exists){
View_Summary build_view = get_first_view_with_buffer(app, buffer.buffer_id); View_Summary build_view = get_first_view_with_buffer(app, buffer.buffer_id);
@ -75,8 +76,18 @@ CUSTOM_COMMAND_SIG(close_build_panel){
} }
} }
CUSTOM_COMMAND_SIG(change_to_build_panel){
Buffer_Summary buffer = GET_COMP_BUFFER();
if (buffer.exists){
View_Summary build_view = get_first_view_with_buffer(app, buffer.buffer_id);
app->set_active_view(app, &build_view);
}
}
CUSTOM_COMMAND_SIG(change_active_panel_build){ CUSTOM_COMMAND_SIG(change_active_panel_build){
Buffer_Summary buffer = app->get_buffer_by_name(app, literal("*compilation*"), AccessAll); Buffer_Summary buffer = GET_COMP_BUFFER();
if (buffer.exists){ if (buffer.exists){
View_Summary build_view = get_first_view_with_buffer(app, buffer.buffer_id); View_Summary build_view = get_first_view_with_buffer(app, buffer.buffer_id);

View File

@ -286,6 +286,7 @@ get_bindings(void *data, int size){
// begin_map to clear everything that was in the map and // begin_map to clear everything that was in the map and
// bind new things instead. // bind new things instead.
begin_map(context, mapid_global); begin_map(context, mapid_global);
bind(context, '.', MDFR_ALT, change_to_build_panel);
bind(context, ',', MDFR_ALT, close_build_panel); bind(context, ',', MDFR_ALT, close_build_panel);
bind(context, 'n', MDFR_ALT, msvc_goto_next_error); bind(context, 'n', MDFR_ALT, msvc_goto_next_error);
bind(context, 'N', MDFR_ALT, msvc_goto_prev_error); bind(context, 'N', MDFR_ALT, msvc_goto_prev_error);

View File

@ -11,18 +11,16 @@ as this is the only one that will be used for generating headers and docs.
#define API_EXPORT #define API_EXPORT
API_EXPORT int API_EXPORT bool32
File_Exists(Application_Links *app, char *filename, int len)/* File_Exists(Application_Links *app, char *filename, int len)/*
DOC_PARAM(filename, the full path to a file) DOC_PARAM(filename, This parameter specifies the full path to a file; it need not be null terminated.)
DOC_PARAM(len, the number of characters in the filename string) DOC_PARAM(len, This parameter specifies the length of the filename string.)
DOC_RETURN(returns non-zero if the file exists, returns zero if the file does not exist) DOC_RETURN(This call returns non-zero if and only if the file exists.)
*/{ */{
char full_filename_space[1024]; char full_filename_space[1024];
String full_filename; String full_filename;
HANDLE file; HANDLE file;
b32 result; b32 result = 0;
result = 0;
if (len < sizeof(full_filename_space)){ if (len < sizeof(full_filename_space)){
full_filename = make_fixed_width_string(full_filename_space); full_filename = make_fixed_width_string(full_filename_space);
@ -41,23 +39,24 @@ DOC_RETURN(returns non-zero if the file exists, returns zero if the file does no
return(result); return(result);
} }
API_EXPORT int API_EXPORT bool32
Directory_CD(Application_Links *app, char *dir, int *len, int capacity, char *rel_path, int rel_len)/* Directory_CD(Application_Links *app, char *dir, int *len, int capacity, char *rel_path, int rel_len)/*
DOC_PARAM(dir, a string buffer containing a directory) DOC_PARAM(dir, This parameter provides a character buffer that stores a directory; it need not be null terminated.)
DOC_PARAM(len, the length of the string in the string buffer) DOC_PARAM(len, This parameter specifies the length of the dir string.)
DOC_PARAM(capacity, the maximum size of the string buffer) DOC_PARAM(capacity, This parameter specifies the maximum size of the dir string.)
DOC_PARAM(rel_path, the path to change to, may include '.' or '..') DOC_PARAM(rel_path, This parameter specifies the path to change to, may include '.' or '..'; it need not be null terminated.)
DOC_PARAM(rel_len, the length of the rel_path string) DOC_PARAM(rel_len, This parameter specifies the length of the rel_path string.)
DOC_RETURN(returns non-zero if the call succeeds, returns zero otherwise) DOC_RETURN(This call returns non-zero if the call succeeds.)
DOC DOC
( (
This call succeeds if the directory exists and the new directory fits inside the dir buffer. This call succeeds if the new directory exists and the it fits inside the
If the call succeeds the dir buffer is filled with the new directory and len contains the dir buffer. If the call succeeds the dir buffer is filled with the new
length of the string in the buffer. directory and len is overwritten with the length of the new string in the buffer.
For instance if dir contains "C:/Users/MySelf" and rel is "Documents" the buffer will contain For instance if dir contains "C:/Users/MySelf" and rel is "Documents" the buffer
"C:/Users/MySelf/Documents" and len will contain the length of that string. This call can will contain "C:/Users/MySelf/Documents" and len will contain the length of that
also be used with rel set to ".." to traverse to parent folders. string. This call can also be used with rel set to ".." to traverse to parent
folders.
) )
*/{ */{
String directory = make_string(dir, *len, capacity); String directory = make_string(dir, *len, capacity);
@ -97,11 +96,11 @@ also be used with rel set to ".." to traverse to parent folders.
return(result); return(result);
} }
API_EXPORT int API_EXPORT bool32
Get_4ed_Path(Application_Links *app, char *out, int capacity)/* Get_4ed_Path(Application_Links *app, char *out, int32_t capacity)/*
DOC_PARAM(out, A char buffer that receives the path to the 4ed executable file.) DOC_PARAM(out, This parameter provides a character buffer that receives the path to the 4ed executable file.)
DOC_PARAM(capacity, The maximum capacity of the output buffer.) DOC_PARAM(capacity, This parameter specifies the maximum capacity of the out buffer.)
DOC_RETURN(Returns non-zero on success, returns zero on failure.) DOC_RETURN(This call returns non-zero on success.)
*/{ */{
String str = make_string(out, 0, capacity); String str = make_string(out, 0, capacity);
return(system_get_binary_path(&str)); return(system_get_binary_path(&str));
@ -109,8 +108,8 @@ DOC_RETURN(Returns non-zero on success, returns zero on failure.)
// TODO(allen): add a "shown but auto-hides on timer" setting here. // TODO(allen): add a "shown but auto-hides on timer" setting here.
API_EXPORT void API_EXPORT void
Show_Mouse_Cursor(Application_Links *app, int show)/* Show_Mouse_Cursor(Application_Links *app, Mouse_Cursor_Show_Type show)/*
DOC_PARAM(show, The show state to put the mouse cursor into, should be one of the Mouse_Cursor_Show_Type enum values.) DOC_PARAM(show, This parameter specifies the new state of the mouse cursor.)
DOC_SEE(Mouse_Cursor_Show_Type) DOC_SEE(Mouse_Cursor_Show_Type)
*/{ */{
switch (show){ switch (show){