Commit graph

644 commits

Author SHA1 Message Date
MJacred
55cdaebdf9 Fix cursor after last character in line counting as a character outside of the viewing area
The cursor column can be after the last_visible_char index and still be visible.
2023-09-05 19:36:17 +02:00
lawnjelly
8814578ceb MultiRect - Fix flushing in TextEdit
The FontDrawer used in TextEdit was previously not being flushed before drawing auto-completion boxes. This was causing rendering artifacts.
This PR also increases the backward compatibility of the MultiRect OFF mode, by forcing a flush after each character.
2023-07-15 14:02:21 +01:00
lawnjelly
57306bf0e3 Fix TextEdit color_region_cache bug
Due to a single error, _is_line_in_region was previously iterating over the color highlighting for the entire document repeatedly for each line in the script.

This is now fixed, which should make the editor much faster with large scripts.
2023-03-11 16:18:29 +00:00
Rémi Verschelde
1426cd3b3a
One Copyright Update to rule them all
As many open source projects have started doing it, we're removing the
current year from the copyright notice, so that we don't need to bump
it every year.

It seems like only the first year of publication is technically
relevant for copyright notices, and even that seems to be something
that many companies stopped listing altogether (in a version controlled
codebase, the commits are a much better source of date of publication
than a hardcoded copyright statement).

We also now list Godot Engine contributors first as we're collectively
the current maintainers of the project, and we clarify that the
"exclusive" copyright of the co-founders covers the timespan before
opensourcing (their further contributions are included as part of Godot
Engine contributors).

Also fixed "cf." Frenchism - it's meant as "refer to / see".

Backported from #70885.
2023-01-10 15:26:54 +01:00
Nong Van Tinh
ffbaa7fff0 Enhance null checking for input event 2022-11-27 15:01:34 +07:00
Michael Alexsander
7a682236df Stop centering clicked suggestions in the autocomplete popup 2022-11-13 09:17:05 -03:00
Abhinav Chennubhotla
8acc25578e Fix code folding icon color not matching defined color
Cherrypick of #58457 in master

Caused by reusing icons from the main editor in the code editor. These
icons were converted based on the main editor theme and not the code
editor theme.

    - Create new icons for use specifically in the code editor
    - Add these icons to the exceptions when converting dark theme icons
    to light theme automatically
    - Change the default value of the code folding color to match previous
    color
    - Code folding icon is now pure white by default to correctly match
    the color defined in settings
