Skip to content

Commit

Permalink
Save target config file when hitting save in color preview
Browse files Browse the repository at this point in the history
  • Loading branch information
focus-editor committed Sep 13, 2024
1 parent eab3ad8 commit 360576b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions FOCUS-CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
+ The `delete_to_start_of_line` command will now delete to the indentation level first, not to the very start of the line right away
+ Many internal changes to reduce the memory footprint and improve the cache friendliness of internal data structures
+ Files larger than the limit of 2,147,483,647 bytes will now no longer be loaded with an error message rather than crashing
+ Hitting save when in the color preview editor will save the target config file, instead of attempting to save the color preview sample text somewhere


# RELEASES ==================================================================
Expand Down
11 changes: 10 additions & 1 deletion src/editors.jai
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ active_editor_handle_event :: (editor: *Editor, buffer: *Buffer, event: Input.Ev
reset_search_results(*editor.search_bar);
editor.refresh_selection = true;

case .save; save(editor.buffer_id);
case .save; save(editor, editors.active);
case .save_all; save_all();
case .save_as; defer_action_save_as(editor.buffer_id);
case .move_current_file; defer_action_move (editor.buffer_id);
Expand Down Expand Up @@ -1770,6 +1770,15 @@ select_all_occurrences :: (using editor: *Editor, buffer: Buffer, search_str :=
return editor.search_whole_words;
}

save :: (editor: Editor, editor_id: s64) {
buffer_id := editor.buffer_id;

// When hitting save while in the color preview panel, save the target config file instead
if is_color_preview_panel(editor_id) then buffer_id = color_preview_get_target_buffer_id();

save(buffer_id);
}

save :: (buffer_id: s64) {
buffer := *open_buffers[buffer_id];
if buffer.readonly || buffer.internal return;
Expand Down
4 changes: 4 additions & 0 deletions src/widgets/color_preview.jai
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ is_color_preview_panel :: inline (editor_id: s64) -> bool {
return editor_id == panel_editor_id;
}

color_preview_get_target_buffer_id :: inline () -> s64 {
return target_buffer_id;
}

color_preview_lose_focus :: () {
// Sometimes we might want to make the previously active editor active, e.g. when deciding on new buffer placement
if editors.active != editors.left && editors.active != editors.right && editors.left >= 0 && editors.right >= 0 {
Expand Down

0 comments on commit 360576b

Please sign in to comment.