Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ctrl-Z and Ctrl-Y, while in Scribble mode, actually act on main editor #3558

Open
JohnCC330 opened this issue Sep 15, 2023 · 9 comments
Open

Comments

@JohnCC330
Copy link

Just now, while editing a couple of notes, I used Ctrl-Z to recover a recent delete and was surprised that it took action on the main source code I was working on.

Thinking it was a focus issue I tried a few time clicking on the scribble text before actually doing the Ctrl-Z, same result though - the Ctrl-Z acted on the main editor. Then I tried with Ctrl-Y to redo, and that too acted on the main editor. Normal cut/copy/paste actions are local to scribble though.

I submit that, if implementing the Undo and Redo functions in the scribble box is too complicated, at least disabling those functions in the main editor would be wise. After all, the scribble box could be covering the code editor's window.

Geany: 1.38
GTK+ v3.24.34 and GLib v2.74.3
Slackware64 15.0

@elextr
Copy link
Member

elextr commented Sep 16, 2023

Scribble is a standard GTK text edit widget. Geany uses GTK3, but Undo and Redo are not implemented until GTK4 AFAICT so the keypresses are ignored by the widget. Unless consumed by a widget, keypresses are passed to the top level window which is the Geany application which then applies them. Editing keys like undo and redo only apply to the main editor, so thats where they are applied.

Some keycodes (eg navigation actions) should work no matter which pane has the focus, so fixing it is not simply a matter of disallowing all keypresses in non-editing panes. "Somebody" has to devise and implement a method of discriminating which actions should work where.

@JohnCC330
Copy link
Author

Oh, I see... I don't know much about the inner workings Geany - though I'd love to find the time to know more. I suspect Geany uses GtkSource for the 'normal' editor? Maybe replace the Scribble Gtk editor by a stripped-down GtkSource instance (disabling linenumbers, syntax coloring, line markers etc)? Would that be a solution?

@elextr
Copy link
Member

elextr commented Sep 17, 2023

Geany uses Scintilla not GTKSource view.

@ntrel
Copy link
Member

ntrel commented Sep 18, 2023

Geany's keybindings do not handle undo/redo unless a document has focus, it defers them. The problem is the menu accelerators override Geany's keybindings. For the menu callbacks I tried requiring a document to have focus, but that breaks the popup menu undo/redo items.

@elextr
Copy link
Member

elextr commented Sep 18, 2023

Then the test for preconditions should be in the callbacks for all that are mentioned in Glade, or they all should be removed from glade?

@ntrel
Copy link
Member

ntrel commented Sep 18, 2023

When the popup menu callbacks are called a document never has focus.

@elextr
Copy link
Member

elextr commented Sep 18, 2023

Sure, so the popup menu needs different callbacks with different precondition tests to the callbacks that can be activated by GTK that bypass Geanys keybindings.

@ntrel
Copy link
Member

ntrel commented Sep 18, 2023

Well how do you check what the focus will be once the popup menu is no longer showing?

@elextr
Copy link
Member

elextr commented Sep 18, 2023

The popup menu undo/redo has to have a different callback that does not check focus, its only precondition is a valid document, the popup can only be activated by right click on the edit pane so the focus check is not needed.

The callbacks for the GTK actions need to check both focus and valid document, so they need to be different callbacks.

The callback called by Geany keybindings doesn't need to check anything since cb_func_editor_action() has already done both, although it won't hurt to use either one of the others.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants