Skip to content
This repository was archived by the owner on Feb 8, 2024. It is now read-only.

Commit 3d42232

Browse files
committed
merge
1 parent c5841a7 commit 3d42232

17 files changed

+870
-417
lines changed

4coder_fleury.cpp

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
//~ @f4_features 4coder Fleury Feature/Option List
1616

17-
//~ @f4_lang_intro Multi-Language Support
17+
//- @f4_lang_intro Multi-Language Support
1818
//
1919
// This custom layer has been tweaked to allow for better multi-language support
2020
// in 4coder. It isn't perfect and will not support all languages, but it works
@@ -79,7 +79,7 @@
7979
// 3. Add the info for your language to the 4coder_fleury_lang_list.h file.
8080
// More information is in that file.
8181

82-
//~ @f4_colors_intro Syntax Highlighting and Color Additions
82+
//- @f4_colors_intro Syntax Highlighting and Color Additions
8383
//
8484
// 4coder provides very basic syntax highlighting, but this layer implements
8585
// some more features, particularly ones that rely on the code index. There
@@ -143,7 +143,7 @@
143143
// username in comments.
144144

145145

146-
//~ @f4_render_intro Rendering Features
146+
//- @f4_render_intro Rendering Features
147147
//
148148
// Many of the features in this layer are just rendering tweaks/improvements to
149149
// 4coder's defaults. Below is a list of features and some options for them.
@@ -175,7 +175,7 @@
175175
// the line. Turn it off with "f4_disable_error_annotations" in your config
176176
// file.
177177

178-
//~ @f4_calc_intro Built-In Calculator/Plotting
178+
//- @f4_calc_intro Built-In Calculator/Plotting
179179
//
180180
// This custom layer includes a tiny little calculator language, which has
181181
// plotting capabilities. It has a few features that comprise it all:
@@ -191,7 +191,7 @@
191191
// to. The entire buffer is interpreted as calculator code, and it will
192192
// do all the same things that calc comments do.
193193

194-
//~ @f4_pos_context_intro Language Position-Context Tooltips
194+
//- @f4_pos_context_intro Language Position-Context Tooltips
195195
//
196196
// This feature shows tooltips relating to the current cursor position, as it
197197
// adheres to the programming language of the buffer in question. For example,
@@ -206,7 +206,7 @@
206206
// Alternatively, you can turn the whole thing off with "f4_disable_poscontext"
207207
// in your config file.
208208

209-
//~ @f4_commands
209+
//- @f4_commands
210210
//
211211
// There are a lot of commands you can bind in your bindings.4coder file that
212212
// have been helpful for me and others. Here is a list of the most useful ones.
@@ -238,6 +238,8 @@
238238
// so your laptop doesn't get hot. Set its default value with "f4_battery_saver"
239239
// in your config file.
240240
//
241+
// - f4_disable_cursor_trails: Turns off cursor animation.
242+
//
241243
// - f4_toggle_compilation_expand: Expands/shrinks the *compilation* panel at the
242244
// bottom of the screen. Bind this to a key that you want to press when you are
243245
// checking out the output of a build, and be sure to send your build commands
@@ -339,6 +341,19 @@
339341
// DONE:
340342
//
341343

344+
//~ TODO FOR CASEY
345+
//
346+
// [X] Active pane frame color/thickness control in Fleury config options, to allow turning it
347+
// off entirely or changing the color
348+
// done: f4_margin_size and f4_margin_use_mode_color
349+
// [X] Inactive pane color cursor differences
350+
// [X] Filenames to disambiguate indexed stuff with the same name
351+
// [X] Way to get to forward decl for an indexed thing too
352+
// done: use go-to-definition again, at the definition site, and it should cycle between
353+
// all the definitions
354+
// [ ] Fix clipboard stuff
355+
// [ ] CPM counter shenanigans
356+
342357
//~ TODO PLOTS
343358
// [ ] Un-Bust Histograms
344359
// [ ] Fix plot clip rect bugs when the plot is not 100% in the visible range
@@ -388,6 +403,7 @@ typedef int socklen_t;
388403
#include "4coder_fleury_cursor.h"
389404
#include "4coder_fleury_plot.h"
390405
#include "4coder_fleury_calc.h"
406+
#include "4coder_fleury_lego.h"
391407
#include "4coder_fleury_pos_context_tooltips.h"
392408
#include "4coder_fleury_code_peek.h"
393409
#include "4coder_fleury_recent_files.h"
@@ -412,6 +428,7 @@ typedef int socklen_t;
412428
#include "4coder_fleury_cursor.cpp"
413429
#include "4coder_fleury_plot.cpp"
414430
#include "4coder_fleury_calc.cpp"
431+
#include "4coder_fleury_lego.cpp"
415432
#include "4coder_fleury_pos_context_tooltips.cpp"
416433
#include "4coder_fleury_code_peek.cpp"
417434
#include "4coder_fleury_recent_files.cpp"
@@ -475,7 +492,6 @@ void custom_layer_init(Application_Links *app)
475492
}
476493
}
477494

