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

Commit 0441af0

Browse files
committed
bump to column command
1 parent f81a256 commit 0441af0

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

4coder_fleury_base_commands.cpp

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1694,6 +1694,52 @@ CUSTOM_DOC("Counts the lines of code in the current buffer, breaks it down by se
16941694
}
16951695
}
16961696

1697+
CUSTOM_COMMAND_SIG(f4_remedy_open_cursor)
1698+
CUSTOM_DOC("Opens the active panel's file in an actively-running RemedyBG instance, and moves to the cursor's line position.")
1699+
{
1700+
Scratch_Block scratch(app);
1701+
View_ID view = get_active_view(app, Access_Read);
1702+
Buffer_ID buffer = view_get_buffer(app, view, Access_Read);
1703+
String8 buffer_name = push_buffer_file_name(app, scratch, buffer);
1704+
i64 pos = view_get_cursor_pos(app, view);
1705+
i64 line = get_line_number_from_pos(app, buffer, pos);
1706+
String8 hot_directory = push_hot_directory(app, scratch);
1707+
Child_Process_ID child_id = create_child_process(app, hot_directory, push_stringf(scratch, "remedybg.exe open-file %.*s %i", string_expand(buffer_name), (int)line));
1708+
(void)child_id;
1709+
}
1710+
1711+
CUSTOM_COMMAND_SIG(f4_bump_to_column)
1712+
CUSTOM_DOC("Insert the required number of spaces to get to a specified column number.")
1713+
{
1714+
View_ID view = get_active_view(app, Access_Always);
1715+
Buffer_ID buffer = view_get_buffer(app, view, Access_Always);
1716+
Face_ID face_id = get_face_id(app, buffer);
1717+
Face_Description description = get_face_description(app, face_id);
1718+
1719+
Query_Bar_Group group(app);
1720+
u8 string_space[256];
1721+
Query_Bar bar = {};
1722+
bar.prompt = string_u8_litexpr("Column Number: ");
1723+
bar.string = SCu8(string_space, (u64)0);
1724+
bar.string_capacity = sizeof(string_space);
1725+
if(query_user_number(app, &bar))
1726+
{
1727+
i64 column_number = (i64)string_to_integer(bar.string, 10);
1728+
i64 cursor = view_get_cursor_pos(app, view);
1729+
i64 cursor_line = get_line_number_from_pos(app, buffer, cursor);
1730+
i64 cursor_column = cursor - get_line_start_pos(app, buffer, cursor_line) + 1;
1731+
i64 spaces_to_insert = column_number - cursor_column;
1732+
History_Group group = history_group_begin(app, buffer);
1733+
for(i64 i = 0; i < spaces_to_insert; i += 1)
1734+
{
1735+
buffer_replace_range(app, buffer, Ii64(cursor, cursor), str8_lit(" "));
1736+
}
1737+
view_set_cursor(app, view, seek_pos(cursor+spaces_to_insert));
1738+
view_set_mark(app, view, seek_pos(cursor+spaces_to_insert));
1739+
history_group_end(group);
1740+
}
1741+
}
1742+
16971743
//~ NOTE(rjf): Deprecated names:
16981744
CUSTOM_COMMAND_SIG(fleury_write_text_input)
16991745
CUSTOM_DOC("Deprecated name. Please update to f4_write_text_input.")

0 commit comments

Comments
 (0)