Compare commits
5 Commits
0ee8e3904a
...
322f690afc
Author | SHA1 | Date |
---|---|---|
|
322f690afc | |
|
ea389639b3 | |
|
01a06a59c7 | |
|
051b5068e5 | |
|
1c9fd3e16f |
|
@ -2053,7 +2053,7 @@ CUSTOM_DOC("Advances forwards through the undo history of the current buffer.")
|
|||
History_Record_Index current = buffer_history_get_current_state_index(app, buffer);
|
||||
History_Record_Index max_index = buffer_history_get_max_record_index(app, buffer);
|
||||
if (current < max_index){
|
||||
Record_Info record = buffer_history_get_record_info(app, buffer, current);
|
||||
Record_Info record = buffer_history_get_record_info(app, buffer, current+1);
|
||||
i64 new_position = record_get_new_cursor_position_redo(app, buffer, current + 1, record);
|
||||
|
||||
buffer_history_set_current_state_index(app, buffer, current + 1);
|
||||
|
|
|
@ -123,6 +123,85 @@ CUSTOM_COMMAND_SIG(cmd_alt_enter_behavior)
|
|||
}
|
||||
}
|
||||
|
||||
function i64
|
||||
qol_seek_char(Application_Links *app, Buffer_ID buffer, Scan_Direction direction, i64 start_pos, u8 target_char){
|
||||
Scratch_Block scratch(app);
|
||||
i64 line = get_line_number_from_pos(app, buffer, start_pos);
|
||||
Range_i64 range = get_line_pos_range(app, buffer, line);
|
||||
range.max += 1;
|
||||
String_Const_u8 string = push_buffer_range(app, scratch, buffer, range);
|
||||
i64 pos = start_pos;
|
||||
while(range_contains(range, pos)){
|
||||
pos += direction;
|
||||
u8 current_char = string.str[pos - range.min];
|
||||
if (current_char == target_char){ return pos; }
|
||||
}
|
||||
return start_pos;
|
||||
}
|
||||
|
||||
CUSTOM_COMMAND_SIG(qol_char_forward)
|
||||
CUSTOM_DOC("[QOL] Seeks forward in current line to the selected char")
|
||||
{
|
||||
View_ID view = get_active_view(app, Access_ReadVisible);
|
||||
Buffer_ID buffer = view_get_buffer(app, view, Access_ReadVisible);
|
||||
i64 cursor_pos = view_get_cursor_pos(app, view);
|
||||
i64 pos = qol_seek_char(app, buffer, Scan_Forward, cursor_pos, qol_target_char);
|
||||
view_set_cursor_and_preferred_x(app, view, seek_pos(pos));
|
||||
}
|
||||
|
||||
CUSTOM_COMMAND_SIG(qol_char_backward)
|
||||
CUSTOM_DOC("[QOL] Seeks back in current line to the selected char")
|
||||
{
|
||||
View_ID view = get_active_view(app, Access_ReadVisible);
|
||||
Buffer_ID buffer = view_get_buffer(app, view, Access_ReadVisible);
|
||||
i64 cursor_pos = view_get_cursor_pos(app, view);
|
||||
i64 pos = qol_seek_char(app, buffer, Scan_Backward, cursor_pos, qol_target_char);
|
||||
view_set_cursor_and_preferred_x(app, view, seek_pos(pos));
|
||||
}
|
||||
|
||||
CUSTOM_COMMAND_SIG(qol_column_toggle)
|
||||
CUSTOM_DOC("[QOL] Toggles the column for bumping and selects hovered char")
|
||||
{
|
||||
View_ID view = get_active_view(app, Access_ReadVisible);
|
||||
Buffer_ID buffer = view_get_buffer(app, view, Access_ReadVisible);
|
||||
if (qol_col_cursor.pos < 0){
|
||||
i64 pos = view_get_cursor_pos(app, view);
|
||||
qol_target_char = buffer_get_char(app, buffer, pos);
|
||||
qol_col_cursor = buffer_compute_cursor(app, buffer, seek_pos(pos));
|
||||
}
|
||||
else{
|
||||
qol_col_cursor.pos = -1;
|
||||
}
|
||||
}
|
||||
|
||||
CUSTOM_COMMAND_SIG(qol_write_space)
|
||||
CUSTOM_DOC("[QOL] Writes as many spaces needed for bumping to column")
|
||||
{
|
||||
Scratch_Block scratch(app);
|
||||
if (qol_col_cursor.pos > 0){
|
||||
View_ID view = get_active_view(app, Access_ReadVisible);
|
||||
Buffer_ID buffer = view_get_buffer(app, view, Access_ReadVisible);
|
||||
|
||||
qol_col_cursor = buffer_compute_cursor(app, buffer, seek_line_col(qol_col_cursor.line, qol_col_cursor.col));
|
||||
|
||||
i64 pos = view_get_cursor_pos(app, view);
|
||||
i64 line = get_line_number_from_pos(app, buffer, pos);
|
||||
f32 col_x = view_relative_xy_of_pos(app, view, line, qol_col_cursor.pos).x;
|
||||
f32 cur_x = view_relative_xy_of_pos(app, view, line, pos).x;
|
||||
Face_ID face = get_face_id(app, buffer);
|
||||
f32 space_advance = get_face_metrics(app, face).space_advance;
|
||||
|
||||
i64 N = i64((col_x - cur_x) / space_advance);
|
||||
if (N < 0){ N = 1; }
|
||||
String_Const_u8 spaces = string_const_u8_push(scratch, N);
|
||||
block_fill_u8(spaces.str, N, ' ');
|
||||
write_text(app, spaces);
|
||||
}
|
||||
else{
|
||||
write_space(app);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function void
|
||||
bindings_cmd_misc(Mapping* m, Command_Map* map)
|
||||
|
@ -231,6 +310,11 @@ custom_keyboard_bindings()
|
|||
Bind(unindent_range, KeyCode_Tab, KeyCode_Shift);
|
||||
Bind(indent_range, KeyCode_Tab);
|
||||
|
||||
Bind(qol_column_toggle, KeyCode_BackwardSlash, key_alt);
|
||||
Bind(qol_write_space, KeyCode_Space, key_alt, KeyCode_Shift);
|
||||
Bind(qol_char_forward, KeyCode_L, key_alt);
|
||||
Bind(qol_char_backward, KeyCode_J, key_alt);
|
||||
|
||||
// Macros
|
||||
Bind(keyboard_macro_start_recording, KeyCode_1, key_alt);
|
||||
Bind(keyboard_macro_finish_recording, KeyCode_2, key_alt);
|
||||
|
|
|
@ -326,7 +326,7 @@ default_render_buffer(Application_Links *app, View_ID view_id, Face_ID face_id,
|
|||
|
||||
// NOTE(allen): Token colorizing
|
||||
|
||||
ARGB_Color color_default = fcolor_resolve(fcolor_id(defcolor_text_default));
|
||||
ARGB_Color color_default = fcolor_resolve(fcolor_id(defcolor_text_default));
|
||||
ARGB_Color color_function = fcolor_resolve(fcolor_id(defcolor_function));
|
||||
ARGB_Color color_operator = fcolor_resolve(fcolor_id(defcolor_operator));
|
||||
ARGB_Color color_type = fcolor_resolve(fcolor_id(defcolor_type));
|
||||
|
@ -365,11 +365,11 @@ ARGB_Color color_default = fcolor_resolve(fcolor_id(defcolor_text_default));
|
|||
token->kind == TokenBaseKind_ParentheticalClose ||
|
||||
token->kind == TokenBaseKind_StatementClose)
|
||||
{
|
||||
token_color = color_operator;
|
||||
token_color = color_operator;
|
||||
}
|
||||
else
|
||||
{
|
||||
String_Const_u8 lexeme = push_token_lexeme(app, scratch, buffer, token);
|
||||
String_Const_u8 lexeme = push_token_lexeme(app, scratch, buffer, token);
|
||||
Code_Index_Note *note = code_index_note_from_string(lexeme);
|
||||
if (note != 0)
|
||||
{
|
||||
|
@ -400,6 +400,18 @@ String_Const_u8 lexeme = push_token_lexeme(app, scratch, buffer, token);
|
|||
draw_scope_highlight(app, buffer, text_layout_id, cursor_pos, colors.vals, colors.count);
|
||||
}
|
||||
|
||||
// NOTE(PS): QOL Column
|
||||
if (qol_col_cursor.pos >= 0){
|
||||
Buffer_Seek seek = seek_line_col(qol_col_cursor.line, qol_col_cursor.col);
|
||||
Buffer_Cursor cursor = buffer_compute_cursor(app, buffer, seek);
|
||||
Rect_f32 col_rect = text_layout_character_on_screen(app, text_layout_id, cursor.pos);
|
||||
if (col_rect.x1 > 0.f){
|
||||
col_rect.y0 = rect.y0;
|
||||
col_rect.y1 = rect.y1;
|
||||
draw_rectangle_fcolor(app, col_rect, 0.f, fcolor_id(defcolor_highlight_cursor_line));
|
||||
}
|
||||
}
|
||||
|
||||
b32 use_error_highlight = def_get_config_b32(vars_save_string_lit("use_error_highlight"));
|
||||
b32 use_jump_highlight = def_get_config_b32(vars_save_string_lit("use_jump_highlight"));
|
||||
if (use_error_highlight || use_jump_highlight){
|
||||
|
|
|
@ -64,6 +64,7 @@
|
|||
#include "4coder_tutorial.h"
|
||||
#include "4coder_search_list.h"
|
||||
#include "4coder_modal.h"
|
||||
#include "4coder_qol.h"
|
||||
|
||||
////////////////////////////////
|
||||
|
||||
|
@ -147,6 +148,8 @@
|
|||
|
||||
#include "4coder_default_hooks.cpp"
|
||||
|
||||
#include "4coder_qol.cpp"
|
||||
|
||||
#endif
|
||||
|
||||
// BOTTOM
|
||||
|
|
|
@ -454,7 +454,8 @@ get_locked_jump_state(Application_Links *app, Heap *heap){
|
|||
Buffer_ID buffer = view_get_buffer(app, result.view, Access_Always);
|
||||
result.list = get_or_make_list_for_buffer(app, heap, buffer);
|
||||
|
||||
i64 cursor_position = view_get_cursor_pos(app, result.view);
|
||||
i64 size = buffer_get_size(app, buffer);
|
||||
i64 cursor_position = size == 0 ? 0 : view_get_cursor_pos(app, result.view) % size;
|
||||
Buffer_Cursor cursor = buffer_compute_cursor(app, buffer, seek_pos(cursor_position));
|
||||
result.list_index = get_index_nearest_from_list(app, result.list, cursor.line);
|
||||
}
|
||||
|
@ -468,7 +469,8 @@ CUSTOM_DOC("If a buffer containing jump locations has been locked in, goes to th
|
|||
|
||||
Locked_Jump_State jump_state = get_locked_jump_state(app, heap);
|
||||
if (jump_state.view != 0){
|
||||
i64 cursor_position = view_get_cursor_pos(app, jump_state.view);
|
||||
i64 size = buffer_get_size(app, view_get_buffer(app, jump_state.view, Access_Always));
|
||||
i64 cursor_position = size == 0 ? 0 : view_get_cursor_pos(app, jump_state.view) % size;
|
||||
Buffer_Cursor cursor = view_compute_cursor(app, jump_state.view, seek_pos(cursor_position));
|
||||
i64 line = get_line_from_list(app, jump_state.list, jump_state.list_index);
|
||||
if (line <= cursor.line){
|
||||
|
|
|
@ -298,6 +298,7 @@ lister_render(Application_Links *app, Frame_Info frame_info, View_ID view){
|
|||
for (i32 i = first_index; i < count; i += 1){
|
||||
Lister_Node *node = lister->filtered.node_ptrs[i];
|
||||
|
||||
if (y_pos >= region.y1) break;
|
||||
Range_f32 y = If32(y_pos, y_pos + block_height);
|
||||
y_pos = y.max;
|
||||
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
/* date = July 7th 2025 2:22 pm */
|
||||
|
||||
#ifndef FCODER_QOL_H
|
||||
#define FCODER_QOL_H
|
||||
|
||||
global u8 qol_target_char;
|
||||
global Buffer_Cursor qol_col_cursor = {-1};
|
||||
|
||||
#endif //FCODER_QOL_H
|
|
@ -52,6 +52,7 @@ print_string_match_list_to_buffer(Application_Links *app, Buffer_ID out_buffer_i
|
|||
}
|
||||
|
||||
end_buffer_insertion(&out);
|
||||
lock_jump_buffer(app, out_buffer_id);
|
||||
}
|
||||
|
||||
internal void
|
||||
|
|
Loading…
Reference in New Issue