2022-09-06 21:50:33 +05:30
Rémi Verschelde
f30a2c1292
Merge pull request #63113 from snailrhymer/3.x-folding-comment-fix 2022-08-08 15:54:57 +02:00
SnailRhymer
efed5087ae Change code folding behavior to include terminal indented comments
Previously, when folding a block of code that finished with an indented comment (i.e. one indented as much as or more than the starting indent of the code), that comment would be left out of the fold. Change the behavior to include such comments, but still leave less-indented ones out.
2022-07-17 17:38:51 +01:00
Brian Semrau
ce24b48e50 Add support for multiple virtual keyboard types 2022-07-07 14:22:28 -04:00
ConteZero
a13b3028a2 Add an option to drag'n'drop selected text in TextEdit
(cherry picked from commit 5d56efcaa4)
2022-06-30 19:23:01 +02:00
kobewi
053fdb8872 Disable scroll when dragging at edges of TextEdit 2022-06-14 23:36:54 +02:00
Rémi Verschelde
8182a754d2
Merge pull request #59827 from ConteZero/fix_right_menu 2022-04-14 21:29:57 +02:00
Haoyu Qiu
19a0145742 Fix undo history for function name autocompletion 2022-04-14 14:37:31 +08:00
Haoyu Qiu
1d476d7737 Consider chained operation when selecting text in TextEdit::undo()
(cherry picked from commit 8cefbfcf43)
2022-04-13 11:43:49 +02:00
Rémi Verschelde
21c3048397 Add missing argument names in bindings 2022-04-04 12:56:59 +02:00
ConteZero
57b616fb21 Fix Right-Click clearing selection 2022-04-03 10:18:12 +02:00
ConteZero
2ff0735329 Added primary clipboard for Linux 2022-03-14 15:28:36 +01:00
ConteZero
0ffacff998 [3.x] Add option to make selection unique 2022-03-14 09:48:09 +01:00
Rémi Verschelde
08c3e00b95
Merge pull request #55355 from ConteZero/drag_and_drop_3.x 2022-03-14 08:43:22 +01:00
ConteZero
4167e98088 Add drag and drop to TextEdit, LineEdit, RichTextLabel 2022-03-14 08:15:25 +01:00
Haoyu Qiu
db9d426798 Remove extra separator when TextEdit is read only and unselectable
(cherry picked from commit 933211cb0c)
2022-03-10 16:19:30 +01:00
Wilson E. Alvarez
c37be0f31b
Expose TextEdit get_visible_rows() and get_total_visible_rows() to GDScript 2022-03-08 22:32:22 -05:00
Rémi Verschelde
a627cdafc5
Update copyright statements to 2022
Happy new year to the wonderful Godot community!
2022-01-13 15:54:13 +01:00
kobewi
9f7f7377dd
Set max value of inactive TextEdit scrolls to 0
(cherry picked from commit 892d93759c)
2022-01-12 17:36:41 +01:00
Yuri Sizov
ba747e2a26 Add methods to get position from column and line in TextEdit 2021-11-29 00:06:16 +03:00
Haoyu Qiu
eb6f74855f Allow toggle TextEdit bookmark gutter 2021-11-21 21:34:30 +08:00
Rémi Verschelde
42d385b312
clang-format: Disable alignment of operands, too unreliable
Sets `AlignOperands` to `DontAlign`.

`clang-format` developers seem to mostly care about space-based indentation and
every other version of clang-format breaks the bad mismatch of tabs and spaces
that it seems to use for operand alignment. So it's better without, so that it
respects our two-tabs `ContinuationIndentWidth`.
2021-10-28 13:23:38 +02:00
Haoyu Qiu
52a840b9c9 Fix crash when tooltip_request_func object is freed 2021-10-06 15:33:31 +08:00
PouleyKetchoupp
ab55c33c20 Fix TextEdit cursor update when adding or deleting text
Updating the viewport while setting the line index before the column is
set could wrongly cause the text to be scrolled down.
2021-09-16 09:14:22 -07:00
Hugo Locurcio
85ebe8e3f6
Add visual feedback when hovering or dragging the code minimap grabber
This makes it more obvious that the minimap grabber can be dragged
to scroll.
2021-09-04 02:25:44 +02:00
Rémi Verschelde
a67eaa67b0
Merge pull request #51732 from codecat/fix-caret-selection-3.x
Move cursor to edge of selection when moving caret left/right
2021-08-18 20:12:19 +02:00
Melissa Geels
6bf6d18ee1 Move cursor to edge of selection when moving caret left/right
This is to mimic the behavior of many third party text editors.
The reasons it's not doing it when moving by word is due to that
behavior being mostly the same on other editors.

This was backported to 3.x from pull request #51502.
2021-08-18 14:28:57 +02:00
Haoyu Qiu
5f316aa216 Improve Undo/Redo menu items
* Make Undo/Redo menu items disabled when clicking it does nothing.
    * Context menu of `TextEdit`
    * Context menu of `LineEdit`
    * Editor's Scene menu
    * Script editor's Edit menu and context menu  (for Script and Text)
* Make editor undo/redo log messages translatable.
* Mark `UndoRedo`'s `has_{un,re}do()` methods as `const`.
* Expose `TextEdit`'s `has_{un,re}do()` to scripts since `{un,re}do()` are already available.
2021-08-18 00:46:51 +08:00
Melissa Geels
ac40f5bb75
Triple click in text editor now uses last mouse position for validity
Previously, you would be able to double click a word, followed by
single-clicking another word on the same line, which would select the
entire line. Now, it will only select the whole line if the mouse
position has remained the same after the double click. This mimicks the
behavior in most third party text editors.

