Skip to content

Add zoom shortcuts and an option to comment lines by clicking their number - #4249

Open
deepsidhu1313 wants to merge 2 commits into
sqlitebrowser:masterfrom
deepsidhu1313:feature/sql-editor-ux
Open

deepsidhu1313 wants to merge 2 commits into
sqlitebrowser:masterfrom
deepsidhu1313:feature/sql-editor-ux

Conversation

@deepsidhu1313

Copy link
Copy Markdown
Contributor

Two independent commits.

  1. More zoom shortcuts for the code editors (refs zoom in execute sql window #2929). QScintilla only binds Ctrl+Plus and Ctrl+Minus to zoom, so on layouts where + needs Shift (for example a US keyboard) zooming in did not work, Ctrl+= was not bound, and there was no way to reset the zoom. This adds Ctrl+Shift++ and Ctrl+= to zoom in and Ctrl+Shift+0 to reset the zoom, as widget-shortcuts in ExtendedScintilla (so the Edit Cell editor gets them too). Ctrl+0 is deliberately not used because it is Reset Window Layout. Tests in the new test-sql-editor (4 of 12 failed before).
  2. New preference "Toggle comment on line number click" (editor/toggle_comment_on_margin_click, Preferences > SQL, off by default). When enabled, clicking a line number in the SQL editor toggles the -- comment of that line, like the existing Ctrl+/ action. It is a preference because clicking a line number currently selects the line (drag, Shift+click and Ctrl+click build on that). Read-only editors and the Edit Cell editor keep the old behaviour. The range logic of toggleBlockComment is now the public slot SqlTextEdit::toggleLineComments(), covered by 37 test cases including real mouse clicks in the margin.

Refs #2929, #2996

QScintilla only binds Ctrl++ and Ctrl+- to zooming. On keyboards where the
plus sign needs Shift (Ctrl+Shift+= on a US layout, Cmd+Shift+; on a
Japanese Mac) the Shift modifier is sent along, so that binding never
matches and there was no keyboard way to zoom in at all. Ctrl+= did not
work either. There was also no way back to the normal size except opening
a new tab.

Add Ctrl+Shift++ and Ctrl+= as additional ways to zoom in, and
Ctrl+Shift+0 to reset the zoom. Ctrl+0 would be the usual shortcut for the
latter, but it is already taken by View > Window Layout > Reset Window
Layout in the main window, so the editors must not claim it.

The shortcuts are widget shortcuts of ExtendedScintilla, so they also
apply to the Edit Cell editor and don't clash between multiple editors.

Add test-sql-editor, which creates editors offscreen and checks the
zoom keys by sending key events, including that Ctrl+0 is left alone.

Related: sqlitebrowser#2929
…itors

Commenting out a line to switch between alternative conditions is a common
thing to do while writing queries. That works with Ctrl+/ or the toolbar
button, but a click on the line number would be quicker.

By default such a click selects the whole line, and the same goes for
dragging over several line numbers or Shift+click to extend the selection,
so changing that for everybody would take something away. Add the option
"Toggle comment on line number click" to the SQL tab of the preferences,
which is off by default, so nothing changes unless it is turned on.

A sensitive margin takes over all clicks on it, so the margin is only made
sensitive in editors where there is something to comment. Read-only
editors, like the SQL log, and the editor for the content of a cell, which
does not hold SQL code, keep selecting the line.

To do this, split the part of toggleBlockComment that works on a range of
lines into toggleLineComments, which toggleBlockComment still uses after
working out the lines from the selection.

Add tests to test-sql-editor for toggleBlockComment, toggleLineComments
and clicking on the line numbers.

Related: sqlitebrowser#2996

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

2 participants