You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/action_scripts.md
+11-24Lines changed: 11 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,55 +1,42 @@
1
1
# Action Scripts in Text Forge
2
2
3
-
Action Scripts are a way to separate and manage possible actions in the Text Forge, helping them keep dozens of
4
-
different capabilities separately and safely and add new capabilities in the shortest time.
3
+
Action Scripts are a way to separate and manage possible actions in the Text Forge, helping them keep dozens of different capabilities separately and safely and add new capabilities in the shortest time.
5
4
6
5
## Design goals
7
6
8
-
- Modularity: Each action script is an independent unit with a specified output and input, almost all Action Scripts are
9
-
detachable from the editor without making an error in its performance
7
+
- Modularity: Each action script is an independent unit with a specified output and input, almost all Action Scripts are detachable from the editor without making an error in its performance
10
8
- Development: Developers can design new capabilities through simple Action Script APIs
11
-
- Accessibility: Action Scripts are easily accessible through code, command palette, and shortcuts
9
+
- Accessibility: Action Scripts are easily accessible through menus, code, command palette, and shortcuts
12
10
13
11
## Structure
14
12
15
-
An action script must extend `ActionScript` or `MultiActionScript` class or another class that extends one of these
16
-
classes. Each action script should be stored in `action_scripts/` directory and have snake_case file name of an option
17
-
english name in menus. For example if we have a `Save As...` option in `File` menu, editor will load `action_scripts/save_as.gd`
18
-
as its action script (will remove dots) and otherwise this action script will not be loaded.
13
+
An action script must extend `ActionScript` or `MultiActionScript` class or another class that extends one of these classes. Each action script should be stored in `action_scripts/` directory and have snake_case file name of an option english name in menus. For example if we have a `Save As...` option in `File` menu, editor will load `action_scripts/save_as.gd` as its action script (will remove dots) and otherwise this action script will not be loaded.
19
14
20
-
Also, action scripts can have a shortcut in `shortcuts/` directory with same name. This file should be a `Shortcut`
21
-
resource (`.tres` file) with a `InputEventKey` as shortcut. Loading shortcut will be done by `ActionScript` class.
15
+
Also, action scripts can have a shortcut in `data/shortcuts.tres` resource file with same name as key. Value should be a `InputEventKey` resource. Loading shortcut will be done by `ShortcutMap` and `ActionScript` class.
22
16
23
-
All loaded action script will be children nodes of `Scripts` node in core, you can use `Global.get_scripts_node()` to
24
-
access to it.
17
+
All loaded action script will be children nodes of `Scripts` node in core, you can use `Global.get_scripts_node()` to access to it.
25
18
26
-
Each action script should override base class `Virtual` functions, you can see them in docstrings. There is a list of
27
-
virtual functions of regular `ActionScript`:
19
+
Each action script should override base class `Virtual` functions, you can see them in docstrings. There is a list of virtual functions of regular `ActionScript`:
28
20
-`_initialize()`: For action script initializing
29
21
-`_run_action()`: Main part of action script
30
22
31
23
## Features
32
24
33
25
### Access to menu option
34
26
35
-
Each action script have an item in menus, this item is accessible with `menu` and `index` property of action script.
36
-
For checkbox and radio-checkbox options, editor will handle checking state itself.
27
+
Each action script have an item in menus, this item is accessible with `menu` and `index` property of action script. For checkbox and radio-checkbox options, editor will handle checking state itself.
37
28
38
29
### Automated shortcut loading
39
30
40
-
`ActionScript` and `MultiActionScript` class will load shortcuts from `shortcuts/` directory and call required functions
41
-
in shortcut pressing.
31
+
`ActionScript` and `MultiActionScript` class will load shortcuts from `data/shortcuts.tres` resource and call required functions in shortcut pressing.
42
32
43
33
### Define commands
44
34
45
-
An action script will define itself as a command for command palette, so command palettes can list action scripts for
46
-
user and run them based on selections. If an action script has shortcut, it will add that shortcut in commands database
47
-
so users can see shortcuts in command palette.
35
+
An action script will define itself as a command for command palette, so command palettes can list action scripts for user and run them based on selections. If an action script has shortcut, it will add that shortcut in commands database so users can see shortcuts in command palette.
48
36
49
37
### Automated enabling / disabling
50
38
51
-
`requires_file` and `requires_saved_file` properties can be used to make smarter action scripts, must action scripts
52
-
just available when there is an opened file, so `requires_file == true` can disable them other times.
39
+
The `requires_file` and `requires_saved_file` properties can make action scripts smarter. Most action scripts should only be available when a file is open, so setting `requires_file = true` disables them otherwise automatically.
Copy file name to clipboardExpand all lines: docs/build.md
+1-3Lines changed: 1 addition & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,9 +2,7 @@
2
2
3
3
!!! Note
4
4
5
-
This page currently haven't complete guide for build, there is just manual for open project source in Godot.
6
-
To build editor from source use [this guide](https://docs.godotengine.org/en/stable/tutorials/export/exporting_projects.html)
7
-
from official Godot docs.
5
+
This page currently haven't complete guide for build, there is just manual for open project source in Godot. To build editor from source use [this guide](https://docs.godotengine.org/en/stable/tutorials/export/exporting_projects.html) from official Godot docs.
Copy file name to clipboardExpand all lines: docs/create_action_scripts.md
+14-32Lines changed: 14 additions & 32 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,42 +7,33 @@
7
7
8
8
There is a checklist before selecting action script as your solution:
9
9
10
-
- I need add an action that user can trigger it?
10
+
- I need to add an action that a user can trigger?
11
11
12
-
If yes, It **can** be action script. Users can use menus, shortcuts, and commands to trigger action scripts. You can
13
-
use other ways to add triggerable actions, but action scripts are a standard way, specially for a lot of actions.
12
+
If yes, it **can** be an action script. Users can trigger action scripts via menus, shortcuts, and commands. You can add triggerable actions in other ways, but action scripts are the standard approach for many actions.
14
13
15
-
- I need add a new option in menus?
14
+
- I need to add a new option in menus?
16
15
17
-
If yes, It**must** be action script. Everything in menus is action script.
16
+
If yes, it**must** be an action script. Everything in menus is implemented via an action script.
18
17
19
-
- I need add a new command?
18
+
- I need to add a new command?
20
19
21
-
If yes, It **may** be action script. Action scripts have internal command defining system, and you can use them from
22
-
command palette, but you can define commands from everywhere in Text Forge, in modes, panels, extensions, action scripts, etc.
20
+
If yes, it **may** be an action script. Action scripts have an internal command-definition system, and you can use them from the command palette, but commands can also be defined in modes, panels, extensions, action scripts, and other parts of Text Forge.
23
21
24
22
## Regular action scripts
25
23
26
-
There is some different types of action scripts based on their base classes, `ActionScript` class designed for regular
27
-
action scripts and can handle a lot of tasks.
24
+
There are different types of action scripts based on their base classes. The `ActionScript` class is designed for regular action scripts and can handle many tasks.
28
25
29
-
To add new action script you should make sure there is an item in menus for that action script, you can use `data/main_ui.ini`
30
-
to add new options (or menus), to understand about structure of this file you can see [here](https://text-forge.github.io/docs/data_driven_ui/#menus).
31
-
After select your option create a script in `action_scripts/` directory with same name (but in snake_case), it this case
32
-
we will create **Copy Path** action script that will copy file path of opened file in clipboard, so we will create
33
-
`action_scripts/copy_path.gd` and use this script as start point:
26
+
To add a new action script, first ensure there is a matching menu item. You can add options (or menus) in `data/main_ui.ini`; see the [Data-driven UI menu structure](https://text-forge.github.io/docs/data_driven_ui/#menus). After selecting your option, create a script in the `action_scripts/` directory with the same name in snake_case. In this example, we will create a **Copy Path** action script to copy the currently opened file path to the clipboard, so we create `action_scripts/copy_path.gd` and start with:
34
27
35
28
```gdscript
36
29
extends ActionScript
37
30
```
38
31
39
-
Just that! Run project and see option is enabled. But there is no action for now, so we have 3 steps to complete our
40
-
action script:
32
+
That’s it for setup. Run the project and confirm the option is enabled. There is no behavior yet, so complete these three steps:
41
33
42
34
### Add initializing
43
35
44
-
We needn't any special initializing for this action script, all we need is disabling it when there is no opened file,
45
-
there is ready-made feature for this:
36
+
We don't need special initialization for this action script. We only need to disable when no file exists or when the file hasn’t been saved yet; `ActionScript` already provides this:
46
37
47
38
```gdscript
48
39
extends ActionScript
@@ -52,15 +43,11 @@ func _initialize() -> void:
52
43
requires_saved_file = true
53
44
```
54
45
55
-
With this function `ActionScript` class will disable option when there isn't saved file, it means when you create a new
56
-
file this option will keep disabled until that file saved, because before that there is no file path. Otherwise, (for
57
-
example when user uses Open) option will be enabled.
46
+
With this function, `ActionScript` disables the option when no saved file exists. For example, after creating a new file, the option stays disabled until the file is saved (because no file path exists yet). When opening an existing file, the option is enabled.
58
47
59
48
### Add main action
60
49
61
-
We have initialized action script, but there is no action, so let's add it. To do this we use `_run_action()` function,
62
-
this function will be called when user clicks in option in menus, presses shortcut (we will add shortcut later) or uses
63
-
command palette. So we can complete our action script with this function:
50
+
We have initialized the action script, but it still has no behavior, so let’s add it. We do this with `_run_action()`, which runs when the user clicks the menu option, presses the shortcut (added later), or uses the command palette.
Almost done! We have completed action script, and you can try it now in witch way you want.
63
+
Almost done! The action script logic is complete, and you can try it now. Next, we'll add a shortcut.
77
64
78
65
### Add shortcut
79
66
80
-
There is an easy way for adding shortcuts to action scripts, so let's see how we can do it. To have shortcut we need a
81
-
`Shortcut` resource stored in `shortcuts/` directory, so go to Godot's FileSystem dock and use RMB on `res://shortcuts/`,
82
-
then click on Create New > Resource... and create a `Shortcut` resource and save it as `copy_path.tres`. Shortcut will
83
-
be opened in Inspector, click on `Events` and add new element, then create a new `InputEventKey` in that element. Use
84
-
`Configure` button and set your shortcut, then run project and try it. You can open command palette (Ctrl+P) and type `copy path`
85
-
to see shortcut.
67
+
To add a shortcut, open `data/shortcuts.tres` from Godot’s FileSystem dock and add a new `String: InputEventKey` pair (for example, key `copy_path`). Click **Configure** to set the keybinding, run the project, then open the command palette (`Ctrl+P`) and type `copy path` to confirm the shortcut appears.
Text Forge uses a data driven system for important parts UI, including menu options and texts. This architecture make
4
-
a dynamic UI and clean translation system.
3
+
Text Forge uses a data-driven system for important parts of the UI, including menu options and texts. This architecture makes a dynamic UI and a clean translation system.
5
4
6
5
## Menus
7
6
8
-
All data related to menus stored in `data/main_ui.ini`, this file have a section for menus and a key for each menu (or
9
-
submenu). Each item is an array of dictionaries and each dictionary has the following structure:
7
+
All data related to menus is stored in `data/main_ui.ini`. This file has a section for menus and a key for each menu (or submenu). Each item is an array of dictionaries and each dictionary has the following structure:
10
8
11
-
-`"code"` - a unique integer for connect this option to its action script, its value can be any non-negative int bug must
12
-
be unique.
9
+
-`"code"` - a unique integer used to connect this option to its action script; its value can be any non-negative int but must be unique.
13
10
-`"text"` - english text of option, it will be used for add name to action scripts and call them based on names.
14
11
-`"key"` - linked translation key in translation file, menu loader will use it to set item text.
15
12
-`"type"` - an integer related to option type, this key can have these values:
@@ -19,12 +16,4 @@ submenu). Each item is an array of dictionaries and each dictionary has the foll
19
16
-`2` - Checkbox
20
17
-`3` - Radio Checkbox
21
18
22
-
Each key must have `_menu` or `_submenu` suffix, items with `_menu` suffix will load in main menu and items with `_submenu`
23
-
suffix will load as submenus based on texts, for example `Convert Case` submenu in `Edit` menu will load from `convert_case_submenu`
24
-
key (snake case of submenu text with suffix).
25
-
26
-
## Panels
27
-
28
-
To handle panels, we have `data/panels/` folder. Here, each panel have a folder with icon, configuration file, and scene.
29
-
In config file, we have place of panel (`R`, `L`, or `B`). Panel manager will load panels from here based on configuration
30
-
file and stored files.
19
+
Each key must have a `_menu` or `_submenu` suffix. Items with the `_menu` suffix will load in the main menu, and items with the `_submenu` suffix will load as submenus based on their texts. For example, the `Convert Case` submenu in the `Edit` menu will load from the `convert_case_submenu` key (snake case of submenu text with suffix).
Copy file name to clipboardExpand all lines: docs/index.md
+3-6Lines changed: 3 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,8 @@
1
1
# Text Forge Documentation
2
2
3
-
Welcome to the official documentation of **Text Forge** — a modular, extensible, and language-agnostic text editor
4
-
built with user empowerment at its core.
3
+
Welcome to the official documentation of **Text Forge** — a modular, extensible, and language-agnostic text editor built with user empowerment at its core.
5
4
6
-
Whether you're a developer, programmer, or data manager, Text Forge gives you the tools to shape your editing experience
7
-
exactly the way you want.
5
+
Whether you're a developer, programmer, or data manager, Text Forge gives you the tools to shape your editing experience exactly the way you want.
8
6
9
7
---
10
8
@@ -47,8 +45,7 @@ New to Text Forge? Start here: [Introduction to Text Forge](introduction.md)
47
45
48
46
## 🛠️ Contribute
49
47
50
-
Text Forge is open source and community-driven. Join us on [GitHub](https://github.com/text-forge/text-forge), share
51
-
your ideas, and help shape the future of the editor.
48
+
Text Forge is open source and community-driven. Join us on [GitHub](https://github.com/text-forge/text-forge), share your ideas, and help shape the future of the editor.
52
49
53
50
Note that here is for documentations, so if you want to contribute in main project, please see [here](https://github.com/text-forge/text-forge)
0 commit comments