mirror of
https://gitlab.com/c3d/db48x.git
synced 2024-09-29 05:36:58 +02:00
ui: Add history menu entries to EditMenu
Add commands to the `EditMenu` to go both up and down in the history, and to enter the interactive stack. Switch to the `EditMenu` automatically when we use the history command. Fixes: #1028 Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
This commit is contained in:
parent
912487ac0f
commit
4febac76d7
10 changed files with 51 additions and 6 deletions
Binary file not shown.
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.8 KiB |
Binary file not shown.
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.3 KiB |
Binary file not shown.
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.8 KiB |
|
@ -41,6 +41,7 @@
|
|||
#include "renderer.h"
|
||||
#include "runtime.h"
|
||||
#include "settings.h"
|
||||
#include "stack.h"
|
||||
#include "symbol.h"
|
||||
#include "sysmenu.h"
|
||||
#include "tag.h"
|
||||
|
@ -1035,3 +1036,34 @@ COMMAND_BODY(EditorFlip)
|
|||
{
|
||||
return ui.editor_selection_flip() ? OK : ERROR;
|
||||
}
|
||||
|
||||
|
||||
COMMAND_BODY(EditorHistory)
|
||||
// ----------------------------------------------------------------------------
|
||||
// Select the last history entry in the editor
|
||||
// ----------------------------------------------------------------------------
|
||||
{
|
||||
ui.editor_history();
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
COMMAND_BODY(EditorHistoryBack)
|
||||
// ----------------------------------------------------------------------------
|
||||
// Select the previous history entry in the editor
|
||||
// ----------------------------------------------------------------------------
|
||||
{
|
||||
ui.editor_history(true);
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
COMMAND_BODY(StackEditor)
|
||||
// ----------------------------------------------------------------------------
|
||||
// Enter the interactive stack
|
||||
// ----------------------------------------------------------------------------
|
||||
{
|
||||
if (!Stack.interactive)
|
||||
Stack.interactive = 1;
|
||||
return OK;
|
||||
}
|
||||
|
|
|
@ -171,5 +171,8 @@ COMMAND_DECLARE(EditorSearch,-1); // Begin search
|
|||
COMMAND_DECLARE(EditorReplace,-1); // Replace search with cursor
|
||||
COMMAND_DECLARE(EditorClear,-1); // Clear editor
|
||||
COMMAND_DECLARE(EditorFlip,-1); // Flip cursor and selection
|
||||
COMMAND_DECLARE(EditorHistory,-1); // Find last entry in editor history
|
||||
COMMAND_DECLARE(EditorHistoryBack,-1); // Find previous entry in editor history
|
||||
COMMAND_DECLARE(StackEditor,-1); // Enter interactive stack
|
||||
|
||||
#endif // COMMAND_H
|
||||
|
|
|
@ -1276,6 +1276,10 @@ CMD(EditorSearch)
|
|||
CMD(EditorReplace)
|
||||
CMD(EditorClear)
|
||||
CMD(EditorFlip)
|
||||
CMD(EditorHistory)
|
||||
CMD(EditorHistoryBack)
|
||||
CMD(StackEditor)
|
||||
|
||||
|
||||
// ============================================================================
|
||||
//
|
||||
|
|
|
@ -1162,7 +1162,11 @@ MENU(EditMenu,
|
|||
"→|", ID_EditorEnd,
|
||||
"Replace", ID_EditorReplace,
|
||||
"Copy", ID_EditorCopy,
|
||||
"Clear", ID_EditorClear);
|
||||
"Clear", ID_EditorClear,
|
||||
|
||||
"Stack", ID_StackEditor,
|
||||
"Hist↑", ID_EditorHistory,
|
||||
"Hist↓", ID_EditorHistoryBack);
|
||||
|
||||
MENU(IntegrationMenu,
|
||||
// ----------------------------------------------------------------------------
|
||||
|
|
|
@ -163,7 +163,7 @@ void tests::run(bool onlyCurrent)
|
|||
if (onlyCurrent)
|
||||
{
|
||||
here().begin("Current");
|
||||
random_number_generation();
|
||||
editor_operations();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -862,7 +862,7 @@ void tests::editor_operations()
|
|||
.image_noheader("istack-9b", 0, 1000);
|
||||
step("Interactive stack Edit")
|
||||
.test(UP, F1, UP, F1, DOWN, F1)
|
||||
.image_noheader("istack-10")
|
||||
.image_noheader("istack-10", 0, 1000)
|
||||
.editor("666 555 666 ")
|
||||
.test(CLEAR, EXIT);
|
||||
}
|
||||
|
|
|
@ -445,7 +445,7 @@ text_p user_interface::editor_save(text_r &editor, bool rewinding)
|
|||
}
|
||||
|
||||
|
||||
void user_interface::editor_history()
|
||||
void user_interface::editor_history(bool back)
|
||||
// ----------------------------------------------------------------------------
|
||||
// Restore editor buffer from history
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -453,7 +453,8 @@ void user_interface::editor_history()
|
|||
editor_save(true);
|
||||
for (uint h = 0; h < HISTORY; h++)
|
||||
{
|
||||
cmdHistoryIndex = (cmdHistoryIndex + HISTORY - 1) % HISTORY;
|
||||
uint next = cmdHistoryIndex + (back ? 1 : HISTORY - 1);
|
||||
cmdHistoryIndex = next % HISTORY;
|
||||
if (history[cmdHistoryIndex])
|
||||
{
|
||||
size_t sz = 0;
|
||||
|
@ -467,6 +468,7 @@ void user_interface::editor_history()
|
|||
break;
|
||||
}
|
||||
}
|
||||
menu::static_object(menu::ID_EditMenu)->evaluate();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -168,7 +168,7 @@ struct user_interface
|
|||
void clear_editor();
|
||||
text_p editor_save(text_r ed, bool rewinding = false);
|
||||
text_p editor_save(bool rewinding = false);
|
||||
void editor_history();
|
||||
void editor_history(bool back = false);
|
||||
bool editor_select();
|
||||
bool editor_word_left();
|
||||
bool editor_word_right();
|
||||
|
|
Loading…
Reference in a new issue