Commit Graph

330 Commits (cb1569345a6f17da08241e645ab03cb2e1b78d2f)

Author SHA1 Message Date
jeffVenancius 97c2133548 Add an option to show a TextEdit caret when editable is disabled
Update doc/classes/TextEdit.xml
2023-04-07 22:27:01 +07:00
Yuri Sizov db2f99cdc0 Implement theme item cache in TextEdit and CodeEdit 2023-04-03 18:01:10 +07:00
George L. Albany f3313ba4cd
Remove methods in header removed in c7eb814
c7eb814 missed these methods in the RichTextLabel's header
Remove set_override_selected_font_color from rich_text_label.h
Remove is_override_selected_font_color from rich_text_label.h
c7eb814 missed these methods in the TextEdit's header
Remove set_override_selected_font_color from text_edit.h
Remove is_override_selected_font_color from text_edit.h
2023-03-15 21:13:38 +07:00
Danil Alexeev af8bf6f1d0
Fix `LineEdit` and `TextEdit` context menus not customizable 2023-01-27 11:14:54 +07:00
Rémi Verschelde 5b1df48c6c
Convert en_GB spelling to en_US with codespell 2023-01-23 11:02:20 +07:00
Rémi Verschelde d95794ec8a
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".
2023-01-05 13:25:55 +07:00
Alfred Reinold Baudisch a862583d05 Unified shortcut to clear carets and selections
Refactors`ui_text_remove_secondary_carets` from https://github.com/godotengine/godot/pull/68089 as `ui_text_clear_carets_and_selection`, with extra behaviour:

- If there's only one active caret active with a selection, clears the selection.
- In case there's more than one caret active, removes the secondary carets and clears selections.

With this change, `TextEdit` then imitates the behaviour of VSCode for clearing carets and selections.
2022-11-02 18:23:24 +07:00
Alfred Reinold Baudisch fcff978763 Shortcut and Bind to Remove Secondary Carets
Adds the bind `ui_text_remove_secondary_carets` to TextEdit, with ESC as the default shortcut.

When the bind is performed, if the TextEdit has multiple carets, `remove_secondary_carets` is called and secondary carets are removed.

This is useful when multiple selects are performed with `add_select_for_next_occurrence` #67644 or when multiple multiple carets are manually added, then it's possible to go back to a single caret with a shortcut.

Closes #67991
2022-10-31 17:44:47 +07:00
Rémi Verschelde 8b1a42cd47
Merge pull request #67888 from KoBeWi/overridead
Remove `override_selected_font_color` property
2022-10-31 10:59:07 +07:00
Rémi Verschelde 273410ba5a
Merge pull request #67139 from PucklaMotzer09/insert_caret_at_carets
Add Caret Insert Below and Above shortcuts to TextEdit
2022-10-31 10:32:07 +07:00
kobewi c7eb814ede Remove override_selected_font_color property 2022-10-26 12:59:18 +07:00
Alfred Reinold Baudisch 7d15ecc3af Add Selection and Caret for Next Occurrence of Selection
Adds the bind `add_selection_for_next_occurrence` to TextEdit, with CTRL+D as the default shortcut.

When the bind is performed, ff a selection is currently active with the last caret in text fields, searches for the next occurrence of the selection, adds a caret and selects the next occurrence.

If no selection is currently active with the last caret in text fields, selects the word currently under the caret.

The action can be performed sequentially for all occurrences of the selection of the last caret and for all existing carets. The viewport is adjusted to the latest newly added caret.

The bind and the behaviour is similar to VS Code's "Add Selection to Next Find Match" and JetBrains' "Add Selection for Next Occurrence". It takes advantage of the multi-caret API.

The default shortcut for `select_word_under_caret` has been changed to ALT+G, in order to give priority to CTRL+D for `add_selection_for_next_occurrence` to better align with popular IDEs and editors.
2022-10-21 08:26:53 +07:00
PucklaMotzer09 e5354cacd0 Add Caret Insert Below and Above shortcuts to TextEdit 2022-10-18 10:38:53 +07:00
microaeris 215fe852b8 Getters for TextEdit scrollbars 2022-10-07 23:16:04 +07:00
Paulb23 4a9d4e3dad Add mutliple Caret support to TextEdit 2022-10-05 17:19:26 +07:00
Paulb23 7dd3857f7e Move selecion into caret 2022-10-03 14:09:27 +07:00
Micky 6dbd283ae5 Rename every instance of `caret_blink_speed` to `caret_blink_interval`
It's been changed in EditorSettings, LineEdit, TextEdit.

