Commit Graph

44 Commits

Author SHA1 Message Date
mgrojo
33266b7707 Improvement and fixes to the un/comment block feature
The last line of the selection is considered part of the block, even if it
is not completely selected. At the same time, we have to discard this last
line of the selection, if the index is 0, since in that case there is no
actual selected character in the line.

Additionally all the steps in the replacement are considered a single
action for history, so that user can undo the change in a single undo
action.

See issue #1614
2018-11-21 21:13:40 +01:00
mgrojo
70534e2ae3 Adapt to QScintilla behaviour with Windows line terminator
QScintilla is returning strings with text(line) with line terminator and
they are also counted by lineLength, so the Windows version has to
substract one for setSelection.

This solves various problems resulting in characters being removed at the
beginning of lines when commenting or uncommenting blocks of code with
Windows line terminators.
2018-11-20 00:19:42 +01:00
mgrojo
2c4ff851b1 Comment/uncomment code command for the SQL editor
A new command is added for commenting or uncommenting SQL code (depending
of the state of the first line of the block).

It is bound to "Ctrl+/" as used by many IDEs ("Ctrl+-" is more standard as
Zoom out). Unusual Scintilla binding for "Ctrl+/" is removed for avoiding
interference.

If there is no selection, the current line is un/commented.

See issue #1614
2018-11-18 01:44:59 +01:00
Martin Kleusberg
35a5b43ce0 Move SQL object classes into a separate directory 2018-11-08 16:20:33 +01:00
mgrojo
d0b5ff10a7 Completion of qualified table names
This adds the schema names to the possible completions and adds support
for cascading completion of schema.table.field.

See related issue #1433
2018-09-05 23:03:47 +02:00
Justin Clift
9a76537aa4 Fix Win compile failure
* Revert c861f1b9d9, as it's breaking
  the MSVC 2013 compile.
* Move the new OUTPUT_NAME line slightly, so it's recognised
2018-07-13 00:46:14 +01:00
Martin Kleusberg
c861f1b9d9 Silence a clang warning 2018-07-10 20:39:50 +02:00
mgrojo
2803e163e0 New tests for the new standard quoting and for the other quoting styles
Modified some tests for taking into account the new standard quoting and
added some more for testing the quoting configuration and for correct
parsing of different quoting styles.

Default branch in escapeIdentifier() for trying to avoid warning.
2018-06-23 17:57:18 +02:00
mgrojo
5c7238d3d0 Preference for quoting identifier mechanism
A new option is added to the SQL tab in Preferences for choosing which
quoting characters must be used by the application when it inserts an
identifier in SQL code. The three options supported by SQLite are
available.

Default quoting characters have been changed from `Grave accents` to
"Double quotes" (SQL standard).

This options also affect the highlighting of double quoted strings: when
the SQL standard is selected, double quoted expressions are highlighted as
identifiers, otherwise as literal strings.
2018-06-18 17:49:12 +02:00
mgrojo
a0e0fc98ae XML mode for the cell editor
The new editor mode shares the same Scintilla widget as the JSON mode.
The JsonTextEdit class has been generalised. Future modes supported by
Scintilla could be added with the current pattern. As a consequence, the
EditMode is not always equal to the current stacked widget.

Some code in EditDialog has been refactored, so it is easier to understand
and modified with so many modes. textNullSet has been replaced by the use
of dataType as Null.

SVG is promoted to a new recognised data type, so it can be edited in the
XML mode.

The XML data is formatted and validated following the pattern established
by the JSON mode.

New modules are needed by the XML mode: the Qt XML module and some new
Scintilla files required by the HTML/XML lexer.

The indent_compact was incorrectly named in Setting::getDefaultValue.

See issue #1253.
2017-12-23 22:19:17 +01:00
mgrojo
8896ecca40 Refactoring and find/replace dialog in the JSON editor.
SQL and JSON text editor classes have been refactored. A new parent class
for both editors have been added for the common logic implementable without
depending on the specific lexer.

