Query bar fixup for new view coroutine structure; also new view coroutine structure

master
Allen Webster 2019-10-13 13:17:22 -07:00
parent 1b6091b871
commit 6770107d2b
20 changed files with 462 additions and 402 deletions

148
4ed.cpp
View File

@ -9,59 +9,6 @@
// TOP
internal App_Coroutine_State
get_state(Application_Links *app){
App_Coroutine_State state = {};
state.co = app->current_coroutine;
state.type = app->type_coroutine;
return(state);
}
internal void
restore_state(Application_Links *app, App_Coroutine_State state){
app->current_coroutine = state.co;
app->type_coroutine = state.type;
}
internal Coroutine*
app_coroutine_handle_request(Models *models, Coroutine *co, App_Coroutine_Out *out){
Coroutine *result = 0;
switch (out->request){
case AppCoroutineRequest_NewFontFace:
{
Face_Description *description = out->face_description;
Face *face = font_set_new_face(&models->font_set, description);
App_Coroutine_In in = {};
in.face_id = face->id;
result = coroutine_run(&models->coroutines, co, &in, out);
}break;
case AppCoroutineRequest_ModifyFace:
{
Face_Description *description = out->face_description;
Face_ID face_id = out->face_id;
App_Coroutine_In in = {};
in.success = font_set_modify_face(&models->font_set, face_id, description);
result = coroutine_run(&models->coroutines, co, &in, out);
}break;
}
return(result);
}
internal Coroutine*
app_coroutine_run(Models *models, App_Coroutine_Purpose purpose, Coroutine *co, App_Coroutine_In *in, App_Coroutine_Out *out){
Application_Links *app = &models->app_links;
App_Coroutine_State prev_state = get_state(app);
app->current_coroutine = co;
app->type_coroutine = purpose;
Coroutine *result = coroutine_run(&models->coroutines, co, in, out);
for (;result != 0 && out->request != AppCoroutineRequest_None;){
result = app_coroutine_handle_request(models, result, out);
}
restore_state(app, prev_state);
return(result);
}
internal void
output_file_append(Models *models, Editing_File *file, String_Const_u8 value){
i64 end = buffer_size(&file->state.buffer);
@ -114,14 +61,6 @@ DELTA_RULE_SIG(fallback_scroll_rule){
#include "4ed_api_implementation.cpp"
internal void
command_caller(Coroutine *coroutine){
App_Coroutine_In *in = (App_Coroutine_In*)coroutine->in;
Models *models = in->models;
Assert(models->command_caller != 0);
models->command_caller(&models->app_links);
}
// App Functions
internal void
@ -349,48 +288,6 @@ models_init(Thread_Context *tctx){
return(models);
}
internal void
force_abort_coroutine(Models *models, View *view){
App_Coroutine_In in = {};
in.user_input.abort = true;
for (u32 j = 0; j < 100 && models->command_coroutine != 0; ++j){
models->command_coroutine = app_coroutine_run(models, Co_Command, models->command_coroutine, &in, &models->coroutine_out);
}
if (models->command_coroutine != 0){
#define M "SERIOUS ERROR: command did not terminate when passed an abort"
print_message(&models->app_links, string_u8_litexpr(M));
#undef M
models->command_coroutine = 0;
}
init_query_set(&view->query_set);
}
internal b32
launch_command_via_event(Models *models, View *view, Input_Event *event){
block_copy_struct(&models->event, event);
Assert(models->command_coroutine == 0);
Coroutine *command_coroutine = coroutine_create(&models->coroutines, command_caller);
models->command_coroutine = command_coroutine;
App_Coroutine_In in = {};
in.models = models;
models->event_unhandled = false;
models->command_coroutine = app_coroutine_run(models,
Co_Command, models->command_coroutine,
&in, &models->coroutine_out);
if (match_core_code(event, CoreCode_Animate)){
models->animate_next_frame = true;
}
return(!models->event_unhandled);
}
internal void
launch_command_via_core_event(Models *models, View *view, Core_Code code){
Input_Event event = {};
event.kind = InputEventKind_Core;
event.core.code = code;
launch_command_via_event(models, view, &event);
}
internal void
app_load_vtables(API_VTable_system *vtable_system,
API_VTable_font *vtable_font,
@ -534,7 +431,7 @@ App_Init_Sig(app_init){
{
Panel *panel = layout_initialize(arena, &models->layout);
View *new_view = live_set_alloc_view(&models->lifetime_allocator, &models->live_set, panel);
view_set_file(models, new_view, models->scratch_buffer);
view_init(models, new_view, models->scratch_buffer, models->view_event_handler);
}
// NOTE(allen): miscellaneous init
@ -780,18 +677,8 @@ App_Step_Sig(app_step){
case EventConsume_ClickChangeView:
{
// NOTE(allen): kill coroutine if we have one
if (models->command_coroutine != 0){
force_abort_coroutine(models, view);
}
// NOTE(allen): run deactivate command
launch_command_via_core_event(models, view, CoreCode_ClickDeactivateView);
// NOTE(allen): kill coroutine if we have one (again because we just launched a command)
if (models->command_coroutine != 0){
force_abort_coroutine(models, view);
}
co_send_core_event(models, view, CoreCode_ClickDeactivateView);
layout->active_panel = mouse_panel;
models->animate_next_frame = true;
@ -799,41 +686,14 @@ App_Step_Sig(app_step){
view = active_panel->view;
// NOTE(allen): run activate command
launch_command_via_core_event(models, view, CoreCode_ClickActivateView);
co_send_core_event(models, view, CoreCode_ClickActivateView);
event_was_handled = true;
}break;
case EventConsume_CustomCommand:
{
// NOTE(allen): update command coroutine
if (models->command_coroutine != 0){
block_copy_struct(&models->event, event);
Coroutine *command_coroutine = models->command_coroutine;
App_Coroutine_Out *co_out = &models->coroutine_out;
Event_Property abort_flags = co_out->abort_flags;
Event_Property get_flags = co_out->get_flags|abort_flags;
Event_Property event_flags = get_event_properties(event);
if ((get_flags&event_flags) != 0){
App_Coroutine_In in = {};
in.user_input.event = *event;
in.user_input.abort = ((abort_flags & event_flags) != 0);
models->event_unhandled = false;
models->command_coroutine = app_coroutine_run(models, Co_Command, command_coroutine, &in, &models->coroutine_out);
if (!HasFlag(event_flags, EventProperty_Animate)){
models->animate_next_frame = true;
}
if (models->command_coroutine == 0){
init_query_set(&view->query_set);
}
event_was_handled = !models->event_unhandled;
}
}
else{
event_was_handled = launch_command_via_event(models, view, event);
}
event_was_handled = co_send_event(models, view, event);
}break;
}
}break;

View File

@ -1192,7 +1192,7 @@ panel_split(Application_Links *app, Panel_ID panel_id, Panel_Split_Orientation o
if (layout_split_panel(layout, panel, (orientation == PanelSplit_LeftAndRight), &new_panel)){
Live_Views *live_set = &models->live_set;
View *new_view = live_set_alloc_view(&models->lifetime_allocator, live_set, new_panel);
view_set_file(models, new_view, models->scratch_buffer);
view_init(models, new_view, models->scratch_buffer, models->view_event_handler);
result = true;
}
}
@ -1328,10 +1328,7 @@ view_close(Application_Links *app, View_ID view_id)
View *view = imp_get_view(models, view_id);
b32 result = false;
if (api_check_view(view)){
if (layout_close_panel(layout, view->panel)){
live_set_free_view(&models->lifetime_allocator, &models->live_set, view);
result = true;
}
result = view_close(models, view);
}
return(result);
}
@ -2085,15 +2082,15 @@ get_user_input(Application_Links *app, Event_Property get_properties, Event_Prop
{
Models *models = (Models*)app->cmd_context;
User_Input result = {};
if (app->type_coroutine == Co_Command){
if (app->type_coroutine == Co_View){
Coroutine *coroutine = (Coroutine*)app->current_coroutine;
Assert(coroutine != 0);
App_Coroutine_Out *out = (App_Coroutine_Out*)coroutine->out;
out->request = AppCoroutineRequest_None;
Co_Out *out = (Co_Out*)coroutine->out;
out->request = CoRequest_None;
out->get_flags = get_properties;
out->abort_flags = abort_properties;
coroutine_yield(coroutine);
App_Coroutine_In *in = (App_Coroutine_In*)coroutine->in;
Co_In *in = (Co_In*)coroutine->in;
result = in->user_input;
}
return(result);
@ -2165,9 +2162,9 @@ set_custom_hook(Application_Links *app, Hook_ID hook_id, Void_Func *func_ptr){
{
models->hook_file_externally_modified = (File_Externally_Modified_Function*)func_ptr;
}break;
case HookID_CommandCaller:
case HookID_ViewEventHandler:
{
models->command_caller = (Command_Caller_Hook_Function*)func_ptr;
models->view_event_handler = (Custom_Command_Function*)func_ptr;
}break;
case HookID_RenderCaller:
{
@ -2213,7 +2210,7 @@ get_active_query_bars(Application_Links *app, View_ID view_id, i32 max_result_co
Models *models = (Models*)app->cmd_context;
View *view = imp_get_view(models, view_id);
b32 result = false;
if (view != 0){
if (api_check_view(view)){
i32 count = 0;
Query_Bar **ptrs = array_out->ptrs;
for (Query_Slot *slot = view->query_set.used_slot;
@ -2252,6 +2249,15 @@ end_query_bar(Application_Links *app, Query_Bar *bar, u32 flags)
free_query_slot(&active_view->query_set, bar);
}
api(custom) function void
clear_all_query_bars(Application_Links *app, View_ID view_id){
Models *models = (Models*)app->cmd_context;
View *view = imp_get_view(models, view_id);
if (api_check_view(view)){
free_all_queries(&view->query_set);
}
}
api(custom) function b32
print_message(Application_Links *app, String_Const_u8 message)
{
@ -2552,11 +2558,11 @@ try_create_new_face(Application_Links *app, Face_Description *description)
if (is_running_coroutine(app)){
Coroutine *coroutine = (Coroutine*)app->current_coroutine;
Assert(coroutine != 0);
App_Coroutine_Out *out = (App_Coroutine_Out*)coroutine->out;
out->request = AppCoroutineRequest_NewFontFace;
Co_Out *out = (Co_Out*)coroutine->out;
out->request = CoRequest_NewFontFace;
out->face_description = description;
coroutine_yield(coroutine);
App_Coroutine_In *in = (App_Coroutine_In*)coroutine->in;
Co_In *in = (Co_In*)coroutine->in;
result = in->face_id;
}
else{
@ -2574,12 +2580,12 @@ try_modify_face(Application_Links *app, Face_ID id, Face_Description *descriptio
if (is_running_coroutine(app)){
Coroutine *coroutine = (Coroutine*)app->current_coroutine;
Assert(coroutine != 0);
App_Coroutine_Out *out = (App_Coroutine_Out*)coroutine->out;
out->request = AppCoroutineRequest_NewFontFace;
Co_Out *out = (Co_Out*)coroutine->out;
out->request = CoRequest_NewFontFace;
out->face_description = description;
out->face_id = id;
coroutine_yield(coroutine);
App_Coroutine_In *in = (App_Coroutine_In*)coroutine->in;
Co_In *in = (Co_In*)coroutine->in;
result = in->success;
}
else{

View File

@ -34,36 +34,6 @@ enum App_State{
APP_STATE_COUNT
};
struct App_Coroutine_In{
union{
struct Models *models;
User_Input user_input;
Face_ID face_id;
b32 success;
};
};
typedef i32 App_Coroutine_Request;
enum{
AppCoroutineRequest_None = 0,
AppCoroutineRequest_NewFontFace = 1,
AppCoroutineRequest_ModifyFace = 2,
};
struct App_Coroutine_Out{
App_Coroutine_Request request;
union{
struct{
Event_Property get_flags;
Event_Property abort_flags;
};
struct{
Face_Description *face_description;
Face_ID face_id;
};
};
};
struct Models{
Thread_Context *tctx;
@ -76,8 +46,6 @@ struct Models{
Face_ID global_face_id;
Coroutine_Group coroutines;
Coroutine *command_coroutine;
App_Coroutine_Out coroutine_out;
Child_Process_Container child_processes;
Custom_API config_api;
@ -94,7 +62,7 @@ struct Models{
Buffer_Hook_Function *hook_end_file;
File_Edit_Range_Function *hook_file_edit_range;
File_Externally_Modified_Function *hook_file_externally_modified;
Command_Caller_Hook_Function *command_caller;
Custom_Command_Function *view_event_handler;
Render_Caller_Function *render_caller;
Input_Filter_Function *input_filter;
Start_Hook_Function *hook_start;
@ -186,7 +154,6 @@ struct Consumption_Record{
typedef i32 App_Coroutine_Purpose;
enum{
Co_View,
Co_Command,
};
struct App_Coroutine_State{
void *co;

View File

@ -49,7 +49,6 @@
#include "4ed_working_set.h"
#include "4ed_hot_directory.h"
#include "4ed_cli.h"
#include "4ed_gui.h"
#include "4ed_layout.h"
#include "4ed_view.h"
#include "4ed_edit.h"
@ -97,7 +96,6 @@
#include "4ed_working_set.cpp"
#include "4ed_hot_directory.cpp"
#include "4ed_cli.cpp"
#include "4ed_gui.cpp"
#include "4ed_layout.cpp"
#include "4ed_view.cpp"
#include "4ed_edit.cpp"

View File

@ -1,55 +0,0 @@
/*
* Mr. 4th Dimention - Allen Webster
*
* 20.02.2016
*
* GUI system for 4coder
*
*/
// TOP
internal void
init_query_set(Query_Set *set){
Query_Slot *slot = set->slots;
set->free_slot = slot;
set->used_slot = 0;
for (i32 i = 0; i+1 < ArrayCount(set->slots); ++i, ++slot){
slot->next = slot + 1;
}
}
internal Query_Slot*
alloc_query_slot(Query_Set *set){
Query_Slot *slot = set->free_slot;
if (slot != 0){
set->free_slot = slot->next;
slot->next = set->used_slot;
set->used_slot = slot;
}
return(slot);
}
internal void
free_query_slot(Query_Set *set, Query_Bar *match_bar){
Query_Slot *slot = 0, *prev = 0;
for (slot = set->used_slot; slot != 0; slot = slot->next){
if (slot->query_bar == match_bar) break;
prev = slot;
}
if (slot){
if (prev){
prev->next = slot->next;
}
else{
set->used_slot = slot->next;
}
slot->next = set->free_slot;
set->free_slot = slot;
}
}
// BOTTOM

View File

@ -1,29 +0,0 @@
/*
* Mr. 4th Dimention - Allen Webster
*
* 20.02.2016
*
* GUI system for 4coder
*
*/
// TOP
#ifndef FRED_GUI_H
#define FRED_GUI_H
struct Query_Slot{
Query_Slot *next;
Query_Bar *query_bar;
};
struct Query_Set{
Query_Slot slots[8];
Query_Slot *free_slot;
Query_Slot *used_slot;
};
#endif
// BOTTOM

View File

@ -9,6 +9,61 @@
// TOP
internal void
init_query_set(Query_Set *set){
Query_Slot *slot = set->slots;
set->free_slot = slot;
set->used_slot = 0;
for (i32 i = 0; i+1 < ArrayCount(set->slots); ++i, ++slot){
slot->next = slot + 1;
}
}
internal Query_Slot*
alloc_query_slot(Query_Set *set){
Query_Slot *slot = set->free_slot;
if (slot != 0){
set->free_slot = slot->next;
slot->next = set->used_slot;
set->used_slot = slot;
}
return(slot);
}
internal void
free_query_slot(Query_Set *set, Query_Bar *match_bar){
Query_Slot *slot = 0;
Query_Slot *prev = 0;
for (slot = set->used_slot; slot != 0; slot = slot->next){
if (slot->query_bar == match_bar) break;
prev = slot;
}
if (slot){
if (prev){
prev->next = slot->next;
}
else{
set->used_slot = slot->next;
}
slot->next = set->free_slot;
set->free_slot = slot;
}
}
function void
free_all_queries(Query_Set *set){
for (;set->used_slot != 0;){
Query_Slot *slot = set->used_slot;
set->used_slot = slot->next;
slot->next = set->free_slot;
set->free_slot = slot;
}
}
////////////////////////////////
internal Command_Map_ID
view_get_map(View *view){
if (view->ui_mode){
@ -394,6 +449,168 @@ view_set_file(Models *models, View *view, Editing_File *file){
////////////////////////////////
internal App_Coroutine_State
get_co_state(Application_Links *app){
App_Coroutine_State state = {};
state.co = app->current_coroutine;
state.type = app->type_coroutine;
return(state);
}
internal void
restore_co_state(Application_Links *app, App_Coroutine_State state){
app->current_coroutine = state.co;
app->type_coroutine = state.type;
}
internal Coroutine*
co_handle_request(Models *models, Coroutine *co, Co_Out *out){
Coroutine *result = 0;
switch (out->request){
case CoRequest_NewFontFace:
{
Face_Description *description = out->face_description;
Face *face = font_set_new_face(&models->font_set, description);
Co_In in = {};
in.face_id = face->id;
result = coroutine_run(&models->coroutines, co, &in, out);
}break;
case CoRequest_ModifyFace:
{
Face_Description *description = out->face_description;
Face_ID face_id = out->face_id;
Co_In in = {};
in.success = font_set_modify_face(&models->font_set, face_id, description);
result = coroutine_run(&models->coroutines, co, &in, out);
}break;
}
return(result);
}
internal Coroutine*
co_run(Models *models, App_Coroutine_Purpose purpose, Coroutine *co,
Co_In *in, Co_Out *out){
Application_Links *app = &models->app_links;
App_Coroutine_State prev_state = get_co_state(app);
app->current_coroutine = co;
app->type_coroutine = purpose;
Coroutine *result = coroutine_run(&models->coroutines, co, in, out);
for (;result != 0 && out->request != CoRequest_None;){
result = co_handle_request(models, result, out);
}
restore_co_state(app, prev_state);
return(result);
}
internal void
view_event_context_base__inner(Coroutine *coroutine){
Co_In *in = (Co_In*)coroutine->in;
Models *models = in->models;
Custom_Command_Function *event_context_base = in->event_context_base;
Assert(event_context_base != 0);
event_context_base(&models->app_links);
}
function void
view_init(Models *models, View *view, Editing_File *initial_buffer,
Custom_Command_Function *event_context_base){
view_set_file(models, view, initial_buffer);
view->co = coroutine_create(&models->coroutines, view_event_context_base__inner);
Co_In in = {};
in.models = models;
in.event_context_base = event_context_base;
view->co = co_run(models, Co_View, view->co, &in, &view->co_out);
// TODO(allen): deal with this kind of problem!
Assert(view->co != 0);
}
function b32
view_close(Models *models, View *view){
Layout *layout = &models->layout;
b32 result = false;
if (layout_close_panel(layout, view->panel)){
live_set_free_view(&models->lifetime_allocator, &models->live_set, view);
result = true;
}
return(result);
}
internal void
view_check_co_exited(Models *models, View *view){
if (view->co == 0){
b32 result = view_close(models, view);
// TODO(allen): Here it looks like the final view has
// closed exited from it's event handler. We should probably
// have a failsafe restarter for the event handler when this
// happens.
Assert(result);
}
}
internal void
co_single_abort(Models *models, View *view){
Coroutine *co = view->co;
Co_In in = {};
in.user_input.abort = true;
view->co = co_run(models, Co_View, co, &in, &view->co_out);
view_check_co_exited(models, view);
}
internal void
co_full_abort(Models *models, View *view){
Coroutine *co = view->co;
Co_In in = {};
in.user_input.abort = true;
for (u32 j = 0; j < 100 && co != 0; ++j){
co = co_run(models, Co_View, co, &in, &view->co_out);
}
if (co != 0){
#define M "SERIOUS ERROR: full stack abort did not complete"
print_message(&models->app_links, string_u8_litexpr(M));
#undef M
}
view->co = 0;
init_query_set(&view->query_set);
}
function b32
co_send_event(Models *models, View *view, Input_Event *event){
b32 event_was_handled = false;
Coroutine *co = view->co;
Co_Out *co_out = &view->co_out;
Event_Property abort_flags = co_out->abort_flags;
Event_Property get_flags = co_out->get_flags|abort_flags;
Event_Property event_flags = get_event_properties(event);
if ((get_flags&event_flags) != 0){
models->event_unhandled = false;
Co_In in = {};
in.user_input.event = *event;
in.user_input.abort = ((abort_flags & event_flags) != 0);
block_copy_struct(&models->event, &in.user_input.event);
view->co = co_run(models, Co_View, view->co, &in, &view->co_out);
view_check_co_exited(models, view);
if (!HasFlag(event_flags, EventProperty_Animate)){
models->animate_next_frame = true;
}
event_was_handled = !models->event_unhandled;
}
return(event_was_handled);
}
function b32
co_send_core_event(Models *models, View *view, Core_Code code){
Input_Event event = {};
event.kind = InputEventKind_Core;
event.core.code = code;
return(co_send_event(models, view, &event));
}
////////////////////////////////
internal b32
file_is_viewed(Layout *layout, Editing_File *file){
b32 is_viewed = false;

View File

@ -12,6 +12,50 @@
#if !defined(FRED_VIEW_H)
#define FRED_VIEW_H
struct Co_In{
union{
struct{
struct Models *models;
Custom_Command_Function *event_context_base;
};
User_Input user_input;
Face_ID face_id;
b32 success;
};
};
typedef i32 Co_Request;
enum{
CoRequest_None = 0,
CoRequest_NewFontFace = 1,
CoRequest_ModifyFace = 2,
};
struct Co_Out{
Co_Request request;
union{
struct{
Event_Property get_flags;
Event_Property abort_flags;
};
struct{
Face_Description *face_description;
Face_ID face_id;
};
};
};
struct Query_Slot{
Query_Slot *next;
Query_Bar *query_bar;
};
struct Query_Set{
Query_Slot slots[8];
Query_Slot *free_slot;
Query_Slot *used_slot;
};
struct View{
View *next;
View *prev;
@ -27,6 +71,9 @@ struct View{
b8 new_scroll_target;
Coroutine *co;
Co_Out co_out;
b8 ui_mode;
Command_Map_ID ui_map_id;
Basic_Scroll ui_scroll;
@ -36,8 +83,6 @@ struct View{
b8 hide_file_bar;
b8 show_whitespace;
// misc
Query_Set query_set;
};

View File

@ -780,6 +780,7 @@ CUSTOM_DOC("Attempts to close 4coder.")
CUSTOM_COMMAND_SIG(goto_line)
CUSTOM_DOC("Queries the user for a number, and jumps the cursor to the corresponding line.")
{
Query_Bar_Group group(app);
u8 string_space[256];
Query_Bar bar = {};
bar.prompt = string_u8_litexpr("Goto Line: ");
@ -812,6 +813,7 @@ isearch(Application_Links *app, Scan_Direction start_scan, i64 first_pos,
i64 buffer_size = buffer_get_size(app, buffer);
Query_Bar_Group group(app);
Query_Bar bar = {};
if (start_query_bar(app, &bar, 0) == 0){
return;
@ -828,7 +830,6 @@ isearch(Application_Links *app, Scan_Direction start_scan, i64 first_pos,
String_Const_u8 rsearch_str = string_u8_litexpr("Reverse-I-Search: ");
umem match_size = bar.string.size;
cursor_is_hidden = true;
User_Input in = {};
for (;;){
@ -844,7 +845,9 @@ isearch(Application_Links *app, Scan_Direction start_scan, i64 first_pos,
}
isearch__update_highlight(app, view, Ii64_size(pos, match_size));
in = get_user_input(app, EventPropertyGroup_AnyKeyboardEvent, EventProperty_Escape);
in = get_user_input(app,
EventPropertyGroup_AnyKeyboardEvent,
EventProperty_Escape|EventProperty_ViewActivation);
if (in.abort){
break;
}
@ -968,7 +971,6 @@ isearch(Application_Links *app, Scan_Direction start_scan, i64 first_pos,
}
view_disable_highlight_range(app, view);
cursor_is_hidden = false;
if (in.abort){
umem size = bar.string.size;
@ -1062,6 +1064,7 @@ query_user_replace_pair(Application_Links *app, Arena *arena){
internal void
replace_in_range_query_user(Application_Links *app, Buffer_ID buffer, Range_i64 range){
Scratch_Block scratch(app);
Query_Bar_Group group(app);
String_Pair pair = query_user_replace_pair(app, scratch);
if (pair.valid){
replace_in_range(app, buffer, range, pair.a, pair.b);
@ -1092,6 +1095,7 @@ CUSTOM_DOC("Queries the user for a needle and string. Replaces all occurences of
global_history_edit_group_begin(app);
Scratch_Block scratch(app);
Query_Bar_Group group(app);
String_Pair pair = query_user_replace_pair(app, scratch);
for (Buffer_ID buffer = get_buffer_next(app, 0, AccessOpen);
buffer != 0;
@ -1108,8 +1112,6 @@ query_replace_base(Application_Links *app, View_ID view, Buffer_ID buffer_id, i6
i64 new_pos = 0;
seek_string_forward(app, buffer_id, pos - 1, 0, r, &new_pos);
cursor_is_hidden = true;
i64 buffer_size = buffer_get_size(app, buffer_id);
User_Input in = {};
@ -1138,7 +1140,6 @@ query_replace_base(Application_Links *app, View_ID view, Buffer_ID buffer_id, i6
}
view_disable_highlight_range(app, view);
cursor_is_hidden = false;
if (in.abort){
return;
@ -1149,6 +1150,7 @@ query_replace_base(Application_Links *app, View_ID view, Buffer_ID buffer_id, i6
function void
query_replace_parameter(Application_Links *app, String_Const_u8 replace_str, i64 start_pos, b32 add_replace_query_bar){
Query_Bar_Group group(app);
Query_Bar replace = {};
replace.prompt = string_u8_litexpr("Replace: ");
replace.string = replace_str;
@ -1185,6 +1187,7 @@ CUSTOM_DOC("Queries the user for two strings, and incrementally replaces every o
View_ID view = get_active_view(app, AccessOpen);
Buffer_ID buffer = view_get_buffer(app, view, AccessOpen);
if (buffer != 0){
Query_Bar_Group group(app);
Query_Bar replace = {};
u8 replace_space[1024];
replace.prompt = string_u8_litexpr("Replace: ");
@ -1283,6 +1286,7 @@ CUSTOM_DOC("Deletes the file of the current buffer if 4coder has the appropriate
Scratch_Block scratch(app);
String_Const_u8 file_name = push_buffer_file_name(app, scratch, buffer);
if (file_name.size > 0){
Query_Bar_Group group(app);
Query_Bar bar = {};
bar.prompt = push_u8_stringf(scratch, "Delete '%.*s' (Y)es, (n)o", string_expand(file_name));
if (start_query_bar(app, &bar, 0) != 0){
@ -1325,6 +1329,7 @@ CUSTOM_DOC("Queries the user for a file name and saves the contents of the curre
Buffer_ID buffer = view_get_buffer(app, view, AccessAll);
Scratch_Block scratch(app);
Query_Bar_Group group(app);
String_Const_u8 buffer_name = push_buffer_unique_name(app, scratch, buffer);
// Query the user
@ -1361,6 +1366,7 @@ CUSTOM_DOC("Queries the user for a new name and renames the file of the current
String_Const_u8 file_name = push_buffer_file_name(app, scratch, buffer);
if (file_name.size > 0){
// Query the user
Query_Bar_Group group(app);
String_Const_u8 front = string_front_of_path(file_name);
u8 name_space[4096];
Query_Bar bar = {};
@ -1395,6 +1401,7 @@ CUSTOM_DOC("Queries the user for a name and creates a new directory with the giv
String_Const_u8 hot = push_hot_directory(app, scratch);
// Query the user
Query_Bar_Group group(app);
u8 name_space[4096];
Query_Bar bar = {};
bar.prompt = push_u8_stringf(scratch, "Make directory at '%.*s': ", string_expand(hot));
@ -1733,6 +1740,7 @@ multi_paste_interactive_up_down(Application_Links *app, i32 paste_count, i32 cli
b32 old_to_new = true;
Range_i64 range = multi_paste_range(app, view, Ii64(pos), paste_count, old_to_new);
Query_Bar_Group group(app);
Query_Bar bar = {};
bar.prompt = string_u8_litexpr("Up and Down to condense and expand paste stages; R to reverse order; Return to finish; Escape to abort.");
if (start_query_bar(app, &bar, 0) == 0) return;
@ -1785,6 +1793,7 @@ CUSTOM_COMMAND_SIG(multi_paste_interactive_quick){
i32 clip_count = clipboard_count(app, 0);
if (clip_count > 0){
u8 string_space[256];
Query_Bar_Group group(app);
Query_Bar bar = {};
bar.prompt = string_u8_litexpr("How Many Slots To Paste: ");
bar.string = SCu8(string_space, (umem)0);

View File

@ -22,6 +22,7 @@ CUSTOM_DOC("If the command execute_any_cli has already been used, this will exec
CUSTOM_COMMAND_SIG(execute_any_cli)
CUSTOM_DOC("Queries for an output buffer name and system command, runs the system command as a CLI and prints the output to the specified buffer."){
Scratch_Block scratch(app);
Query_Bar_Group group(app);
Query_Bar bar_out = {};
bar_out.prompt = string_u8_litexpr("Output Buffer: ");

View File

@ -58,8 +58,6 @@ global b32 do_matching_paren_highlight = true;
global b32 do_colored_comment_keywords = true;
global b32 suppressing_mouse = false;
global b32 cursor_is_hidden = false;
global b32 show_fps_hud = false;
// TODO(allen): REMOVE THIS!

View File

@ -14,75 +14,79 @@ START_HOOK_SIG(default_start){
return(0);
}
COMMAND_CALLER_HOOK(default_command_caller){
// app
// NOTE(allen): Get the binding from the buffer's current map
User_Input input = get_command_input(app);
View_ID view = get_active_view(app, AccessAll);
Command_Map_ID map_id = 0;
if (view_is_in_ui_mode(app, view)){
view_get_setting(app, view, ViewSetting_UICommandMap, &map_id);
}
else{
Buffer_ID buffer = view_get_buffer(app, view, AccessAll);
Managed_Scope buffer_scope = buffer_get_managed_scope(app, buffer);
Command_Map_ID *map_id_ptr =
scope_attachment(app, buffer_scope, buffer_map_id, Command_Map_ID);
if (*map_id_ptr == 0){
*map_id_ptr = mapid_file;
CUSTOM_COMMAND_SIG(default_view_input_handler)
CUSTOM_DOC("Input consumption loop for base view behavior")
{
for (;;){
// NOTE(allen): Get the binding from the buffer's current map
User_Input input = get_user_input(app, EventPropertyGroup_All, 0);
if (input.abort){
break;
}
map_id = *map_id_ptr;
}
Command_Binding binding = map_get_binding_recursive(&framework_mapping, map_id, &input.event);
if (binding.custom == 0){
// NOTE(allen): we don't have anything to do with this input,
// leave it marked unhandled so that if there's a follow up
// event it is not blocked.
leave_command_input_unhandled(app);
}
else{
// NOTE(allen): before the command is called do some book keeping
Managed_Scope scope = view_get_managed_scope(app, view);
Rewrite_Type *next_rewrite = scope_attachment(app, scope, view_next_rewrite_loc, Rewrite_Type);
*next_rewrite = Rewrite_None;
if (fcoder_mode == FCoderMode_NotepadLike){
for (View_ID view_it = get_view_next(app, 0, AccessAll);
view_it != 0;
view_it = get_view_next(app, view_it, AccessAll)){
Managed_Scope scope_it = view_get_managed_scope(app, view_it);
b32 *snap_mark_to_cursor = scope_attachment(app, scope_it, view_snap_mark_to_cursor, b32);
*snap_mark_to_cursor = true;
View_ID view = get_active_view(app, AccessAll);
Command_Map_ID map_id = 0;
if (view_is_in_ui_mode(app, view)){
view_get_setting(app, view, ViewSetting_UICommandMap, &map_id);
}
else{
Buffer_ID buffer = view_get_buffer(app, view, AccessAll);
Managed_Scope buffer_scope = buffer_get_managed_scope(app, buffer);
Command_Map_ID *map_id_ptr =
scope_attachment(app, buffer_scope, buffer_map_id, Command_Map_ID);
if (*map_id_ptr == 0){
*map_id_ptr = mapid_file;
}
map_id = *map_id_ptr;
}
// NOTE(allen): call the command
binding.custom(app);
Command_Binding binding = map_get_binding_recursive(&framework_mapping, map_id, &input.event);
// NOTE(allen): after the command is called do some book keeping
next_rewrite = scope_attachment(app, scope, view_next_rewrite_loc, Rewrite_Type);
if (next_rewrite != 0){
Rewrite_Type *rewrite = scope_attachment(app, scope, view_rewrite_loc, Rewrite_Type);
*rewrite = *next_rewrite;
if (binding.custom == 0){
// NOTE(allen): we don't have anything to do with this input,
// leave it marked unhandled so that if there's a follow up
// event it is not blocked.
leave_command_input_unhandled(app);
}
else{
// NOTE(allen): before the command is called do some book keeping
Managed_Scope scope = view_get_managed_scope(app, view);
Rewrite_Type *next_rewrite = scope_attachment(app, scope, view_next_rewrite_loc, Rewrite_Type);
*next_rewrite = Rewrite_None;
if (fcoder_mode == FCoderMode_NotepadLike){
for (View_ID view_it = get_view_next(app, 0, AccessAll);
view_it != 0;
view_it = get_view_next(app, view_it, AccessAll)){
Managed_Scope scope_it = view_get_managed_scope(app, view_it);
b32 *snap_mark_to_cursor = scope_attachment(app, scope_it, view_snap_mark_to_cursor, b32);
if (*snap_mark_to_cursor){
i64 pos = view_get_cursor_pos(app, view_it);
view_set_mark(app, view_it, seek_pos(pos));
*snap_mark_to_cursor = true;
}
}
// NOTE(allen): call the command
binding.custom(app);
// NOTE(allen): after the command is called do some book keeping
next_rewrite = scope_attachment(app, scope, view_next_rewrite_loc, Rewrite_Type);
if (next_rewrite != 0){
Rewrite_Type *rewrite = scope_attachment(app, scope, view_rewrite_loc, Rewrite_Type);
*rewrite = *next_rewrite;
if (fcoder_mode == FCoderMode_NotepadLike){
for (View_ID view_it = get_view_next(app, 0, AccessAll);
view_it != 0;
view_it = get_view_next(app, view_it, AccessAll)){
Managed_Scope scope_it = view_get_managed_scope(app, view_it);
b32 *snap_mark_to_cursor = scope_attachment(app, scope_it, view_snap_mark_to_cursor, b32);
if (*snap_mark_to_cursor){
i64 pos = view_get_cursor_pos(app, view_it);
view_set_mark(app, view_it, seek_pos(pos));
}
}
}
}
}
}
return(0);
}
internal Range_i64_Array
@ -483,8 +487,7 @@ default_buffer_render_caller(Application_Links *app, Frame_Info frame_info, View
}
// NOTE(allen): Cursor and mark
b32 cursor_is_hidden_in_this_view = (cursor_is_hidden && is_active_view);
if (!cursor_is_hidden_in_this_view){
if (!has_highlight_range){
switch (fcoder_mode){
case FCoderMode_Original:
{
@ -1296,7 +1299,7 @@ set_all_default_hooks(Application_Links *app){
set_custom_hook(app, HookID_FileExternallyModified, default_file_externally_modified);
set_custom_hook(app, HookID_EndFile, end_file_close_jump_list);
set_custom_hook(app, HookID_CommandCaller, default_command_caller);
set_custom_hook(app, HookID_ViewEventHandler, default_view_input_handler);
set_custom_hook(app, HookID_RenderCaller, default_render_caller);
set_custom_hook(app, HookID_InputFilter, default_suppress_mouse_filter);
set_custom_hook(app, HookID_ScrollRule, smooth_scroll_rule);

View File

@ -113,6 +113,10 @@ enum{
EventPropertyGroup_AnyUserInput =
EventPropertyGroup_AnyKeyboardEvent|
EventPropertyGroup_AnyMouseEvent,
EventPropertyGroup_All =
EventPropertyGroup_AnyUserInput|
EventProperty_Animate|
EventProperty_ViewActivation,
};
#endif

View File

@ -1276,6 +1276,22 @@ backspace_utf8(String_Const_u8 string){
return(string);
}
////////////////////////////////
Query_Bar_Group::Query_Bar_Group(Application_Links *app){
this->app = app;
this->view = get_active_view(app, AccessAll);
}
Query_Bar_Group::Query_Bar_Group(Application_Links *app, View_ID view){
this->app = app;
this->view = view;
}
Query_Bar_Group::~Query_Bar_Group(){
clear_all_query_bars(this->app, this->view);
}
internal b32
query_user_general(Application_Links *app, Query_Bar *bar, b32 force_number){
// NOTE(allen|a3.4.4): It will not cause an *error* if we continue on after failing to.
@ -1676,7 +1692,8 @@ try_buffer_kill(Application_Links *app, Buffer_ID buffer, View_ID gui_view_id, B
internal String_Const_u8
get_query_string(Application_Links *app, char *query_str, u8 *string_space, i32 space_size){
Query_Bar bar;
Query_Bar_Group group(app);
Query_Bar bar = {};
bar.prompt = SCu8((u8*)query_str);
bar.string = SCu8(string_space, (umem)0);
bar.string_capacity = space_size;

View File

@ -1012,6 +1012,8 @@ project_key_strings_query_user(Application_Links *app,
u8 *binary_file_space, i32 binary_file_cap){
Project_Key_Strings keys = {};
Query_Bar_Group bar_group(app);
Query_Bar script_file_bar = {};
Query_Bar code_file_bar = {};
Query_Bar output_dir_bar = {};

View File

@ -331,17 +331,26 @@ ENUM(u32, Glyph_Flag){
GlyphFlag_Rotate90 = 0x1,
};
STRUCT Query_Bar{
struct Query_Bar{
String_Const_u8 prompt;
String_Const_u8 string;
umem string_capacity;
};
STRUCT Query_Bar_Ptr_Array{
struct Query_Bar_Ptr_Array{
Query_Bar **ptrs;
i32 count;
};
struct Query_Bar_Group{
Application_Links *app;
View_ID view;
Query_Bar_Group(Application_Links *app);
Query_Bar_Group(Application_Links *app, View_ID view);
~Query_Bar_Group();
};
TYPEDEF_FUNC void UI_Quit_Function_Type(struct Application_Links *app, View_ID view);
#define UI_QUIT_FUNCTION(name) void name(struct Application_Links *app, View_ID view)
@ -475,7 +484,7 @@ enum{
HookID_EndFile,
HookID_FileEditRange,
HookID_FileExternallyModified,
HookID_CommandCaller,
HookID_ViewEventHandler,
HookID_RenderCaller,
HookID_InputFilter,
HookID_Start,
@ -488,9 +497,6 @@ enum{
TYPEDEF_FUNC i32 Hook_Function(struct Application_Links *app);
#define HOOK_SIG(name) i32 name(struct Application_Links *app)
TYPEDEF_FUNC i32 Command_Caller_Hook_Function(struct Application_Links *app);
#define COMMAND_CALLER_HOOK(name) i32 name(struct Application_Links *app)
TYPEDEF_FUNC void Render_Caller_Function(struct Application_Links *app, Frame_Info frame_info);
#define RENDER_CALLER_SIG(name) void name(struct Application_Links *app, Frame_Info frame_info)

View File

@ -2,14 +2,14 @@
#define command_id(c) (fcoder_metacmd_ID_##c)
#define command_metadata(c) (&fcoder_metacmd_table[command_id(c)])
#define command_metadata_by_id(id) (&fcoder_metacmd_table[id])
#define command_one_past_last_id 224
#define command_one_past_last_id 225
#if defined(CUSTOM_COMMAND_SIG)
#define PROC_LINKS(x,y) x
#else
#define PROC_LINKS(x,y) y
#endif
#if defined(CUSTOM_COMMAND_SIG)
CUSTOM_COMMAND_SIG(miblo_decrement_time_stamp_minute);
CUSTOM_COMMAND_SIG(default_view_input_handler);
CUSTOM_COMMAND_SIG(seek_beginning_of_textual_line);
CUSTOM_COMMAND_SIG(seek_end_of_textual_line);
CUSTOM_COMMAND_SIG(seek_beginning_of_line);
@ -233,6 +233,7 @@ CUSTOM_COMMAND_SIG(miblo_decrement_basic);
CUSTOM_COMMAND_SIG(miblo_increment_time_stamp);
CUSTOM_COMMAND_SIG(miblo_decrement_time_stamp);
CUSTOM_COMMAND_SIG(miblo_increment_time_stamp_minute);
CUSTOM_COMMAND_SIG(miblo_decrement_time_stamp_minute);
#endif
struct Command_Metadata{
PROC_LINKS(Custom_Command_Function, void) *proc;
@ -244,14 +245,14 @@ char *source_name;
i32 source_name_len;
i32 line_number;
};
static Command_Metadata fcoder_metacmd_table[224] = {
{ PROC_LINKS(miblo_decrement_time_stamp_minute, 0), "miblo_decrement_time_stamp_minute", 33, "Decrement a time stamp under the cursor by one minute. (format [m]m:ss or h:mm:ss", 81, "w:\\4ed\\code\\custom\\4coder_miblo_numbers.cpp", 43, 249 },
{ PROC_LINKS(seek_beginning_of_textual_line, 0), "seek_beginning_of_textual_line", 30, "Seeks the cursor to the beginning of the line across all text.", 62, "w:\\4ed\\code\\custom\\4coder_helper.cpp", 36, 1967 },
{ PROC_LINKS(seek_end_of_textual_line, 0), "seek_end_of_textual_line", 24, "Seeks the cursor to the end of the line across all text.", 56, "w:\\4ed\\code\\custom\\4coder_helper.cpp", 36, 1973 },
{ PROC_LINKS(seek_beginning_of_line, 0), "seek_beginning_of_line", 22, "Seeks the cursor to the beginning of the visual line.", 53, "w:\\4ed\\code\\custom\\4coder_helper.cpp", 36, 1979 },
{ PROC_LINKS(seek_end_of_line, 0), "seek_end_of_line", 16, "Seeks the cursor to the end of the visual line.", 47, "w:\\4ed\\code\\custom\\4coder_helper.cpp", 36, 1985 },
{ PROC_LINKS(goto_beginning_of_file, 0), "goto_beginning_of_file", 22, "Sets the cursor to the beginning of the file.", 45, "w:\\4ed\\code\\custom\\4coder_helper.cpp", 36, 1991 },
{ PROC_LINKS(goto_end_of_file, 0), "goto_end_of_file", 16, "Sets the cursor to the end of the file.", 39, "w:\\4ed\\code\\custom\\4coder_helper.cpp", 36, 1999 },
static Command_Metadata fcoder_metacmd_table[225] = {
{ PROC_LINKS(default_view_input_handler, 0), "default_view_input_handler", 26, "Input consumption loop for base view behavior", 45, "w:\\4ed\\code\\custom\\4coder_default_hooks.cpp", 43, 17 },
{ PROC_LINKS(seek_beginning_of_textual_line, 0), "seek_beginning_of_textual_line", 30, "Seeks the cursor to the beginning of the line across all text.", 62, "w:\\4ed\\code\\custom\\4coder_helper.cpp", 36, 1984 },
{ PROC_LINKS(seek_end_of_textual_line, 0), "seek_end_of_textual_line", 24, "Seeks the cursor to the end of the line across all text.", 56, "w:\\4ed\\code\\custom\\4coder_helper.cpp", 36, 1990 },
{ PROC_LINKS(seek_beginning_of_line, 0), "seek_beginning_of_line", 22, "Seeks the cursor to the beginning of the visual line.", 53, "w:\\4ed\\code\\custom\\4coder_helper.cpp", 36, 1996 },
{ PROC_LINKS(seek_end_of_line, 0), "seek_end_of_line", 16, "Seeks the cursor to the end of the visual line.", 47, "w:\\4ed\\code\\custom\\4coder_helper.cpp", 36, 2002 },
{ PROC_LINKS(goto_beginning_of_file, 0), "goto_beginning_of_file", 22, "Sets the cursor to the beginning of the file.", 45, "w:\\4ed\\code\\custom\\4coder_helper.cpp", 36, 2008 },
{ PROC_LINKS(goto_end_of_file, 0), "goto_end_of_file", 16, "Sets the cursor to the end of the file.", 39, "w:\\4ed\\code\\custom\\4coder_helper.cpp", 36, 2016 },
{ PROC_LINKS(change_active_panel, 0), "change_active_panel", 19, "Change the currently active panel, moving to the panel with the next highest view_id.", 85, "w:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 196 },
{ PROC_LINKS(change_active_panel_backwards, 0), "change_active_panel_backwards", 29, "Change the currently active panel, moving to the panel with the next lowest view_id.", 84, "w:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 206 },
{ PROC_LINKS(open_panel_vsplit, 0), "open_panel_vsplit", 17, "Create a new panel by vertically splitting the active panel.", 60, "w:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 216 },
@ -331,37 +332,37 @@ static Command_Metadata fcoder_metacmd_table[224] = {
{ PROC_LINKS(eol_nixify, 0), "eol_nixify", 10, "Puts the buffer in NIX line ending mode.", 40, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 764 },
{ PROC_LINKS(exit_4coder, 0), "exit_4coder", 11, "Attempts to close 4coder.", 25, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 772 },
{ PROC_LINKS(goto_line, 0), "goto_line", 9, "Queries the user for a number, and jumps the cursor to the corresponding line.", 78, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 780 },
{ PROC_LINKS(search, 0), "search", 6, "Begins an incremental search down through the current buffer for a user specified string.", 89, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1007 },
{ PROC_LINKS(reverse_search, 0), "reverse_search", 14, "Begins an incremental search up through the current buffer for a user specified string.", 87, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1013 },
{ PROC_LINKS(search_identifier, 0), "search_identifier", 17, "Begins an incremental search down through the current buffer for the word or token under the cursor.", 100, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1019 },
{ PROC_LINKS(reverse_search_identifier, 0), "reverse_search_identifier", 25, "Begins an incremental search up through the current buffer for the word or token under the cursor.", 98, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1025 },
{ PROC_LINKS(replace_in_range, 0), "replace_in_range", 16, "Queries the user for a needle and string. Replaces all occurences of needle with string in the range between cursor and the mark in the active buffer.", 150, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1071 },
{ PROC_LINKS(replace_in_buffer, 0), "replace_in_buffer", 17, "Queries the user for a needle and string. Replaces all occurences of needle with string in the active buffer.", 109, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1080 },
{ PROC_LINKS(replace_in_all_buffers, 0), "replace_in_all_buffers", 22, "Queries the user for a needle and string. Replaces all occurences of needle with string in all editable buffers.", 112, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1089 },
{ PROC_LINKS(query_replace, 0), "query_replace", 13, "Queries the user for two strings, and incrementally replaces every occurence of the first string with the second string.", 120, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1182 },
{ PROC_LINKS(query_replace_identifier, 0), "query_replace_identifier", 24, "Queries the user for a string, and incrementally replace every occurence of the word or token found at the cursor with the specified string.", 140, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1202 },
{ PROC_LINKS(query_replace_selection, 0), "query_replace_selection", 23, "Queries the user for a string, and incrementally replace every occurence of the string found in the selected range with the specified string.", 141, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1218 },
{ PROC_LINKS(save_all_dirty_buffers, 0), "save_all_dirty_buffers", 22, "Saves all buffers marked dirty (showing the '*' indicator).", 59, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1253 },
{ PROC_LINKS(delete_file_query, 0), "delete_file_query", 17, "Deletes the file of the current buffer if 4coder has the appropriate access rights. Will ask the user for confirmation first.", 125, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1278 },
{ PROC_LINKS(save_to_query, 0), "save_to_query", 13, "Queries the user for a file name and saves the contents of the current buffer, altering the buffer's name too.", 110, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1321 },
{ PROC_LINKS(rename_file_query, 0), "rename_file_query", 17, "Queries the user for a new name and renames the file of the current buffer, altering the buffer's name too.", 107, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1353 },
{ PROC_LINKS(make_directory_query, 0), "make_directory_query", 20, "Queries the user for a name and creates a new directory with the given name.", 76, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1390 },
{ PROC_LINKS(move_line_up, 0), "move_line_up", 12, "Swaps the line under the cursor with the line above it, and moves the cursor up with it.", 88, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1423 },
{ PROC_LINKS(move_line_down, 0), "move_line_down", 14, "Swaps the line under the cursor with the line below it, and moves the cursor down with it.", 90, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1429 },
{ PROC_LINKS(duplicate_line, 0), "duplicate_line", 14, "Create a copy of the line on which the cursor sits.", 51, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1435 },
{ PROC_LINKS(delete_line, 0), "delete_line", 11, "Delete the line the on which the cursor sits.", 45, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1449 },
{ PROC_LINKS(open_file_in_quotes, 0), "open_file_in_quotes", 19, "Reads a filename from surrounding '\"' characters and attempts to open the corresponding file.", 94, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1514 },
{ PROC_LINKS(open_matching_file_cpp, 0), "open_matching_file_cpp", 22, "If the current file is a *.cpp or *.h, attempts to open the corresponding *.h or *.cpp file in the other view.", 110, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1546 },
{ PROC_LINKS(view_buffer_other_panel, 0), "view_buffer_other_panel", 23, "Set the other non-active panel to view the buffer that the active panel views, and switch to that panel.", 104, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1559 },
{ PROC_LINKS(swap_buffers_between_panels, 0), "swap_buffers_between_panels", 27, "Set the other non-active panel to view the buffer that the active panel views, and switch to that panel.", 104, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1571 },
{ PROC_LINKS(kill_buffer, 0), "kill_buffer", 11, "Kills the current buffer.", 25, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1607 },
{ PROC_LINKS(save, 0), "save", 4, "Saves the current buffer.", 25, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1615 },
{ PROC_LINKS(reopen, 0), "reopen", 6, "Reopen the current buffer from the hard drive.", 46, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1625 },
{ PROC_LINKS(undo, 0), "undo", 4, "Advances backwards through the undo history of the current buffer.", 66, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1852 },
{ PROC_LINKS(redo, 0), "redo", 4, "Advances forwards through the undo history of the current buffer.", 65, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1865 },
{ PROC_LINKS(undo_all_buffers, 0), "undo_all_buffers", 16, "Advances backward through the undo history in the buffer containing the most recent regular edit.", 97, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1879 },
{ PROC_LINKS(redo_all_buffers, 0), "redo_all_buffers", 16, "Advances forward through the undo history in the buffer containing the most recent regular edit.", 96, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1950 },
{ PROC_LINKS(open_in_other, 0), "open_in_other", 13, "Interactively opens a file in the other panel.", 46, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 2051 },
{ PROC_LINKS(search, 0), "search", 6, "Begins an incremental search down through the current buffer for a user specified string.", 89, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1009 },
{ PROC_LINKS(reverse_search, 0), "reverse_search", 14, "Begins an incremental search up through the current buffer for a user specified string.", 87, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1015 },
{ PROC_LINKS(search_identifier, 0), "search_identifier", 17, "Begins an incremental search down through the current buffer for the word or token under the cursor.", 100, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1021 },
{ PROC_LINKS(reverse_search_identifier, 0), "reverse_search_identifier", 25, "Begins an incremental search up through the current buffer for the word or token under the cursor.", 98, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1027 },
{ PROC_LINKS(replace_in_range, 0), "replace_in_range", 16, "Queries the user for a needle and string. Replaces all occurences of needle with string in the range between cursor and the mark in the active buffer.", 150, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1074 },
{ PROC_LINKS(replace_in_buffer, 0), "replace_in_buffer", 17, "Queries the user for a needle and string. Replaces all occurences of needle with string in the active buffer.", 109, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1083 },
{ PROC_LINKS(replace_in_all_buffers, 0), "replace_in_all_buffers", 22, "Queries the user for a needle and string. Replaces all occurences of needle with string in all editable buffers.", 112, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1092 },
{ PROC_LINKS(query_replace, 0), "query_replace", 13, "Queries the user for two strings, and incrementally replaces every occurence of the first string with the second string.", 120, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1184 },
{ PROC_LINKS(query_replace_identifier, 0), "query_replace_identifier", 24, "Queries the user for a string, and incrementally replace every occurence of the word or token found at the cursor with the specified string.", 140, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1205 },
{ PROC_LINKS(query_replace_selection, 0), "query_replace_selection", 23, "Queries the user for a string, and incrementally replace every occurence of the string found in the selected range with the specified string.", 141, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1221 },
{ PROC_LINKS(save_all_dirty_buffers, 0), "save_all_dirty_buffers", 22, "Saves all buffers marked dirty (showing the '*' indicator).", 59, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1256 },
{ PROC_LINKS(delete_file_query, 0), "delete_file_query", 17, "Deletes the file of the current buffer if 4coder has the appropriate access rights. Will ask the user for confirmation first.", 125, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1281 },
{ PROC_LINKS(save_to_query, 0), "save_to_query", 13, "Queries the user for a file name and saves the contents of the current buffer, altering the buffer's name too.", 110, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1325 },
{ PROC_LINKS(rename_file_query, 0), "rename_file_query", 17, "Queries the user for a new name and renames the file of the current buffer, altering the buffer's name too.", 107, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1358 },
{ PROC_LINKS(make_directory_query, 0), "make_directory_query", 20, "Queries the user for a name and creates a new directory with the given name.", 76, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1396 },
{ PROC_LINKS(move_line_up, 0), "move_line_up", 12, "Swaps the line under the cursor with the line above it, and moves the cursor up with it.", 88, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1430 },
{ PROC_LINKS(move_line_down, 0), "move_line_down", 14, "Swaps the line under the cursor with the line below it, and moves the cursor down with it.", 90, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1436 },
{ PROC_LINKS(duplicate_line, 0), "duplicate_line", 14, "Create a copy of the line on which the cursor sits.", 51, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1442 },
{ PROC_LINKS(delete_line, 0), "delete_line", 11, "Delete the line the on which the cursor sits.", 45, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1456 },
{ PROC_LINKS(open_file_in_quotes, 0), "open_file_in_quotes", 19, "Reads a filename from surrounding '\"' characters and attempts to open the corresponding file.", 94, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1521 },
{ PROC_LINKS(open_matching_file_cpp, 0), "open_matching_file_cpp", 22, "If the current file is a *.cpp or *.h, attempts to open the corresponding *.h or *.cpp file in the other view.", 110, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1553 },
{ PROC_LINKS(view_buffer_other_panel, 0), "view_buffer_other_panel", 23, "Set the other non-active panel to view the buffer that the active panel views, and switch to that panel.", 104, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1566 },
{ PROC_LINKS(swap_buffers_between_panels, 0), "swap_buffers_between_panels", 27, "Set the other non-active panel to view the buffer that the active panel views, and switch to that panel.", 104, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1578 },
{ PROC_LINKS(kill_buffer, 0), "kill_buffer", 11, "Kills the current buffer.", 25, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1614 },
{ PROC_LINKS(save, 0), "save", 4, "Saves the current buffer.", 25, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1622 },
{ PROC_LINKS(reopen, 0), "reopen", 6, "Reopen the current buffer from the hard drive.", 46, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1632 },
{ PROC_LINKS(undo, 0), "undo", 4, "Advances backwards through the undo history of the current buffer.", 66, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1861 },
{ PROC_LINKS(redo, 0), "redo", 4, "Advances forwards through the undo history of the current buffer.", 65, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1874 },
{ PROC_LINKS(undo_all_buffers, 0), "undo_all_buffers", 16, "Advances backward through the undo history in the buffer containing the most recent regular edit.", 97, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1888 },
{ PROC_LINKS(redo_all_buffers, 0), "redo_all_buffers", 16, "Advances forward through the undo history in the buffer containing the most recent regular edit.", 96, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1959 },
{ PROC_LINKS(open_in_other, 0), "open_in_other", 13, "Interactively opens a file in the other panel.", 46, "w:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 2060 },
{ PROC_LINKS(lister__quit, 0), "lister__quit", 12, "A lister mode command that quits the list without executing any actions.", 72, "w:\\4ed\\code\\custom\\4coder_lists.cpp", 35, 8 },
{ PROC_LINKS(lister__activate, 0), "lister__activate", 16, "A lister mode command that activates the list's action on the highlighted item.", 79, "w:\\4ed\\code\\custom\\4coder_lists.cpp", 35, 15 },
{ PROC_LINKS(lister__write_character, 0), "lister__write_character", 23, "A lister mode command that dispatches to the lister's write character handler.", 78, "w:\\4ed\\code\\custom\\4coder_lists.cpp", 35, 30 },
@ -436,11 +437,11 @@ static Command_Metadata fcoder_metacmd_table[224] = {
{ PROC_LINKS(load_project, 0), "load_project", 12, "Looks for a project.4coder file in the current directory and tries to load it. Looks in parent directories until a project file is found or there are no more parents.", 167, "w:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 937 },
{ PROC_LINKS(project_fkey_command, 0), "project_fkey_command", 20, "Run an 'fkey command' configured in a project.4coder file. Determines the index of the 'fkey command' by which function key or numeric key was pressed to trigger the command.", 175, "w:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 944 },
{ PROC_LINKS(project_go_to_root_directory, 0), "project_go_to_root_directory", 28, "Changes 4coder's hot directory to the root directory of the currently loaded project. With no loaded project nothing hapepns.", 125, "w:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 969 },
{ PROC_LINKS(setup_new_project, 0), "setup_new_project", 17, "Queries the user for several configuration options and initializes a new 4coder project with build scripts for every OS.", 120, "w:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1301 },
{ PROC_LINKS(setup_build_bat, 0), "setup_build_bat", 15, "Queries the user for several configuration options and initializes a new build batch script.", 92, "w:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1308 },
{ PROC_LINKS(setup_build_sh, 0), "setup_build_sh", 14, "Queries the user for several configuration options and initializes a new build shell script.", 92, "w:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1314 },
{ PROC_LINKS(setup_build_bat_and_sh, 0), "setup_build_bat_and_sh", 22, "Queries the user for several configuration options and initializes a new build batch script.", 92, "w:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1320 },
{ PROC_LINKS(project_command_lister, 0), "project_command_lister", 22, "Open a lister of all commands in the currently loaded project.", 62, "w:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1335 },
{ PROC_LINKS(setup_new_project, 0), "setup_new_project", 17, "Queries the user for several configuration options and initializes a new 4coder project with build scripts for every OS.", 120, "w:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1303 },
{ PROC_LINKS(setup_build_bat, 0), "setup_build_bat", 15, "Queries the user for several configuration options and initializes a new build batch script.", 92, "w:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1310 },
{ PROC_LINKS(setup_build_sh, 0), "setup_build_sh", 14, "Queries the user for several configuration options and initializes a new build shell script.", 92, "w:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1316 },
{ PROC_LINKS(setup_build_bat_and_sh, 0), "setup_build_bat_and_sh", 22, "Queries the user for several configuration options and initializes a new build batch script.", 92, "w:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1322 },
{ PROC_LINKS(project_command_lister, 0), "project_command_lister", 22, "Open a lister of all commands in the currently loaded project.", 62, "w:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1337 },
{ PROC_LINKS(list_all_functions_current_buffer, 0), "list_all_functions_current_buffer", 33, "Creates a jump list of lines of the current buffer that appear to define or declare functions.", 94, "w:\\4ed\\code\\custom\\4coder_function_list.cpp", 43, 267 },
{ PROC_LINKS(list_all_functions_current_buffer_lister, 0), "list_all_functions_current_buffer_lister", 40, "Creates a lister of locations that look like function definitions and declarations in the buffer.", 97, "w:\\4ed\\code\\custom\\4coder_function_list.cpp", 43, 277 },
{ PROC_LINKS(list_all_functions_all_buffers, 0), "list_all_functions_all_buffers", 30, "Creates a jump list of lines from all buffers that appear to define or declare functions.", 89, "w:\\4ed\\code\\custom\\4coder_function_list.cpp", 43, 289 },
@ -469,8 +470,9 @@ static Command_Metadata fcoder_metacmd_table[224] = {
{ PROC_LINKS(miblo_increment_time_stamp, 0), "miblo_increment_time_stamp", 26, "Increment a time stamp under the cursor by one second. (format [m]m:ss or h:mm:ss", 81, "w:\\4ed\\code\\custom\\4coder_miblo_numbers.cpp", 43, 231 },
{ PROC_LINKS(miblo_decrement_time_stamp, 0), "miblo_decrement_time_stamp", 26, "Decrement a time stamp under the cursor by one second. (format [m]m:ss or h:mm:ss", 81, "w:\\4ed\\code\\custom\\4coder_miblo_numbers.cpp", 43, 237 },
{ PROC_LINKS(miblo_increment_time_stamp_minute, 0), "miblo_increment_time_stamp_minute", 33, "Increment a time stamp under the cursor by one minute. (format [m]m:ss or h:mm:ss", 81, "w:\\4ed\\code\\custom\\4coder_miblo_numbers.cpp", 43, 243 },
{ PROC_LINKS(miblo_decrement_time_stamp_minute, 0), "miblo_decrement_time_stamp_minute", 33, "Decrement a time stamp under the cursor by one minute. (format [m]m:ss or h:mm:ss", 81, "w:\\4ed\\code\\custom\\4coder_miblo_numbers.cpp", 43, 249 },
};
static i32 fcoder_metacmd_ID_miblo_decrement_time_stamp_minute = 0;
static i32 fcoder_metacmd_ID_default_view_input_handler = 0;
static i32 fcoder_metacmd_ID_seek_beginning_of_textual_line = 1;
static i32 fcoder_metacmd_ID_seek_end_of_textual_line = 2;
static i32 fcoder_metacmd_ID_seek_beginning_of_line = 3;
@ -694,4 +696,5 @@ static i32 fcoder_metacmd_ID_miblo_decrement_basic = 220;
static i32 fcoder_metacmd_ID_miblo_increment_time_stamp = 221;
static i32 fcoder_metacmd_ID_miblo_decrement_time_stamp = 222;
static i32 fcoder_metacmd_ID_miblo_increment_time_stamp_minute = 223;
static i32 fcoder_metacmd_ID_miblo_decrement_time_stamp_minute = 224;
#endif

View File

@ -124,6 +124,7 @@ vtable->get_mouse_state = get_mouse_state;
vtable->get_active_query_bars = get_active_query_bars;
vtable->start_query_bar = start_query_bar;
vtable->end_query_bar = end_query_bar;
vtable->clear_all_query_bars = clear_all_query_bars;
vtable->print_message = print_message;
vtable->log_string = log_string;
vtable->thread_get_id = thread_get_id;
@ -298,6 +299,7 @@ get_mouse_state = vtable->get_mouse_state;
get_active_query_bars = vtable->get_active_query_bars;
start_query_bar = vtable->start_query_bar;
end_query_bar = vtable->end_query_bar;
clear_all_query_bars = vtable->clear_all_query_bars;
print_message = vtable->print_message;
log_string = vtable->log_string;
thread_get_id = vtable->thread_get_id;

View File

@ -122,6 +122,7 @@
#define custom_get_active_query_bars_sig() b32 custom_get_active_query_bars(Application_Links* app, View_ID view_id, i32 max_result_count, Query_Bar_Ptr_Array* array_out)
#define custom_start_query_bar_sig() b32 custom_start_query_bar(Application_Links* app, Query_Bar* bar, u32 flags)
#define custom_end_query_bar_sig() void custom_end_query_bar(Application_Links* app, Query_Bar* bar, u32 flags)
#define custom_clear_all_query_bars_sig() void custom_clear_all_query_bars(Application_Links* app, View_ID view_id)
#define custom_print_message_sig() b32 custom_print_message(Application_Links* app, String_Const_u8 message)
#define custom_log_string_sig() b32 custom_log_string(Application_Links* app, String_Const_u8 str)
#define custom_thread_get_id_sig() i32 custom_thread_get_id(Application_Links* app)
@ -292,6 +293,7 @@ typedef Mouse_State custom_get_mouse_state_type(Application_Links* app);
typedef b32 custom_get_active_query_bars_type(Application_Links* app, View_ID view_id, i32 max_result_count, Query_Bar_Ptr_Array* array_out);
typedef b32 custom_start_query_bar_type(Application_Links* app, Query_Bar* bar, u32 flags);
typedef void custom_end_query_bar_type(Application_Links* app, Query_Bar* bar, u32 flags);
typedef void custom_clear_all_query_bars_type(Application_Links* app, View_ID view_id);
typedef b32 custom_print_message_type(Application_Links* app, String_Const_u8 message);
typedef b32 custom_log_string_type(Application_Links* app, String_Const_u8 str);
typedef i32 custom_thread_get_id_type(Application_Links* app);
@ -463,6 +465,7 @@ custom_get_mouse_state_type *get_mouse_state;
custom_get_active_query_bars_type *get_active_query_bars;
custom_start_query_bar_type *start_query_bar;
custom_end_query_bar_type *end_query_bar;
custom_clear_all_query_bars_type *clear_all_query_bars;
custom_print_message_type *print_message;
custom_log_string_type *log_string;
custom_thread_get_id_type *thread_get_id;
@ -635,6 +638,7 @@ internal Mouse_State get_mouse_state(Application_Links* app);
internal b32 get_active_query_bars(Application_Links* app, View_ID view_id, i32 max_result_count, Query_Bar_Ptr_Array* array_out);
internal b32 start_query_bar(Application_Links* app, Query_Bar* bar, u32 flags);
internal void end_query_bar(Application_Links* app, Query_Bar* bar, u32 flags);
internal void clear_all_query_bars(Application_Links* app, View_ID view_id);
internal b32 print_message(Application_Links* app, String_Const_u8 message);
internal b32 log_string(Application_Links* app, String_Const_u8 str);
internal i32 thread_get_id(Application_Links* app);
@ -807,6 +811,7 @@ global custom_get_mouse_state_type *get_mouse_state = 0;
global custom_get_active_query_bars_type *get_active_query_bars = 0;
global custom_start_query_bar_type *start_query_bar = 0;
global custom_end_query_bar_type *end_query_bar = 0;
global custom_clear_all_query_bars_type *clear_all_query_bars = 0;
global custom_print_message_type *print_message = 0;
global custom_log_string_type *log_string = 0;
global custom_thread_get_id_type *thread_get_id = 0;

View File

@ -122,6 +122,7 @@ api(custom) function Mouse_State get_mouse_state(Application_Links* app);
api(custom) function b32 get_active_query_bars(Application_Links* app, View_ID view_id, i32 max_result_count, Query_Bar_Ptr_Array* array_out);
api(custom) function b32 start_query_bar(Application_Links* app, Query_Bar* bar, u32 flags);
api(custom) function void end_query_bar(Application_Links* app, Query_Bar* bar, u32 flags);
api(custom) function void clear_all_query_bars(Application_Links* app, View_ID view_id);
api(custom) function b32 print_message(Application_Links* app, String_Const_u8 message);
api(custom) function b32 log_string(Application_Links* app, String_Const_u8 str);
api(custom) function i32 thread_get_id(Application_Links* app);