replaced fade 'ticks' with ''seconds''

master
Allen Webster 2016-06-24 00:02:09 -04:00
parent bbba0237b1
commit 1564ade4b0
12 changed files with 112 additions and 124 deletions

View File

@ -310,6 +310,10 @@ enum Auto_Indent_Flag{
AutoIndent_UseTab = 0x2
};
enum Set_Buffer_Flag{
SetBuffer_KeepOriginalGUI = 0x1
};
enum Input_Type_Flag{
EventOnAnyKey = 0x1,
EventOnEsc = 0x2,

View File

@ -25,12 +25,12 @@
#define GET_VIEW_NEXT_SIG(n) void n(Application_Links *app, View_Summary *view, unsigned int access)
#define GET_VIEW_SIG(n) View_Summary n(Application_Links *app, int view_id, unsigned int access)
#define GET_ACTIVE_VIEW_SIG(n) View_Summary n(Application_Links *app, unsigned int access)
#define VIEW_COMPUTE_CURSOR_SIG(n) Full_Cursor n(Application_Links *app, View_Summary *view, Buffer_Seek seek)
#define VIEW_COMPUTE_CURSOR_SIG(n) int 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_MARK_SIG(n) int 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_BUFFER_SIG(n) int n(Application_Links *app, View_Summary *view, int buffer_id)
#define VIEW_POST_FADE_SIG(n) int n(Application_Links *app, View_Summary *view, int ticks, int start, int end, unsigned int color)
#define VIEW_SET_BUFFER_SIG(n) int n(Application_Links *app, View_Summary *view, int buffer_id, unsigned int 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_SET_PASTE_REWRITE__SIG(n) void n(Application_Links *app, View_Summary *view)
#define VIEW_GET_PASTE_REWRITE__SIG(n) int n(Application_Links *app, View_Summary *view)
#define GET_USER_INPUT_SIG(n) User_Input n(Application_Links *app, unsigned int get_type, unsigned int abort_type)

View File

@ -44,7 +44,7 @@ CUSTOM_COMMAND_SIG(switch_to_compilation){
view = app->get_active_view(app, access);
buffer = app->get_buffer_by_name(app, name, name_size, access);
app->view_set_buffer(app, &view, buffer.buffer_id);
app->view_set_buffer(app, &view, buffer.buffer_id, 0);
}
CUSTOM_COMMAND_SIG(rewrite_as_single_caps){

View File

@ -313,7 +313,7 @@ CUSTOM_COMMAND_SIG(paste){
Theme_Color paste;
paste.tag = Stag_Paste;
app->get_theme_colors(app, &paste, 1);
app->view_post_fade(app, &view, 20, pos, pos + len, paste.color);
app->view_post_fade(app, &view, 0.667f, pos, pos + len, paste.color);
}
}
}
@ -354,7 +354,7 @@ CUSTOM_COMMAND_SIG(paste_next){
Theme_Color paste;
paste.tag = Stag_Paste;
app->get_theme_colors(app, &paste, 1);
app->view_post_fade(app, &view, 20, pos, pos + len, paste.color);
app->view_post_fade(app, &view, 0.667f, pos, pos + len, paste.color);
}
}
else{

View File

@ -765,14 +765,14 @@ view_open_file(Application_Links *app, View_Summary *view,
int result = false;
Buffer_Summary buffer = app->get_buffer_by_name(app, filename, filename_len, AccessProtected|AccessHidden);
if (buffer.exists){
app->view_set_buffer(app, view, buffer.buffer_id);
app->view_set_buffer(app, view, buffer.buffer_id, 0);
result = true;
}
else{
buffer = app->create_buffer(app, filename, filename_len, do_in_background);
if (!do_in_background){
if (buffer.exists){
app->view_set_buffer(app, view, buffer.buffer_id);
app->view_set_buffer(app, view, buffer.buffer_id, 0);
result = true;
}
}

View File

@ -1103,11 +1103,21 @@ DOC_RETURN(returns a summary that describes the active view)
return(view);
}
VIEW_COMPUTE_CURSOR_SIG(external_view_compute_cursor){
VIEW_COMPUTE_CURSOR_SIG(external_view_compute_cursor)/*
DOC_PARAM(view, the view on which to run the cursor computation)
DOC_PARAM(seek, the seek position)
DOC_PARAM(cursor_out, on success this is filled with result of the seek)
DOC_RETURN(returns non-zero on success)
DOC
(
Computes a full cursor for the given seek position.
)
DOC_SEE(Buffer_Seek)
*/{
Command_Data *cmd = (Command_Data*)app->cmd_context;
View *vptr = imp_get_view(cmd, view);
Editing_File *file = 0;
Full_Cursor result = {0};
int result = false;
if (vptr){
file = vptr->file_data.file;
@ -1115,7 +1125,8 @@ VIEW_COMPUTE_CURSOR_SIG(external_view_compute_cursor){
if (seek.type == buffer_seek_line_char && seek.character <= 0){
seek.character = 1;
}
result = view_compute_cursor(vptr, seek);
result = true;
*cursor_out = view_compute_cursor(vptr, seek);
fill_view_summary(view, vptr, cmd);
}
}
@ -1123,7 +1134,18 @@ VIEW_COMPUTE_CURSOR_SIG(external_view_compute_cursor){
return(result);
}
VIEW_SET_CURSOR_SIG(external_view_set_cursor){
VIEW_SET_CURSOR_SIG(external_view_set_cursor)/*
DOC_PARAM(view, the view in which to set the cursor)
DOC_PARAM(seek, the seek position)
DOC_PARAM(set_preferred_x, if true the preferred x is updated to match the new cursor position)
DOC_RETURN(returns non-zero on success)
DOC
(
Sets the the view's cursor position. set_preferred_x should usually be true unless the change in
cursor position is is a vertical motion that tries to keep the cursor in the same column or x position.
)
DOC_SEE(Buffer_Seek)
*/{
Command_Data *cmd = (Command_Data*)app->cmd_context;
View *vptr = imp_get_view(cmd, view);
Editing_File *file = 0;
@ -1148,7 +1170,16 @@ VIEW_SET_CURSOR_SIG(external_view_set_cursor){
return(result);
}
VIEW_SET_MARK_SIG(external_view_set_mark){
VIEW_SET_MARK_SIG(external_view_set_mark)/*
DOC_PARAM(view, the view in which to set the mark)
DOC_PARAM(seek, the seek position)
DOC_RETURN(returns non-zero on success)
DOC
(
Sets the the view's mark position.
)
DOC_SEE(Buffer_Seek)
*/{
Command_Data *cmd = (Command_Data*)app->cmd_context;
View *vptr = imp_get_view(cmd, view);
Full_Cursor cursor = {0};
@ -1169,7 +1200,20 @@ VIEW_SET_MARK_SIG(external_view_set_mark){
return(result);
}
VIEW_SET_HIGHLIGHT_SIG(external_view_set_highlight){
VIEW_SET_HIGHLIGHT_SIG(external_view_set_highlight)/*
DOC_PARAM(view, the view to set the highlight in)
DOC_PARAM(start, the start of the highlight range)
DOC_PARAM(end, the end of the highlight range)
DOC_PARAM(turn_on, indicates whether the highlight is being turned on or off)
DOC_RETURN(returns non-zero on success)
DOC
(
The highlight is mutually exclusive to the cursor. When the turn_on parameter
is set to true the highlight will be shown and the cursor will be hidden. After
that either setting the with view_set_cursor or calling view_set_highlight and
the turn_on set to false, will switch back to showing the cursor.
)
*/{
Command_Data *cmd = (Command_Data*)app->cmd_context;
View *vptr = imp_get_view(cmd, view);
int result = false;
@ -1188,7 +1232,18 @@ VIEW_SET_HIGHLIGHT_SIG(external_view_set_highlight){
return(result);
}
VIEW_SET_BUFFER_SIG(external_view_set_buffer){
VIEW_SET_BUFFER_SIG(external_view_set_buffer)/*
DOC_PARAM(view, the view to display the buffer in)
DOC_PARAM(buffer_id, the buffer to show in the view)
DOC_PARAM(flags, set buffer behavior flags)
DOC_RETURN(returns non-zero on success)
DOC
(
On success view_set_buffer sets the specified view's current buffer and
cancels and dialogue shown in the view and displays the file.
)
DOC_SEE(Set_Buffer_Flag)
*/{
Command_Data *cmd = (Command_Data*)app->cmd_context;
View *vptr = imp_get_view(cmd, view);
Models *models = cmd->models;
@ -1202,9 +1257,11 @@ VIEW_SET_BUFFER_SIG(external_view_set_buffer){
result = true;
if (file != vptr->file_data.file){
view_set_file(vptr, file, models);
if (!(flags & SetBuffer_KeepOriginalGUI)){
view_show_file(vptr);
}
}
}
fill_view_summary(view, vptr, cmd);
}
@ -1223,7 +1280,7 @@ VIEW_POST_FADE_SIG(external_view_post_fade){
if (vptr){
if (size > 0){
result = true;
view_post_paste_effect(vptr, ticks, start, size, color);
view_post_paste_effect(vptr, seconds, start, size, color);
}
}

View File

@ -88,7 +88,7 @@ enum File_Sync_State{
struct Text_Effect{
i32 start, end;
u32 color;
i32 tick_down, tick_max;
f32 seconds_down, seconds_max;
};
// NOTE(allen): The Editing_File struct is now divided into two

View File

@ -2226,14 +2226,14 @@ view_replace_range(System_Functions *system, Models *models, View *view,
}
inline void
view_post_paste_effect(View *view, i32 ticks, i32 start, i32 size, u32 color){
view_post_paste_effect(View *view, f32 seconds, i32 start, i32 size, u32 color){
Editing_File *file = view->file_data.file;
file->state.paste_effect.start = start;
file->state.paste_effect.end = start + size;
file->state.paste_effect.color = color;
file->state.paste_effect.tick_down = ticks;
file->state.paste_effect.tick_max = ticks;
file->state.paste_effect.seconds_down = seconds;
file->state.paste_effect.seconds_max = seconds;
}
internal Style*
@ -2270,7 +2270,7 @@ view_undo_redo(System_Functions *system,
view->recent->mark = view->recent->cursor.pos;
Style *style = main_style(models);
view_post_paste_effect(view, 10, step.edit.start, step.edit.len,
view_post_paste_effect(view, 0.333f, step.edit.start, step.edit.len,
style->main.undo_color);
}
else{
@ -2988,7 +2988,8 @@ file_auto_tab_tokens(System_Functions *system, Models *models,
Edit_Spec spec =
file_compute_whitespace_edit(mem, file, pos,
batch.edits, batch.str_base, batch.str_size,
inverse_array, inv_str, part->max - part->pos, batch.edit_count);
inverse_array, inv_str, part->max - part->pos,
batch.edit_count);
file_do_white_batch_edit(system, models, file, spec, hist_normal);
}
@ -2996,31 +2997,6 @@ file_auto_tab_tokens(System_Functions *system, Models *models,
#endif
}
internal void
view_auto_tab_tokens(System_Functions *system, Models *models,
View *view, i32 start, i32 end, Indent_Options opts){
#if BUFFER_EXPERIMENT_SCALPEL <= 0
Editing_File *file = view->file_data.file;
i32 pos = view->recent->cursor.pos;
file_auto_tab_tokens(system, models, file, pos, start, end, opts);
// TODO(allen): This is the bug dummy
{
Buffer_Type *buffer = &file->state.buffer;
i32 line = buffer_get_line_index(buffer, pos);
i32 start = buffer->line_starts[line];
Hard_Start_Result hard_start = buffer_find_hard_start(buffer, start, 4);
if (hard_start.char_pos > pos){
view_cursor_move(view, hard_start.char_pos);
}
}
#endif
}
struct Get_Link_Result{
b32 in_link;
i32 index;
@ -3645,8 +3621,8 @@ file_step(View *view, i32_Rect region, Input_Summary *user_input, b32 is_active,
i32 is_animating = 0;
Editing_File *file = view->file_data.file;
if (file && !file->is_loading){
if (file->state.paste_effect.tick_down > 0){
--file->state.paste_effect.tick_down;
if (file->state.paste_effect.seconds_down > 0.f){
file->state.paste_effect.seconds_down -= user_input->dt;
is_animating = 1;
}
}
@ -5475,11 +5451,12 @@ draw_file_loaded(View *view, i32_Rect rect, b32 is_active, Render_Target *target
u32 fade_color = 0xFFFF00FF;
f32 fade_amount = 0.f;
if (file->state.paste_effect.tick_down > 0 &&
if (file->state.paste_effect.seconds_down > 0.f &&
file->state.paste_effect.start <= ind &&
ind < file->state.paste_effect.end){
fade_color = file->state.paste_effect.color;
fade_amount = (f32)(file->state.paste_effect.tick_down) / file->state.paste_effect.tick_max;
fade_amount = file->state.paste_effect.seconds_down;
fade_amount /= file->state.paste_effect.seconds_max;
}
char_color = color_blend(char_color, fade_amount, fade_color);

View File

@ -23,7 +23,7 @@ popd
pushd ..\build
REM call "..\code\buildsuper.bat" ..\code\4coder_default_bindings.cpp
call "..\code\buildsuper.bat" ..\code\power\4coder_experiments.cpp
REM call "..\code\buildsuper.bat" ..\code\power\4coder_experiments.cpp
REM call "..\code\buildsuper.bat" ..\code\power\4coder_casey.cpp
REM call "..\code\buildsuper.bat" ..\4vim\4coder_chronal.cpp
if %ERRORLEVEL% neq 0 (set FirstError=1)

View File

@ -43,13 +43,12 @@ void Get_View_Next(Application_Links *app, View_Summary *view, unsigned int acce
View_Summary Get_View(Application_Links *app, int view_id, unsigned int access);
View_Summary Get_Active_View(Application_Links *app, unsigned int access);
Full_Cursor View_Compute_Cursor (Application_Links *app, View_Summary *view, Buffer_Seek seek);
int View_Compute_Cursor (Application_Links *app, View_Summary *view, Buffer_Seek seek, Full_Cursor *cursor_out);
int View_Set_Cursor (Application_Links *app, View_Summary *view, Buffer_Seek seek, int set_preferred_x);
int View_Set_Mark (Application_Links *app, View_Summary *view, Buffer_Seek seek);
int View_Set_Highlight (Application_Links *app, View_Summary *view, int start, int end, int turn_on);
int View_Set_Buffer (Application_Links *app, View_Summary *view, int buffer_id);
// TODO(allen): Switch from ticks to seconds.
int View_Post_Fade (Application_Links *app, View_Summary *view, int ticks, int start, int end, unsigned int color);
int View_Set_Buffer (Application_Links *app, View_Summary *view, int buffer_id, unsigned int flags);
int View_Post_Fade (Application_Links *app, View_Summary *view, float seconds, int start, int end, unsigned int color);
// TODO(allen):
// Get rid of this temporary hack ass soon ass possible.

View File

@ -508,20 +508,13 @@ SwitchToOrLoadFile(struct Application_Links *app, String FileName, bool CreateIf
if(buffer.exists)
{
app->view_set_buffer(app, &view, buffer.buffer_id);
app->view_set_buffer(app, &view, buffer.buffer_id, 0);
Result.Switched = true;
}
else
{
if(app->file_exists(app, FileName.str, FileName.size) || CreateIfNotFound)
{
#if 0
push_parameter(app, par_name, expand_str(FileName));
// TODO(casey): Do I have to check for existence, or can I pass a parameter
// to interactive open to tell it to fail if the file isn't there?
exec_command(app, cmdid_interactive_open);
#endif
// NOTE(allen): This opens the file and puts it in &view
// This returns false if the open fails.
view_open_file(app, &view, expand_str(FileName), false);
@ -640,7 +633,7 @@ CUSTOM_COMMAND_SIG(casey_find_corresponding_file_other_window)
exec_command(app, cmdid_change_active_panel);
View_Summary new_view = app->get_active_view(app, AccessAll);
app->view_set_buffer(app, &new_view, buffer.buffer_id);
app->view_set_buffer(app, &new_view, buffer.buffer_id, 0);
// exec_command(app, casey_find_corresponding_file);
}
@ -656,44 +649,9 @@ CUSTOM_COMMAND_SIG(casey_save_and_make_without_asking)
buffer.exists;
app->get_buffer_next(app, &buffer, access))
{
#if 0
push_parameter(app, par_name, buffer.file_name, buffer.file_name_len);
push_parameter(app, par_buffer_id, buffer.buffer_id);
exec_command(app, cmdid_save);
#endif
app->save_buffer(app, &buffer, buffer.file_name, buffer.file_name_len);
app->save_buffer(app, &buffer, buffer.file_name, buffer.file_name_len, 0);
}
#if 0
String dir = make_string(app->memory, 0, app->memory_size);
append(&dir, BuildDirectory);
for(int At = 0;
At < dir.size;
++At)
{
if(dir.str[At] == '/')
{
dir.str[At] = '\\';
}
}
push_parameter(app, par_flags, CLI_OverlapWithConflict);
push_parameter(app, par_name, GlobalCompilationBufferName, (int)strlen(GlobalCompilationBufferName));
push_parameter(app, par_cli_path, dir.str, dir.size);
if(append(&dir, "build.bat"))
{
push_parameter(app, par_cli_command, dir.str, dir.size);
exec_command(app, cmdid_command_line);
exec_command(app, cmdid_change_active_panel);
}
else{
app->clear_parameters(app);
}
#endif
// NOTE(allen): The parameter pushing made it a little easier
// to deal with this particular pattern where two similar strings
// were both used. Now both strings need to exist at the same
@ -1154,11 +1112,6 @@ OpenProject(Application_Links *app, char *ProjectFileName)
// was originally, so that new appends overwrite old ones.
dir.size = dir_size;
append(&dir, info->filename);
#if 0
push_parameter(app, par_name, dir.str, dir.size);
push_parameter(app, par_do_in_background, 1);
exec_command(app, cmdid_interactive_open);
#endif
view_open_file(app, 0, dir.str, dir.size, true);
++TotalOpenAttempts;
@ -1351,14 +1304,6 @@ OPEN_FILE_HOOK_SIG(casey_file_settings)
treat_as_project = match(ext, make_lit_string("prj"));
}
#if 0
push_parameter(app, par_buffer_id, buffer.buffer_id);
push_parameter(app, par_lex_as_cpp_file, treat_as_code);
push_parameter(app, par_wrap_lines, !treat_as_code);
push_parameter(app, par_key_mapid, mapid_file);
exec_command(app, cmdid_set_settings);
#endif
app->buffer_set_setting(app, &buffer, BufferSetting_Lex, treat_as_code);
app->buffer_set_setting(app, &buffer, BufferSetting_WrapLine, !treat_as_code);
app->buffer_set_setting(app, &buffer, BufferSetting_MapID, mapid_file);

View File

@ -10,7 +10,6 @@ CUSTOM_COMMAND_SIG(kill_rect){
unsigned int access = AccessOpen;
View_Summary view = app->get_active_view(app, access);
Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access);
Full_Cursor cursor;
Buffer_Rect rect = get_rect(&view);
@ -18,15 +17,22 @@ CUSTOM_COMMAND_SIG(kill_rect){
int start = 0;
int end = 0;
cursor = app->view_compute_cursor(app, &view, seek_line_char(line, rect.char0));
int success = true;
Full_Cursor cursor = {0};
success = success &&
app->view_compute_cursor(app, &view, seek_line_char(line, rect.char0), &cursor);
start = cursor.pos;
cursor = app->view_compute_cursor(app, &view, seek_line_char(line, rect.char1));
success = success &&
app->view_compute_cursor(app, &view, seek_line_char(line, rect.char1), &cursor);
end = cursor.pos;
if (success){
app->buffer_replace_range(app, &buffer, start, end, 0, 0);
}
}
}
// TODO(allen): Both of these brace related commands would work better
// if the API exposed access to the tokens in a code file.