The only visible effect of this change should be that the JSON editor
(issue #1173) now has the same find/replace dialog as the SQL editor.

This prepares for the implementation of the XML editor (issue #1253).
2017-12-16 00:09:47 +01:00
mgrojo
de260d32c5 Always open the find/replace dialog with Ctrl+H and option in context menu
The shortcut is constrained to the Widget context so it does not conflict
with other SqlTextEdit widgets in the application. Now all SqlTextEdit
widgets are able of opening the dialog with the same shortcut and behave
in the same way (do not block the parent window).

The find/replace dialog can now be discovered by the user in the context
menu at the SqlTextEdit widgets.
2017-12-15 21:15:39 +01:00
mgrojo
c9bf5f87cb Find/Replace dialog improvements
Find/Replace dialog does not block the main window.

Dialog reused, so checks changed by user are preserved.

The selection of the last occurrence in Find All and Replace All
is cleared, so all the occurrences have the same appearance.
2017-11-26 01:19:33 +01:00
mgrojo
82665e3f09 Find/Replace dialog for SQL editors and logs
A classic Find/Replace dialog including all the options provided
by the QScintilla editor. Additionally a "Replace All" and a
Find All" button are implemented. This complements issue #191

New shortcut in main window for opening the find/replace dialog
connected to the focused widget. Standard for Replace is Ctrl+H.
Consequently the shortcut for Copy with Headers is changed to
Ctrl+Shift+C (see issue #1058).

For SQL text widgets not embedded in the main window, the standard
shortcut cannot be enabled, otherwise it conflicts with the main
window. Therefore the shortcut Ctrl+Shift+H is enabled for all the
SQL widgets as fallback. A better solution would be desirable.
2017-11-25 21:39:41 +01:00
mgr
d8aeae1a6f Avoid displaying an unnecessary horizontal scrollbar in SQL editor widgets
The following scroll width functionalities are added to QScintilla:
setScrollWidth, getScrollWidth, setScrollWidthTracking and
getScrollWidthTracking.

This allows setting a lower value for the initial scroll width (default is
2000 pixels).  Consequently, the horizontal scroll is only visible if the
SQL lines become bigger than window width.

The scroll width, though, is never reduced by Scintilla for performance
reasons.

See this for explanation:
https://github.com/jacobslusser/ScintillaNET/issues/216

And see this for a possible implementation of a fully adjusted scroll
width with fixed-width fonts:
https://groups.google.com/forum/#!topic/scintilla-interest/ly8u7mVDgyQ
2017-11-12 14:32:14 +01:00
Martin Kleusberg
ee32b3e4e1 Use nullptr where possible 2017-10-30 21:20:02 +01:00
Martin Kleusberg
f1194d845e Rename all the settings accessor functions
Rename the settings accessor functions from Settings::getSettingsValue()
(and similar) to Settings::getValue() (and similar). The 'Settings' bit
seems a bit redundant and costs a lot of screen space.
2017-03-20 23:16:52 +01:00
Vladislav Tronko
3a06395f88 Divide PreferencesDialog in two classes
This forces PreferencesDialog to serve only for UI needs.
Plus, this opens the door for adding another class for shortcut
management without pain.
2016-09-03 22:30:55 +03:00
Martin Kleusberg
63e8540de4 Add option to disable auto completion in the SQL editor
See issue #537.
2016-04-23 21:13:48 +02:00
Martin Kleusberg
0fed833e55 Move a connect in SqlTextEdit to avoid unnecessary slot calls
Move the connect for updating the line number area width from the reload
settings method to the constructor to make sure it's only called once.
Otherwise there would be more and more unnecessary connections made
whenever the settings are reloaded.
2015-12-22 18:19:55 +01:00
m
3b5053c0a0 set default color to black 2015-06-23 03:09:03 +08:00
m
9af70c042e fix line numbers position recalculation 2015-06-23 02:57:26 +08:00
m
84ba7d8a17 fix: UTF-8 characters (when out of comments or quotes) are drawn with different font 2015-06-23 02:46:09 +08:00
Martin Kleusberg
5e0d1ba34e Add option for disabling the SQL error indicators
See issue #302.
2015-06-22 12:38:50 +02:00
Martin Kleusberg
2715d75f01 Add option for setting SQL editor font
See issue #299.
2015-05-06 19:54:02 +02:00
Martin Kleusberg
7e3d9cd0a3 sqltextedit: Enable UTF-8
See issue #282.
2015-05-01 13:38:17 +02:00
Martin Kleusberg
cf412a211d qscintilla: Reload settings properly after they have changed 2015-04-23 19:52:07 +02:00
Martin Kleusberg
94846336df qscintilla: Finetune auto completion
Only start auto completion after a three letter threshold.

Only take words for auto completion from the API word list, not from the
current document.
2015-04-23 19:52:07 +02:00
Martin Kleusberg
649b1790e5 Mark syntax errors in Execute SQL tab
If a syntax error is reported by SQLite during execution in the Execute
SQL tab of the main window try to locate the problematic SQL statement
and highlight it using a red squiggling line.
2015-04-23 19:52:06 +02:00
Martin Kleusberg
6fed5ec7c2 qscintilla: Enable code folding 2015-04-23 19:52:06 +02:00
Martin Kleusberg
cde2393539 Use QScintilla instead of own implementation of a code editor
This is a first rough implementation of QScintilla support as SQL text
editor.

It should work mostly and build fine with qmake as well as cmake. The
new code supports all the features of the old one plus adding a few
subtle improvements. The main point of this, however, is reducing the
code we have to maintain and making it easier to add new features to the
editor.
2015-04-23 19:51:54 +02:00
schdub
2bfeb03b7e Suggestion: 'Tab' indents multiline selection in SQL editor 2015-04-15 11:13:59 +03:00
Peinthor Rene
d8cdcbd572 add an option for the tabsize in the sql editor (default 4) 2015-04-10 09:21:01 +02:00
Peinthor Rene
31915c4061 compat: change to compile under qt4.7 2014-11-28 19:49:15 +01:00
Martin Kleusberg
f257f9248e Move syntax highlighter objects to SqlTextEdit class
Any SqlTextEdit object has its SQL syntax highlighter anyway, so it
makes sense to move the syntax highlighter object inside the text edit
class instead of maintining somewhere else. This hopefully makes the
code a bit easier to maintain.
2014-11-09 12:20:02 +01:00
Peinthor Rene
5a9b1672a7 qt5: include QMimeData 2014-02-13 23:52:35 +01:00
Martin Kleusberg
7a81189d50 PreferencesDialog: New settings for font size of SQL editor and log
Add two new settings to allow changing the font size inside the SQL log
and the SQL editor.

Increase the default font size from 8 to 9 - better a bit too big on
some systems than too small on others.

Also do some restructuring in the MainWindow to avoid duplicate code to
reload settings.
2013-06-07 20:57:58 +02:00
Martin Kleusberg
929bb9026d SqlTextEdit: Support opening files by drag and drop
When dropping a file on the editor widget try to open and read it.
2013-05-17 15:05:21 +02:00
Martin Kleusberg
5b9d5cc40b Remove some debug messages. Change some error messages..
Remove some useless debug messages, e.g. because they just print an SQL
string which you can see in the SQL log window anyway.

Change some "critical" errors messages to just warning. No sense in
printing a critical error message when the program can handle the
problem by itself.
2013-05-08 22:03:04 +02:00
Martin Kleusberg
432180ec03 SqlTextEdit: Show line numbers
Show line numbers in the SqlTextEdit widget. This code is based on the
CodeEditor example from the Qt documentation.
2013-05-07 20:16:17 +02:00
Martin Kleusberg
0de7ff8564 SqlTextEdit: Highlight current line 2013-05-04 21:10:50 +02:00
Martin Kleusberg
57b44b891d Add auto completion in SQL editor again 2013-05-03 11:47:53 +02:00
Peinthor Rene
340af96deb fix additional space if we have no completionPrefix 2013-03-29 14:54:25 +01:00
Peinthor Rene
ba34c1e986 add basic autocompletion for tables and fields to the sql text input
this does only work on full table names, NOT on aliases
for a full auto completion to work we need a sqlite parser
2013-02-14 17:32:54 +01:00