Affects setters and getters, and passed parameters, too.
2022-09-06 18:37:17 +07:00
风青山 e561c68256 Add some codes, returnes directly if the value is not changed.
Avoid executing the following value-changed logics if the value does not really change.
2022-08-23 23:25:22 +07:00
bruvzg 344ba0ffaf
Refactor Font configuration and import UI, and Font resources. 2022-07-06 14:12:36 +07:00
kobewi 41f6e7c50e Allow to disable TextEdit vertical scroll 2022-07-04 15:02:15 +07:00
ConteZero 5d56efcaa4 Add an option to drag'n'drop selected text in TextEdit 2022-06-26 15:22:02 +07:00
reduz 746dddc067 Replace most uses of Map by HashMap
* Map is unnecessary and inefficient in almost every case.
* Replaced by the new HashMap.
* Renamed Map to RBMap and Set to RBSet for cases that still make sense
  (order matters) but use is discouraged.

There were very few cases where replacing by HashMap was undesired because
keeping the key order was intended.
I tried to keep those (as RBMap) as much as possible, but might have missed
some. Review appreciated!
2022-05-16 10:37:48 +07:00
bruvzg 081b6b8053
Add ALT NUM+ {hex code} character input support for LineEdit, TextEdit and CodeEdit. 2022-05-13 09:33:24 +07:00
bruvzg be611c1c05
Implement Label3D node.
Add "generate_mipmap" font import option.
Add some missing features to the Sprite3D.
Move BiDi override code from Control to TextServer.
Add functions to access TextServer font cache textures.
Add MSDF related flags and shader to the standard material.
Change standard material cache to use HashMap instead of Vector.
2022-04-22 12:08:46 +07:00
bruvzg d1207a0504
[Input] Add extra `shortcut_input` input processing step to process Unicode character input with Alt / Ctrl modifiers, after processing of shortcuts. 2022-04-05 13:46:45 +07:00
Rémi Verschelde f8ab79e68a Zero initialize all pointer class and struct members
This prevents the pitfall of UB when checking if they have been
assigned something valid by comparing to nullptr.
2022-04-04 19:49:50 +07:00
Hugo Locurcio a06f82ca4d
Add optional constructor arguments to more Control nodes
This can be used to make editor code more compact.
However, as of writing, these constructor arguments cannot be used
from the scripting API.

This was already provided for Label and CheckBox, but it was missing
for other Control nodes where it made sense to provide a default value.
2022-03-04 09:48:41 +07:00
bruvzg 215bede6ff
[TextServer] Add function to change font, font size, and OpenType features without invalidating line break points, justification points, or recreating shaped text buffer. 2022-02-02 11:20:44 +07:00
Paulb23 1cd1df5dc3 Move placeholder color to theme item 2022-01-30 17:56:23 +07:00
Paulb23 09212ba151 Add Placeholder to TextEdit 2022-01-23 20:19:36 +07:00
Paulb23 f43f68f605 Convert TextEdit callbacks to Callable 2022-01-19 17:26:22 +07:00
bruvzg c89c515ccf
[TextServer] Improve ligature cursor handling.
Fix mid-grapheme hit test.
Fix OpenType features property handling, add default features override option.
Enable mid-grapheme cursor by default.
2022-01-09 19:03:48 +07:00
Rémi Verschelde fe52458154
Update copyright statements to 2022
Happy new year to the wonderful Godot community!
2022-01-03 21:27:34 +07:00
luz paz a124f1effe Fix various typos
Found via ` codespell -q 3 -S ./thirdparty,*.po,./DONORS.md -L ackward,ang,ans,ba,beng,cas,childs,childrens,dof,doubleclick,expct,fave,findn,gird,hist,inout,leapyear,lod,nd,numer,ois,ony,paket,seeked,sinc,switchs,te,uint,varn`
Update editor/import/resource_importer_layered_texture.cpp

Co-authored-by: Raul Santos <raulsntos@gmail.com>
Update doc/classes/TileSetScenesCollectionSource.xml