Fixes #51312.

(cherry picked from commit 408401a642)
2021-08-12 16:43:22 +02:00
Rémi Verschelde
32f5bee985
LineEdit: Respect max_length by truncating text to append
When appending text (either via `set_text()` or by pasting from clipboard),
if the input would make the `LineEdit` exceed its configured `max_length`,
the input text is truncated to fit. The discard part is passed as a parameter
in the `text_change_rejected` signal.

Fixes #33321.
Fixes #41278.

Also cleaned up unimplemented `max_chars` property in `TextEdit`.

Co-authored-by: Tony-Goat <70238376+Tony-Goat@users.noreply.github.com>
(cherry picked from commit 9a1ce8e6c3)
2021-07-13 10:20:02 +02:00
Marcel Admiraal
7e03bd1671 Remove duplicate WARN_PRINTS macro 2021-06-18 12:57:59 +01:00
Hugo Locurcio
f36c90b82f
Add a soft line length guideline to the script editor
The default value is 80. The hard line length guideline's default column
has been moved to 100 to account for the new soft line length guideline.

It can be disabled by setting its value to the same column as the
hard line length guideline.
2021-06-16 06:00:02 +02:00
Hugo Locurcio
2e6a4aea99
Allow more items in automatic width calculation for TextEdit completion
Calculating the width for 100 items takes a millisecond in
a debug build on an i7-6700K. It's likely that the editor can remain
smooth even with 1,000 items, especially in a release build.
2021-06-08 16:21:39 +02:00
Hugo Locurcio
a38b447413
Highlight control flow keywords with a different color
This makes them easier to distinguish from other keywords.
2021-05-25 00:31:39 +02:00
Hugo Locurcio
333dfb96da
Scroll faster when holding Alt in TextEdit (and script editor)
This feature is inspired by a similar feature found in
Visual Studio Code.

(cherry picked from commit cf1cf6c6eb)
2021-05-18 11:58:09 +02:00
kobewi
cb5870dd4a
Display arrow cursor if text is not editable
(cherry picked from commit c3967c80ab)
2021-05-09 17:50:06 +02:00
Rémi Verschelde
140350d767
Style: Enforce braces around if blocks and loops
Using clang-tidy's `readability-braces-around-statements`.
https://clang.llvm.org/extra/clang-tidy/checks/readability-braces-around-statements.html
2021-05-05 15:02:01 +02:00
Rémi Verschelde
a828398655
Style: Replaces uses of 0/NULL by nullptr (C++11)
Using clang-tidy's `modernize-use-nullptr`.
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
2021-05-04 16:30:23 +02:00
Rémi Verschelde
b5e1e05ef2
Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocks 2021-05-04 14:45:16 +02:00
Rémi Verschelde
3d15f04668
Style: clang-format: Disable AllowShortIfStatementsOnASingleLine 2021-05-04 14:45:15 +02:00
Koala
d08666f999
Fix indent left line selection
(cherry picked from commit 2c64008718)
2021-05-04 12:47:36 +02:00
floppyhammer
4628ab2a15
ImproveCompletionPanelPositionInShaderEditor
(cherry picked from commit e927a9fef0)
2021-04-29 11:35:52 +02:00
PouleyKetchoupp
ac9e5d9c60
Fix TextEdit autoscroll with wrapped lines
Index to find the last line wrap index was off by one, which prevented the first wrapped line to trigger autoscroll.

(cherry picked from commit 121030940c)
2021-02-16 14:27:38 +01:00
PouleyKetchoupp
018008ce81 TextEdit respects content margin from StyleBox
Backport from PR #45858 on master.
2021-02-15 10:47:38 -07:00