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

Commit 62925c5

Browse files
committed
Merge remote-tracking branch 'upstream/master' into BraceHighlightTweaks
2 parents 5f07c0e + 733d01c commit 62925c5

22 files changed

+993
-425
lines changed

4coder_fleury.cpp

Lines changed: 54 additions & 11 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
@@ -139,11 +139,17 @@
139139
// - fleury_color_token_highlight: The color used to underline/highlight
140140
// tokens that the cursor is over.
141141
//
142+
// - fleury_color_token_minor_highlight: The Color That is used for minor
143+
// highlights. i.e. cursor token occurance underlines.
144+
//
142145
// - fleury_color_comment_user_name: The color used to highlight the
143146
// username in comments.
147+
//
148+
// - fleury_color_error_annotation: Text color used for the inline error
149+
// message string with F4_RenderErrorAnnotations
144150

145151

146-
//~ @f4_render_intro Rendering Features
152+
//- @f4_render_intro Rendering Features
147153
//
148154
// Many of the features in this layer are just rendering tweaks/improvements to
149155
// 4coder's defaults. Below is a list of features and some options for them.
@@ -174,8 +180,15 @@
174180
// *compilation* window, it will display what that error is to the right of
175181
// the line. Turn it off with "f4_disable_error_annotations" in your config
176182
// file.
183+
//
184+
// - Cursor Identifier Highlight: The Identifier under the cursor is highlighted
185+
// with an underline (using the fleury_color_token_highlight color). It also
186+
// highlights all other occurances of the identifier (by string) that is
187+
// visible and syntax highlighted (occurances are highlighted using
188+
// "fleury_color_token_minor_highlight". Turn the highlight of other occurances
189+
// off with "f4_disable_cursor_token_occurance" in your config file.
177190

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

194-
//~ @f4_pos_context_intro Language Position-Context Tooltips
207+
//- @f4_pos_context_intro Language Position-Context Tooltips
195208
//
196209
// This feature shows tooltips relating to the current cursor position, as it
197210
// adheres to the programming language of the buffer in question. For example,
@@ -206,7 +219,7 @@
206219
// Alternatively, you can turn the whole thing off with "f4_disable_poscontext"
207220
// in your config file.
208221

209-
//~ @f4_commands
222+
//- @f4_commands
210223
//
211224
// There are a lot of commands you can bind in your bindings.4coder file that
212225
// have been helpful for me and others. Here is a list of the most useful ones.
@@ -238,6 +251,8 @@
238251
// so your laptop doesn't get hot. Set its default value with "f4_battery_saver"
239252
// in your config file.
240253
//
254+
// - f4_disable_cursor_trails: Turns off cursor animation.
255+
//
241256
// - f4_toggle_compilation_expand: Expands/shrinks the *compilation* panel at the
242257
// bottom of the screen. Bind this to a key that you want to press when you are
243258
// checking out the output of a build, and be sure to send your build commands
@@ -339,6 +354,19 @@
339354
// DONE:
340355
//
341356

357+
//~ TODO FOR CASEY
358+
//
359+
// [X] Active pane frame color/thickness control in Fleury config options, to allow turning it
360+
// off entirely or changing the color
361+
// done: f4_margin_size and f4_margin_use_mode_color
362+
// [X] Inactive pane color cursor differences
363+
// [X] Filenames to disambiguate indexed stuff with the same name
364+
// [X] Way to get to forward decl for an indexed thing too
365+
// done: use go-to-definition again, at the definition site, and it should cycle between
366+
// all the definitions
367+
// [ ] Fix clipboard stuff
368+
// [ ] CPM counter shenanigans
369+
342370
//~ TODO PLOTS
343371
// [ ] Un-Bust Histograms
344372
// [ ] Fix plot clip rect bugs when the plot is not 100% in the visible range
@@ -347,7 +375,7 @@
347375
// [ ] Plots and Calc are so coupled and I hate it, please rewrite or something
348376

349377
//~ TODO META
350-
// [ ] Project-wide todo list (by searching for TODO and DONE comments, lister for toggling)
378+
// [X] Project-wide todo list (by searching for TODO and DONE comments, lister for toggling)
351379
// [ ] Project switcher
352380
// [ ] Plan + do modal input scheme... Identifier-mode, text-mode, semantics mode, search mode...?
353381

@@ -388,6 +416,7 @@ typedef int socklen_t;
388416
#include "4coder_fleury_cursor.h"
389417
#include "4coder_fleury_plot.h"
390418
#include "4coder_fleury_calc.h"
419+
#include "4coder_fleury_lego.h"
391420
#include "4coder_fleury_pos_context_tooltips.h"
392421
#include "4coder_fleury_code_peek.h"
393422
#include "4coder_fleury_recent_files.h"
@@ -412,6 +441,7 @@ typedef int socklen_t;
412441
#include "4coder_fleury_cursor.cpp"
413442
#include "4coder_fleury_plot.cpp"
414443
#include "4coder_fleury_calc.cpp"
444+
#include "4coder_fleury_lego.cpp"
415445
#include "4coder_fleury_pos_context_tooltips.cpp"
416446
#include "4coder_fleury_code_peek.cpp"
417447
#include "4coder_fleury_recent_files.cpp"
@@ -475,7 +505,6 @@ void custom_layer_init(Application_Links *app)
475505
}
476506
}
477507

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

@@ -513,7 +542,6 @@ CUSTOM_DOC("Fleury startup event")
513542

514543
//~ NOTE(rjf): Open special buffers.
515544
{
516-
517545
// NOTE(rjf): Open compilation buffer.
518546
{
519547
Buffer_ID comp_buffer = create_buffer(app, string_u8_litexpr("*compilation*"),
@@ -523,6 +551,15 @@ CUSTOM_DOC("Fleury startup event")
523551
buffer_set_setting(app, comp_buffer, BufferSetting_ReadOnly, true);
524552
}
525553

554+
// NOTE(rjf): Open lego buffer.
555+
{
556+
Buffer_ID comp_buffer = create_buffer(app, string_u8_litexpr("*lego*"),
557+
BufferCreate_NeverAttachToFile |
558+
BufferCreate_AlwaysNew);
559+
buffer_set_setting(app, comp_buffer, BufferSetting_Unimportant, true);
560+
buffer_set_setting(app, comp_buffer, BufferSetting_ReadOnly, true);
561+
}
562+
526563
// NOTE(rjf): Open calc buffer.
527564
{
528565
Buffer_ID calc_buffer = create_buffer(app, string_u8_litexpr("*calc*"),
@@ -564,10 +601,11 @@ CUSTOM_DOC("Fleury startup event")
564601
Face_Metrics metrics = get_face_metrics(app, face_id);
565602
view_set_split_pixel_size(app, compilation_view, (i32)(metrics.line_height*4.f));
566603
view_set_passive(app, compilation_view, true);
604+
global_compilation_view = compilation_view;
605+
view_set_buffer(app, compilation_view, comp_id, 0);
567606
}
568-
view_set_buffer(app, compilation_view, comp_id, 0);
607+
569608
view_set_active(app, view);
570-
global_compilation_view = compilation_view;
571609

572610
// NOTE(rjf): Right Panel
573611
open_panel_vsplit(app);
@@ -588,6 +626,11 @@ CUSTOM_DOC("Fleury startup event")
588626
}
589627
}
590628

629+
//~ NOTE(rjf): Set misc options.
630+
{
631+
global_battery_saver = def_get_config_b32(vars_save_string_lit("f4_battery_saver"));
632+
}
633+
591634
//~ NOTE(rjf): Initialize audio.
592635
{
593636
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)