Co-authored-by: Raul Santos <raulsntos@gmail.com>
Update scene/gui/graph_edit.cpp

Co-authored-by: Raul Santos <raulsntos@gmail.com>
Update scene/resources/animation.cpp

Co-authored-by: Raul Santos <raulsntos@gmail.com>
Update scene/resources/animation.cpp

Co-authored-by: Raul Santos <raulsntos@gmail.com>
Update scene/resources/animation.cpp

Co-authored-by: Raul Santos <raulsntos@gmail.com>
Update scene/gui/rich_text_label.cpp

Co-authored-by: Raul Santos <raulsntos@gmail.com>
Revert previously committed change
2022-01-02 01:03:58 +07:00
Paulb23 bfe2cd2f03 Optimise TextEdit base operations 2021-12-08 18:23:07 +07:00
ConteZero 0699941f07 Add drag and drop to TextEdit 2021-12-02 22:00:07 +07:00
Lightning_A e078f970db Rename `remove()` to `remove_at()` when removing by index 2021-11-23 18:58:57 +07:00
Yuri Sizov e85e6ec7fc Add methods to get position from column and line in TextEdit 2021-11-22 15:13:13 +07:00
Paulb23 2a302f7097 Fix TextEdit mouse interactions when the last line is hidden 2021-11-17 18:29:19 +07:00
Aaron Franke 3c0fdcc8ac
Use "enum class" for input enums 2021-11-12 15:37:54 +07:00
ConteZero fbee4efa5f Add option to make selection unique 2021-10-27 19:45:52 +07:00
ConteZero 838c9d37b4 Added primary clipboard for Linux 2021-10-18 14:01:06 +07:00
Rémi Verschelde 5ae569560d
Fix missing argument names in bindings
While at it, tweak some boolean setters to use `p_enabled` for the bool.

Also renames `draw_minimap()` to `set_draw_minimap()`.
2021-10-09 00:20:10 +07:00
Haoyu Qiu 45e943f4fe Fix crash when tooltip_request_func object is freed 2021-10-06 15:00:31 +07:00
bruvzg 0c0b5c84b0 Implement TextServer GDExtension interface, remove TextServer GDNative interface. 2021-10-01 15:13:29 +07:00
Eric M e0f8410d16 Improved breakpoint gutter for CodeEdit.
Added preview of breakpoint placement on hover. Added override of icon for the Editor to use an SVG so it is no longer blurry.
2021-09-30 22:15:47 +07:00
Rémi Verschelde d039f4af14
Merge pull request #52185 from Paulb23/nested-complex-ops
Allow nested complex ops in TextEdit
2021-09-14 11:57:42 +07:00
Rémi Verschelde 70ba366743
Merge pull request #50375 from Paulb23/code_edit_unit_tests 2021-09-13 21:51:20 +07:00
Gilles Roudière 321ee7bda1
Merge pull request #52106 from Paulb23/text-edit-optimisation
Optimise TextEdit get line height and width
2021-09-08 14:04:41 +07:00
Hugo Locurcio c8949f21e7
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:22 +07:00
Paulb23 ce064348fa Add CodeEdit breakpoint unit tests 2021-09-01 16:46:04 +07:00
Paulb23 c5d7ae7920 Allow nested complex ops in TextEdit 2021-08-28 12:49:55 +07:00
Paulb23 de009cb5ae Optimise TextEdit get height and width 2021-08-28 11:27:23 +07:00
reduz 5cecdfa8af Entirely removes BIND_VMETHOD in favor of GDVIRTUAL
* `_gui_input`, `_input`, `_unhandled_input` and `_unhandled_key_input` are now regular C++ virutal functions.
* Everything else converted to GDVIRTUAL
* BIND_VMETHOD is gone, always use the new syntax from now on.

Creating `_gui_input` method and using the binder to register events will no longer work, simply override the virtual function now.
2021-08-23 08:10:13 +07:00
reduz 3682978aee Replace BIND_VMETHOD by new GDVIRTUAL syntax
* New syntax is type safe.
* New syntax allows for type safe virtuals in native extensions.
* New syntax permits extremely fast calling.

Note: Everything was replaced where possible except for `_gui_input` `_input` and `_unhandled_input`.
These will require API rework on a separate PR as they work different than the rest of the functions.

