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_whitespace_up,
cmdid_seek_whitespace_down,
cmdid_center_view,
cmdid_word_complete,
cmdid_set_mark,
cmdid_copy,

View File

@ -312,7 +312,7 @@ isearch(Application_Links *app, int start_reversed){
if (step_backward){
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;
}
match.start = new_pos;
@ -325,7 +325,7 @@ isearch(Application_Links *app, int start_reversed){
if (step_forward){
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;
}
match.start = new_pos;

View File

@ -1,4 +1,6 @@
// TOP
#include "4coder_default.cpp"
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, ' ', MDFR_SHIFT, cmdid_write_character);
bind(context, 'q', MDFR_ALT | MDFR_CTRL, write_capital);
bind(context, 'w', MDFR_ALT | MDFR_CTRL, write_capital);
bind(context, 'e', MDFR_ALT | MDFR_CTRL, write_capital);
bind(context, 'e', MDFR_CTRL, cmdid_center_view);
bind(context, 'T', MDFR_CTRL | MDFR_ALT, begin_html_mode);
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
seek_token_left(Cpp_Token_Stack *tokens, i32 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);
}
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){
ProfileMomentFunction();
REQ_READABLE_VIEW(view);
@ -425,90 +407,24 @@ COMMAND_DECL(seek_whitespace_down){
view_cursor_move(view, pos);
}
COMMAND_DECL(seek_token_left){
COMMAND_DECL(center_view){
ProfileMomentFunction();
REQ_READABLE_VIEW(view);
USE_VIEW(view);
REQ_FILE(file, view);
if (file->state.tokens_complete){
i32 pos = seek_token_left(&file->state.token_stack, view->cursor.pos);
view_cursor_move(view, pos);
}
}
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);
f32 y, h;
if (view->unwrapped_lines){
y = view->cursor.unwrapped_y;
}
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){
ProfileMomentFunction();
REQ_READABLE_VIEW(view);
REQ_FILE(file, view);
h = view_compute_height(view);
y -= h * .5f;
if (y < view->scroll_min_limit) y = view->scroll_min_limit;
i32 token_pos, white_pos;
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);
view->target_y = y;
}
COMMAND_DECL(word_complete){
@ -2725,6 +2641,7 @@ setup_command_table(){
SET(seek_right);
SET(seek_whitespace_up);
SET(seek_whitespace_down);
SET(center_view);
SET(word_complete);
SET(set_mark);
SET(copy);
@ -3014,6 +2931,7 @@ enum Command_Line_Action{
CLAct_WindowSize,
CLAct_WindowMaximize,
CLAct_WindowPosition,
CLAct_FontSize,
CLAct_Count
};
@ -3024,7 +2942,7 @@ init_command_line_settings(App_Settings *settings, Plat_Settings *plat_settings,
Command_Line_Action action = CLAct_Nothing;
i32 i,index;
b32 strict = 0;
settings->init_files_max = ArrayCount(settings->init_files);
for (i = 1; i <= clparams.argc; ++i){
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_WindowMaximize; break;
case 'p': action = CLAct_WindowPosition; break;
case 'f': action = CLAct_FontSize; break;
}
}
else if (arg[0] != 0){
@ -3112,6 +3032,14 @@ init_command_line_settings(App_Settings *settings, Plat_Settings *plat_settings,
}
action = CLAct_Nothing;
}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_Vars *vars;
App_Settings *settings;
i32 out_size = 0;
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);
}
else{
vars->models.settings = {};
settings = &vars->models.settings;
*settings = {};
settings->font_size = 16;
}
*files = vars->models.settings.init_files;
*file_count = &vars->models.settings.init_files_count;
@ -3398,7 +3329,7 @@ App_Init_Sig(app_init){
i32 pt_size;
};
int font_size = 16;
int font_size = models->settings.font_size;
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"
"-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"
"-<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"
);

View File

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

View File

@ -2488,17 +2488,17 @@ style_get_color(Style *style, Cpp_Token token){
}
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;
return max_target_y;
}
internal real32
internal f32
view_compute_max_target_y(View *view){
i32 lowest_line = view_compute_lowest_line(view);
i32 line_height = view->font_height;
real32 view_height = view_compute_height(view);
real32 max_target_y = view_compute_max_target_y(
f32 view_height = view_compute_height(view);
f32 max_target_y = view_compute_max_target_y(
lowest_line, line_height, view_height);
return max_target_y;
}

View File

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