478-
479495
//~ NOTE(rjf): @f4_startup Whenever 4coder's core is ready for the custom layer to start up,
480496
// this is called.
481497

@@ -513,7 +529,6 @@ CUSTOM_DOC("Fleury startup event")
513529

514530
//~ NOTE(rjf): Open special buffers.
515531
{
516-
517532
// NOTE(rjf): Open compilation buffer.
518533
{
519534
Buffer_ID comp_buffer = create_buffer(app, string_u8_litexpr("*compilation*"),
@@ -523,6 +538,15 @@ CUSTOM_DOC("Fleury startup event")
523538
buffer_set_setting(app, comp_buffer, BufferSetting_ReadOnly, true);
524539
}
525540

541+
// NOTE(rjf): Open lego buffer.
542+
{
543+
Buffer_ID comp_buffer = create_buffer(app, string_u8_litexpr("*lego*"),
544+
BufferCreate_NeverAttachToFile |
545+
BufferCreate_AlwaysNew);
546+
buffer_set_setting(app, comp_buffer, BufferSetting_Unimportant, true);
547+
buffer_set_setting(app, comp_buffer, BufferSetting_ReadOnly, true);
548+
}
549+
526550
// NOTE(rjf): Open calc buffer.
527551
{
528552
Buffer_ID calc_buffer = create_buffer(app, string_u8_litexpr("*calc*"),
@@ -564,10 +588,11 @@ CUSTOM_DOC("Fleury startup event")
564588
Face_Metrics metrics = get_face_metrics(app, face_id);
565589
view_set_split_pixel_size(app, compilation_view, (i32)(metrics.line_height*4.f));
566590
view_set_passive(app, compilation_view, true);
591+
global_compilation_view = compilation_view;
592+
view_set_buffer(app, compilation_view, comp_id, 0);
567593
}
568-
view_set_buffer(app, compilation_view, comp_id, 0);
594+
569595
view_set_active(app, view);
570-
global_compilation_view = compilation_view;
571596

572597
// NOTE(rjf): Right Panel
573598
open_panel_vsplit(app);
@@ -588,6 +613,11 @@ CUSTOM_DOC("Fleury startup event")
588613
}
589614
}
590615

616+
//~ NOTE(rjf): Set misc options.
617+
{
618+
global_battery_saver = def_get_config_b32(vars_save_string_lit("f4_battery_saver"));
619+
}
620+
591621
//~ NOTE(rjf): Initialize audio.
592622
{
593623
def_audio_init();

4coder_fleury_base_commands.cpp

Lines changed: 57 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -116,47 +116,82 @@ F4_GoToDefinition(Application_Links *app, F4_Index_Note *note, b32 same_panel)
116116
Buffer_Scroll scroll = view_get_buffer_scroll(app, view);
117117
scroll.position.line_number = line_number;
118118
scroll.target.line_number = line_number;
119-
scroll.target.pixel_shift.y = -view_height*0.5f;
119+
scroll.position.pixel_shift.y = scroll.target.pixel_shift.y = -view_height*0.5f;
120120
view_set_buffer_scroll(app, view, scroll, SetBufferScroll_SnapCursorIntoView);
121121
view_set_cursor(app, view, seek_pos(note->range.min));
122122
view_set_mark(app, view, seek_pos(note->range.min));
123123
}
124124
}
125125

126126
internal F4_Index_Note *
127-
F4_FindMostIntuitiveNoteInDuplicateChain(F4_Index_Note *note)
127+
F4_FindMostIntuitiveNoteInDuplicateChain(F4_Index_Note *note, Buffer_ID cursor_buffer, i64 cursor_pos)
128128
{
129-
if(note && note->flags & F4_Index_NoteFlag_Prototype)
129+
F4_Index_Note *result = note;
130+
if(note != 0)
130131
{
132+
F4_Index_Note *best_note_based_on_cursor = 0;
131133
for(F4_Index_Note *candidate = note; candidate; candidate = candidate->next)
132134
{
133-
if(!(candidate->flags & F4_Index_NoteFlag_Prototype))
135+
F4_Index_File *file = candidate->file;
136+
if(file != 0)
134137
{
135-
note = candidate;
136-
break;
138+
if(cursor_buffer == file->buffer &&
139+
candidate->range.min <= cursor_pos && cursor_pos <= candidate->range.max)
140+
{
141+
if(candidate->next)
142+
{
143+
best_note_based_on_cursor = candidate->next;
144+
break;
145+
}
146+
else
147+
{
148+
best_note_based_on_cursor = note;
149+
break;
150+
}
151+
}
152+
}
153+
}
154+
155+
if(best_note_based_on_cursor)
156+
{
157+
result = best_note_based_on_cursor;
158+
}
159+
else if(note->flags & F4_Index_NoteFlag_Prototype)
160+
{
161+
for(F4_Index_Note *candidate = note; candidate; candidate = candidate->next)
162+
{
163+
if(!(candidate->flags & F4_Index_NoteFlag_Prototype))
164+
{
165+
result = candidate;
166+
break;
167+
}
137168
}
138169
}
139170
}
140-
return note;
171+
return result;
141172
}
142173