Added a new method flag METHOD_FLAG_OBJECT_CORE, used internally. Allows to not dump the core virtuals like `_notification` to the json API, since each language will implement those as it is best fits.
2021-08-22 08:23:58 +07:00
Haoyu Qiu 16c2d4ef22 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-17 21:11:10 +07:00
Paulb23 273374957b Only update TextEdit text cache when dirty 2021-08-13 17:47:53 +07:00
Paulb23 ae4dcb8918 Cleanup and bind remaing methods in TextEdit 2021-08-12 11:43:35 +07:00
Paulb23 0a32a6907b Cleanup and expose viewport / scrolling methods 2021-08-12 09:29:58 +07:00
Paulb23 7dbb0f3233 Rename readonly to editable 2021-08-12 09:29:58 +07:00
Paulb23 b799e5583a Rename insert mode to overtype mode 2021-08-12 09:29:58 +07:00
Paulb23 b700011314 Protect internal CodeEdit --> TextEdit API 2021-08-12 09:29:58 +07:00
Paulb23 9ec3e7f3d7 Cleanup TextEdit selection methods 2021-08-12 09:29:56 +07:00
Paulb23 7e70f9e0b9 Expose and cleanup TextEdit line wrap API 2021-08-12 09:29:16 +07:00
Paulb23 d5dcaee4c5 Cleanup and rename caret operations 2021-08-12 09:29:13 +07:00
Paulb23 e60900a353 Make TextEdit cut, copy and paste overridable 2021-08-12 09:27:10 +07:00
Paulb23 abbf14e7f5 Remove dead code from TextEdit 2021-08-12 09:27:10 +07:00
Melissa Geels 408401a642 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.
2021-08-11 21:49:26 +07:00
Paulb23 dd5a37f556 Move symbol lookup into CodeEdit 2021-08-01 12:06:33 +07:00
Paulb23 8f900ac178 Move line length guidelines into CodeEdit 2021-08-01 12:06:33 +07:00
Paulb23 d1a1ad127e Move brace matching into CodeEdit 2021-08-01 12:06:33 +07:00
Paulb23 12f0053555 Move auto brace completion to CodeEdit 2021-08-01 12:06:33 +07:00
Rémi Verschelde a0bc2f359d
Merge pull request #50588 from bruvzg/menu_gen
Optimize LineEdit and TextEdit menu item generation.
2021-07-19 22:56:53 +07:00
Yuri Roubinsky 1597045b09 Fixed typos in `TextEdit::GutterType` enum 2021-07-19 11:18:54 +07:00
bruvzg 1ac7a126f1 Optimize LineEdit and TextEdit menu item generation. 2021-07-19 08:19:09 +07:00
reduz a3fb76cd45 Create many types of popups on demand
* LineEdit popups created on demand.
* TextEdit popups created on demand.
* SpinSlider popups created on demand.
* ResourcePicker popups created on demand.

Improves editor responsiveness.
2021-07-17 10:57:14 +07:00
Rémi Verschelde 9a1ce8e6c3
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>
2021-07-06 18:03:03 +07:00
Paulb23 1a0cfc219b Move indent management to CodeEdit 2021-06-20 20:00:54 +07:00
Lightning_A e28fd07b2b Rename `instance()`->`instantiate()` when it's a verb 2021-06-19 20:49:18 +07:00
Paulb23 ab49ea032c Remove redundant keywords from TextEdit 2021-06-19 13:56:54 +07:00
Paulb23 5c618dd03d Move code folding into CodeEdit and hide line hiding API 2021-06-01 17:07:01 +07:00
Paulb23 c1b9971ad8 Move and expose Code Hint in CodeEdit 2021-06-01 15:38:45 +07:00
Paulb23 1c16673798 Move and expose AutoComplete in CodeEdit 2021-06-01 15:38:45 +07:00
Hugo Locurcio 80f4e407b2
Add a keyboard shortcut to select the word under cursor in TextEdit
This also acts as a general-purpose "deselect" shortcut since pressing
it a second time will deselect text.

This is available both in the script editor and in TextEdit fields
in use, both in the editor and projects.

