a4.0.2 features ready (still testing)

This commit is contained in:
Allen Webster 2016-03-21 18:27:27 -04:00
parent 8ca38b5f73
commit d9cc45158d
7 changed files with 46 additions and 109 deletions

View File

@ -166,6 +166,7 @@ enum Command_ID{
cmdid_seek_right, cmdid_seek_right,
cmdid_seek_whitespace_up, cmdid_seek_whitespace_up,
cmdid_seek_whitespace_down, cmdid_seek_whitespace_down,
cmdid_center_view,
cmdid_word_complete, cmdid_word_complete,
cmdid_set_mark, cmdid_set_mark,
cmdid_copy, cmdid_copy,

View File

@ -312,7 +312,7 @@ isearch(Application_Links *app, int start_reversed){
if (step_backward){ if (step_backward){
pos = new_pos; pos = new_pos;
start_pos = new_pos; start_pos = new_pos;
app->buffer_seek_string(app, &buffer, start_pos - 1, bar.string.str, bar.string.size, 0, &new_pos); app->buffer_seek_string_insensitive(app, &buffer, start_pos - 1, bar.string.str, bar.string.size, 0, &new_pos);
if (new_pos < 0) new_pos = start_pos; if (new_pos < 0) new_pos = start_pos;
} }
match.start = new_pos; match.start = new_pos;
@ -325,7 +325,7 @@ isearch(Application_Links *app, int start_reversed){
if (step_forward){ if (step_forward){
pos = new_pos; pos = new_pos;
start_pos = new_pos; start_pos = new_pos;
app->buffer_seek_string(app, &buffer, start_pos + 1, bar.string.str, bar.string.size, 1, &new_pos); app->buffer_seek_string_insensitive(app, &buffer, start_pos + 1, bar.string.str, bar.string.size, 1, &new_pos);
if (new_pos >= buffer.size) new_pos = start_pos; if (new_pos >= buffer.size) new_pos = start_pos;
} }
match.start = new_pos; match.start = new_pos;

View File

@ -1,4 +1,6 @@
// TOP
#include "4coder_default.cpp" #include "4coder_default.cpp"
unsigned char blink_t = 0; unsigned char blink_t = 0;
@ -442,11 +444,11 @@ void default_get_bindings(Bind_Helper *context){
bind(context, '\n', MDFR_SHIFT, write_and_auto_tab); bind(context, '\n', MDFR_SHIFT, write_and_auto_tab);
bind(context, ' ', MDFR_SHIFT, cmdid_write_character); bind(context, ' ', MDFR_SHIFT, cmdid_write_character);
bind(context, 'q', MDFR_ALT | MDFR_CTRL, write_capital); bind(context, 'e', MDFR_CTRL, cmdid_center_view);
bind(context, 'w', MDFR_ALT | MDFR_CTRL, write_capital);
bind(context, 'e', MDFR_ALT | MDFR_CTRL, write_capital);
bind(context, 'T', MDFR_CTRL | MDFR_ALT, begin_html_mode); bind(context, 'T', MDFR_CTRL | MDFR_ALT, begin_html_mode);
end_map(context); end_map(context);
} }
// BOTTOM

126
4ed.cpp
View File

@ -252,15 +252,6 @@ COMMAND_DECL(write_character){
} }
} }
COMMAND_DECL(seek_whitespace_right){
ProfileMomentFunction();
REQ_READABLE_VIEW(view);
REQ_FILE(file, view);
i32 pos = buffer_seek_whitespace_right(&file->state.buffer, view->cursor.pos);
view_cursor_move(view, pos);
}
internal i32 internal i32
seek_token_left(Cpp_Token_Stack *tokens, i32 pos){ seek_token_left(Cpp_Token_Stack *tokens, i32 pos){
Cpp_Get_Token_Result get = cpp_get_token(tokens, pos); Cpp_Get_Token_Result get = cpp_get_token(tokens, pos);
@ -398,15 +389,6 @@ COMMAND_DECL(seek_right){
view_cursor_move(view, new_pos); view_cursor_move(view, new_pos);
} }
COMMAND_DECL(seek_whitespace_left){
ProfileMomentFunction();
REQ_READABLE_VIEW(view);
REQ_FILE(file, view);
i32 pos = buffer_seek_whitespace_left(&file->state.buffer, view->cursor.pos);
view_cursor_move(view, pos);
}
COMMAND_DECL(seek_whitespace_up){ COMMAND_DECL(seek_whitespace_up){
ProfileMomentFunction(); ProfileMomentFunction();
REQ_READABLE_VIEW(view); REQ_READABLE_VIEW(view);
@ -425,90 +407,24 @@ COMMAND_DECL(seek_whitespace_down){
view_cursor_move(view, pos); view_cursor_move(view, pos);
} }
COMMAND_DECL(seek_token_left){ COMMAND_DECL(center_view){
ProfileMomentFunction(); ProfileMomentFunction();
REQ_READABLE_VIEW(view); USE_VIEW(view);
REQ_FILE(file, view); REQ_FILE(file, view);
if (file->state.tokens_complete){ f32 y, h;
i32 pos = seek_token_left(&file->state.token_stack, view->cursor.pos); if (view->unwrapped_lines){
view_cursor_move(view, pos); y = view->cursor.unwrapped_y;
}
}
COMMAND_DECL(seek_token_right){
ProfileMomentFunction();
REQ_READABLE_VIEW(view);
REQ_FILE(file, view);
if (file->state.tokens_complete){
i32 pos = seek_token_right(&file->state.token_stack, view->cursor.pos);
view_cursor_move(view, pos);
}
}
COMMAND_DECL(seek_white_or_token_right){
ProfileMomentFunction();
REQ_READABLE_VIEW(view);
REQ_FILE(file, view);
i32 token_pos, white_pos;
if (file->state.tokens_complete){
token_pos = seek_token_right(&file->state.token_stack, view->cursor.pos);
} }
else{ else{
token_pos = buffer_size(&file->state.buffer); y = view->cursor.wrapped_y;
} }
white_pos = buffer_seek_whitespace_right(&file->state.buffer, view->cursor.pos);
view_cursor_move(view, Min(token_pos, white_pos));
}
COMMAND_DECL(seek_white_or_token_left){ h = view_compute_height(view);
ProfileMomentFunction(); y -= h * .5f;
REQ_READABLE_VIEW(view); if (y < view->scroll_min_limit) y = view->scroll_min_limit;
REQ_FILE(file, view);
i32 token_pos, white_pos; view->target_y = y;
if (file->state.tokens_complete){
token_pos = seek_token_left(&file->state.token_stack, view->cursor.pos);
}
else{
token_pos = 0;
}
white_pos = buffer_seek_whitespace_left(&file->state.buffer, view->cursor.pos);
view_cursor_move(view, Max(token_pos, white_pos));
}
COMMAND_DECL(seek_alphanumeric_right){
ProfileMomentFunction();
REQ_READABLE_VIEW(view);
REQ_FILE(file, view);
i32 pos = buffer_seek_alphanumeric_right(&file->state.buffer, view->cursor.pos);
view_cursor_move(view, pos);
}
COMMAND_DECL(seek_alphanumeric_left){
ProfileMomentFunction();
REQ_READABLE_VIEW(view);
REQ_FILE(file, view);
i32 pos = buffer_seek_alphanumeric_left(&file->state.buffer, view->cursor.pos);
view_cursor_move(view, pos);
}
COMMAND_DECL(seek_alphanumeric_or_camel_right){
ProfileMomentFunction();
REQ_READABLE_VIEW(view);
REQ_FILE(file, view);
i32 pos = buffer_seek_alphanumeric_or_camel_right(&file->state.buffer, view->cursor.pos);
view_cursor_move(view, pos);
}
COMMAND_DECL(seek_alphanumeric_or_camel_left){
ProfileMomentFunction();
REQ_READABLE_VIEW(view);
REQ_FILE(file, view);
i32 pos = buffer_seek_alphanumeric_or_camel_left(&file->state.buffer, view->cursor.pos);
view_cursor_move(view, pos);
} }
COMMAND_DECL(word_complete){ COMMAND_DECL(word_complete){
@ -2725,6 +2641,7 @@ setup_command_table(){
SET(seek_right); SET(seek_right);
SET(seek_whitespace_up); SET(seek_whitespace_up);
SET(seek_whitespace_down); SET(seek_whitespace_down);
SET(center_view);
SET(word_complete); SET(word_complete);
SET(set_mark); SET(set_mark);
SET(copy); SET(copy);
@ -3014,6 +2931,7 @@ enum Command_Line_Action{
CLAct_WindowSize, CLAct_WindowSize,
CLAct_WindowMaximize, CLAct_WindowMaximize,
CLAct_WindowPosition, CLAct_WindowPosition,
CLAct_FontSize,
CLAct_Count CLAct_Count
}; };
@ -3024,7 +2942,7 @@ init_command_line_settings(App_Settings *settings, Plat_Settings *plat_settings,
Command_Line_Action action = CLAct_Nothing; Command_Line_Action action = CLAct_Nothing;
i32 i,index; i32 i,index;
b32 strict = 0; b32 strict = 0;
settings->init_files_max = ArrayCount(settings->init_files); settings->init_files_max = ArrayCount(settings->init_files);
for (i = 1; i <= clparams.argc; ++i){ for (i = 1; i <= clparams.argc; ++i){
if (i == clparams.argc) arg = ""; if (i == clparams.argc) arg = "";
@ -3046,6 +2964,8 @@ init_command_line_settings(App_Settings *settings, Plat_Settings *plat_settings,
case 'w': action = CLAct_WindowSize; break; case 'w': action = CLAct_WindowSize; break;
case 'W': action = CLAct_WindowMaximize; break; case 'W': action = CLAct_WindowMaximize; break;
case 'p': action = CLAct_WindowPosition; break; case 'p': action = CLAct_WindowPosition; break;
case 'f': action = CLAct_FontSize; break;
} }
} }
else if (arg[0] != 0){ else if (arg[0] != 0){
@ -3112,6 +3032,14 @@ init_command_line_settings(App_Settings *settings, Plat_Settings *plat_settings,
} }
action = CLAct_Nothing; action = CLAct_Nothing;
}break; }break;
case CLAct_FontSize:
{
if (i < clparams.argc){
settings->font_size = str_to_int(clparams.argv[i]);
}
action = CLAct_Nothing;
}break;
} }
} }
} }
@ -3147,6 +3075,7 @@ execute_special_tool(void *memory, i32 size, Command_Line_Parameters clparams){
App_Read_Command_Line_Sig(app_read_command_line){ App_Read_Command_Line_Sig(app_read_command_line){
App_Vars *vars; App_Vars *vars;
App_Settings *settings;
i32 out_size = 0; i32 out_size = 0;
if (clparams.argc > 1 && match(clparams.argv[1], "-T")){ if (clparams.argc > 1 && match(clparams.argv[1], "-T")){
@ -3158,7 +3087,9 @@ App_Read_Command_Line_Sig(app_read_command_line){
init_command_line_settings(&vars->models.settings, plat_settings, clparams); init_command_line_settings(&vars->models.settings, plat_settings, clparams);
} }
else{ else{
vars->models.settings = {}; settings = &vars->models.settings;
*settings = {};
settings->font_size = 16;
} }
*files = vars->models.settings.init_files; *files = vars->models.settings.init_files;
*file_count = &vars->models.settings.init_files_count; *file_count = &vars->models.settings.init_files_count;
@ -3398,7 +3329,7 @@ App_Init_Sig(app_init){
i32 pt_size; i32 pt_size;
}; };
int font_size = 16; int font_size = models->settings.font_size;
if (font_size < 8) font_size = 8; if (font_size < 8) font_size = 8;
@ -3795,6 +3726,7 @@ App_Step_Sig(app_step){
"-File equality is handled better so renamings (such as 'subst') are safe now\n" "-File equality is handled better so renamings (such as 'subst') are safe now\n"
"-This buffer will report events including errors that happen in 4coder\n" "-This buffer will report events including errors that happen in 4coder\n"
"-Super users can post their own messages here with app->print_message\n" "-Super users can post their own messages here with app->print_message\n"
"-<ctrl e> centers view on cursor; cmdid_center_view in customization API\n"
"-Set font size on command line with -f N, N = 16 by default\n\n" "-Set font size on command line with -f N, N = 16 by default\n\n"
); );

View File

@ -19,6 +19,8 @@ struct App_Settings{
i32 initial_line; i32 initial_line;
b32 lctrl_lalt_is_altgr; b32 lctrl_lalt_is_altgr;
i32 font_size;
}; };
struct Models{ struct Models{

View File

@ -2488,17 +2488,17 @@ style_get_color(Style *style, Cpp_Token token){
} }
inline f32 inline f32
view_compute_max_target_y(i32 lowest_line, i32 line_height, real32 view_height){ view_compute_max_target_y(i32 lowest_line, i32 line_height, f32 view_height){
real32 max_target_y = ((lowest_line+.5f)*line_height) - view_height*.5f; real32 max_target_y = ((lowest_line+.5f)*line_height) - view_height*.5f;
return max_target_y; return max_target_y;
} }
internal real32 internal f32
view_compute_max_target_y(View *view){ view_compute_max_target_y(View *view){
i32 lowest_line = view_compute_lowest_line(view); i32 lowest_line = view_compute_lowest_line(view);
i32 line_height = view->font_height; i32 line_height = view->font_height;
real32 view_height = view_compute_height(view); f32 view_height = view_compute_height(view);
real32 max_target_y = view_compute_max_target_y( f32 max_target_y = view_compute_max_target_y(
lowest_line, line_height, view_height); lowest_line, line_height, view_height);
return max_target_y; return max_target_y;
} }

View File

@ -99,10 +99,10 @@
; [X] tab option for auto-indent ; [X] tab option for auto-indent
; [X] catch unsaved files on close ; [X] catch unsaved files on close
; [X] feedback messages ; [X] feedback messages
; [X] feedback message API
; ;
; [] file status in custom API ; [] file status in custom API
; [] user file bar string ; [] user file bar string
; [] feedback message API
; [] simple multi-line ; [] simple multi-line
; ;
; [] command meta data ; [] command meta data
@ -162,7 +162,7 @@
; [] error text at line ; [] error text at line
; [] word complete ghosting ; [] word complete ghosting
; ;
; [] the main_4coder experiment ; [] the "main_4coder" experiment
; ;
; [] tutorials ; [] tutorials
; ;
@ -180,9 +180,9 @@
; EASY TODOS ; EASY TODOS
; [X] better messages for example not "BEHIND OS" ; [X] better messages for example not "BEHIND OS"
; [X] shift backspace ; [X] shift backspace
; [X] center view on cursor
; [] close editor command ; [] close editor command
; [] panel grow/shrink commands ; [] panel grow/shrink commands
; [] center view on cursor
; [] delta time in scroll interpolation ; [] delta time in scroll interpolation
; ;