143174
CUSTOM_COMMAND_SIG(f4_go_to_definition)
144175
CUSTOM_DOC("Goes to the definition of the identifier under the cursor.")
145176
{
177+
View_ID view = get_active_view(app, Access_Always);
178+
Buffer_ID buffer = view_get_buffer(app, view, Access_Always);
146179
Scratch_Block scratch(app);
147180
String_Const_u8 string = push_token_or_word_under_active_cursor(app, scratch);
148181
F4_Index_Note *note = F4_Index_LookupNote(string);
149-
note = F4_FindMostIntuitiveNoteInDuplicateChain(note);
182+
note = F4_FindMostIntuitiveNoteInDuplicateChain(note, buffer, view_get_cursor_pos(app, view));
150183
F4_GoToDefinition(app, note, 0);
151184
}
152185

153186
CUSTOM_COMMAND_SIG(f4_go_to_definition_same_panel)
154187
CUSTOM_DOC("Goes to the definition of the identifier under the cursor in the same panel.")
155188
{
189+
View_ID view = get_active_view(app, Access_Always);
190+
Buffer_ID buffer = view_get_buffer(app, view, Access_Always);
156191
Scratch_Block scratch(app);
157192
String_Const_u8 string = push_token_or_word_under_active_cursor(app, scratch);
158193
F4_Index_Note *note = F4_Index_LookupNote(string);
159-
note = F4_FindMostIntuitiveNoteInDuplicateChain(note);
194+
note = F4_FindMostIntuitiveNoteInDuplicateChain(note, buffer, view_get_cursor_pos(app, view));
160195
F4_GoToDefinition(app, note, 1);
161196
}
162197

@@ -172,6 +207,8 @@ _F4_PushListerOptionForNote(Application_Links *app, Arena *arena, Lister *lister
172207
jump->buffer = buffer;
173208
jump->pos = note->range.first;
174209

210+
String_Const_u8 buffer_name = push_buffer_unique_name(app, arena, buffer);
211+
String_Const_u8 name = push_stringf(arena, "[%.*s] %.*s", string_expand(buffer_name), string_expand(note->string));
175212
String_Const_u8 sort = S8Lit("");
176213
switch(note->kind)
177214
{
@@ -209,7 +246,7 @@ _F4_PushListerOptionForNote(Application_Links *app, Arena *arena, Lister *lister
209246

210247
default: break;
211248
}
212-
lister_add_item(lister, note->string, sort, jump, 0);
249+
lister_add_item(lister, name, sort, jump, 0);
213250
}
214251
}
215252

@@ -403,11 +440,11 @@ CUSTOM_DOC("Open a project by navigating to the project file.")
403440
if (HasFlag(attribs.flags, FileAttribute_IsDirectory)){
404441
set_hot_directory(app, full_file_name);
405442
continue;
406-
}
407-
if (string_looks_like_drive_letter(file_name)){
408-
set_hot_directory(app, file_name);
409-
continue;
410-
}
443+
}
444+
if (string_looks_like_drive_letter(file_name)){
445+
set_hot_directory(app, file_name);
446+
continue;
447+
}
411448
if (query_create_folder(app, file_name)){
412449
set_hot_directory(app, full_file_name);
413450
continue;
@@ -524,7 +561,6 @@ CUSTOM_DOC("Sets up a blank 4coder project provided some user folder.")
524561
load_project(app);
525562
}
526563

527-
528564
function i64
529565
F4_Boundary_TokenAndWhitespace(Application_Links *app, Buffer_ID buffer,
530566
Side side, Scan_Direction direction, i64 pos)
@@ -1145,12 +1181,12 @@ CUSTOM_DOC("Interactively open a file out of the file system, filtered to files
11451181
{
11461182
set_hot_directory(app, full_file_name);
11471183
continue;
1148-
}
1149-
if(string_looks_like_drive_letter(file_name))
1184+
}
1185+
if(string_looks_like_drive_letter(file_name))
11501186
{
1151-
set_hot_directory(app, file_name);
1152-
continue;
1153-
}
1187+
set_hot_directory(app, file_name);
1188+
continue;
1189+
}
11541190
if(query_create_folder(app, file_name))
11551191
{
11561192
set_hot_directory(app, full_file_name);

4coder_fleury_bindings.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,10 @@ F4_SetAbsolutelyNecessaryBindings(Mapping *mapping)
103103
SelectMap(code_map_id);
104104
ParentMap(file_map_id);
105105
BindTextInput(fleury_write_text_and_auto_indent);
106-
107-
SelectMap(global_command_map_id);
106+
BindMouse(f4_lego_click_store_token_1, MouseCode_Right);
107+
BindMouse(f4_lego_click_store_token_2, MouseCode_Middle);
108+
109+
SelectMap(global_command_map_id);
108110
ParentMap(global_map_id);
109111
GlobalCommandMapReroute[0].From = global_map_id;
110112
GlobalCommandMapReroute[0].To = global_command_map_id;

0 commit comments

Comments
 (0)