The Duplicate Line script editor shortcut was moved to Ctrl + Shift + D
since it conflicts with the new shortcut (Ctrl + D). The rationale for
doing so is that Duplicate Line is a less commonly used action, and
its behavior can be replicated by copying and pasting the current line
anyway. (With no selection active, the whole line will be copied.)
2021-05-22 23:47:43 +07:00
Paulb23 00e10a842f Add custom background line colour to TextEdit and remove marked lines 2021-05-22 14:41:55 +07:00
Eric M 49714b0963 Removed hardcoded shortcuts from /scene and converted to input actions
This removes hardcoded actions from things like LineEdit and TextEdit.

Previously, things like copy, paste, etc were all hardcoded to Ctrl+C, Ctrl+V, etc. They could not be changed. This allows the possibility of them being changed, by making them use the action map. This has the added benefit of greatly simplifying the input handling logic in those controls. The logic which was previously in a huge and hard to follow switch statement has been extracted to individual methods.
2021-02-18 16:22:51 +07:00
bruvzg d78336c65e
[CTL] Add missing font outline drawing routines and theme constants. 2021-02-14 14:11:44 +07:00
PouleyKetchoupp 121030940c 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.
2021-02-12 13:44:46 +07:00
Rafał Mikrut 7961a1dea3 Initialize class variables with default values in scene/ [2/2] 2021-02-09 18:24:36 +07:00
Marcel Admiraal 8eb39f4e8b Change themes *_color_* to *_*_color
Changed:
font_color_accel -> font_accelerator_color
font_color_bg -> font_unselected_color
font_color_disabled -> font_disabled_color
font_color_fg -> font_selected_color
font_color_hover -> font_hover_color
font_color_hover_pressed -> font_hover_pressed_color
font_color_pressed -> font_pressed_color
font_color_readonly -> font_readonly_color
font_color_selected -> font_selected_color
font_color_shadow -> font_shadow_color
font_color_uneditable -> font_uneditable_color
icon_color_disabled -> icon_disabled_color
icon_color_hover -> icon_hover_color
icon_color_hover_pressed -> icon_hover_pressed_color
icon_color_normal -> icon_normal_color
icon_color_pressed -> icon_pressed_color

Also includes:
font_outline_modulate -> font_outline_color
tab_fg -> tab_selected
tab_bg -> tab_unselected
2021-01-24 06:28:49 +07:00
Rémi Verschelde b5334d14f7
Update copyright statements to 2021
Happy new year to the wonderful Godot community!

2020 has been a tough year for most of us personally, but a good year for
Godot development nonetheless with a huge amount of work done towards Godot
4.0 and great improvements backported to the long-lived 3.2 branch.

We've had close to 400 contributors to engine code this year, authoring near
7,000 commit! (And that's only for the `master` branch and for the engine code,
there's a lot more when counting docs, demos and other first-party repos.)

Here's to a great year 2021 for all Godot users 🎆
2021-01-01 20:19:21 +07:00
Yuri Roubinsky 2d4ef1c193 Fixed mouse scrolling in TextEdit's 2020-12-11 12:51:10 +07:00
bruvzg 3be31c4960
[Complex Text Layouts] Refactor TextEdit and CodeEdit controls. 2020-11-26 14:25:50 +07:00
bruvzg 99666de00f
[Complex Text Layouts] Refactor Font class, default themes and controls to use Text Server interface.
Implement interface mirroring.
Add TextLine and TextParagraph classes.
Handle UTF-16 input on macOS and Windows.
2020-11-26 14:25:48 +07:00
Devin Curry b9c35af15d ScriptEditor: Fix line number gutter drag select
Fixes issue #42722
2020-10-25 12:13:54 +07:00
Marcel Admiraal 1bb65b2618 Remove bit fields and use fixed width integers instead. 2020-09-11 11:02:00 +07:00
Paulb23 33ab9cd621 Move safe line color into editor 2020-09-10 20:35:28 +07:00
Paulb23 d18a90b8f0 Move ConnectionGutter to editor code_editor 2020-09-10 20:35:28 +07:00
Paulb23 7829fdc1d0 Add folding gutter to code_edit 2020-09-10 20:35:28 +07:00
Paulb23 4d7df24d46 Add main_gutter (breakpoints, bookmarks, execution lines) to code_edit 2020-09-10 20:35:28 +07:00