Skip to content

Commit 2b769af

Browse files
Update docs to: EditorAPI Refactor (#71)
1 parent bdfa319 commit 2b769af

3 files changed

Lines changed: 143 additions & 13 deletions

File tree

docs/create_action_scripts.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,21 @@
33
!!! Note
44
Reading [Action Scripts Guide](action_scripts.md) is recommended before creating actions scripts.
55

6+
## When I should use action scripts?
7+
8+
There is a checklist before selecting action script as your solution:
9+
- I need add an action that user can trigger it?
10+
11+
If yes, It **can** be action script. Users can use menus, shortcuts, and commands to trigger action scripts. You can
12+
use other ways to add triggerable actions, but action scripts are a standard way, specially for a lot of actions.
13+
- I need add a new option in menus?
14+
15+
If yes, It **must** be action script. Everything in menus is action script.
16+
- I need add a new command?
17+
18+
If yes, It **may** be action script. Action scripts have internal command defining system, and you can use them from
19+
command palette, but you can define commands from everywhere in Text Forge, in modes, panels, extensions, action scripts, etc.
20+
621
## Regular action scripts
722

823
There is some different types of action scripts based on their base classes, `ActionScript` class designed for regular

docs/mode_development.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Mode Development
2+
3+
Text Forge have a powerful and feature rich API to add support for any language in the fastest way. We provide modes to
4+
help developers and users work with any file just with plug one module. In this page, we will show a standard way for
5+
mode development to you and best practices.
6+
7+
!!! Note
8+
9+
Reading [Modes Guide](modes.md) is highly recommended before develop modes, please read that document before this.
10+
11+
## Text Forge Mode API
12+
13+
To handle external modules we need an API, so we provide **Text Forge Mode API** (TFM API in short) as modes' connection
14+
way. TFM is a feature packed API for any mode, so it have a lot of features.
15+
16+
!!! Note
17+
18+
We have multiple versions of TFM API, and each editor version just supports one TFM API version (but a TFM API
19+
version can be shared between a lot of versions). Latest TFM API version is 2.0 currently and this version supports
20+
Text Forge 0.1-stable and newer versions.
21+
22+
To use all features of modes, you should know about its API, so we will explain it a little more. TFM API consists of
23+
two parts, the first part is in EditorAPI that connect editor to modes, the second part is the `TextForgeMode` class,
24+
which keeps this connection standard and provides some ready-made features.
25+
26+
You will work with **TextForgeMode** to complete your mode, this will define your mode and EditorAPI will do the rest.
27+
So a mode have a very important part, its script. This script extends TextForgeMode class and customizes behaviors to
28+
provide your mode logic.
29+
30+
## Make your first mode with template
31+
32+
We provide a mode template to help mode developers, specially for first time testing. You can find it [here](https://github.com/text-forge/mode-template),
33+
you can download, clone or fork it to have a simple initialization, you can find guides in template.
34+
35+
## Useful examples
36+
37+
You can see our official modes like [Web Mode Kit](https://github.com/text-forge/web-mode-kit) and
38+
[GDScript Mode](https://github.com/text-forge/gdscript-mode) to find solutions for most important challenges.

docs/modes.md

Lines changed: 90 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,102 @@
11
# Modes In Text Forge
22

33
Text Forge is lightweight and language agnostic, So there is no default dependence on any language. But how you can work
4-
with any file type and have special features like syntax highlighter?
5-
This is where the mods come in, a mode is a special module designed to adapt to certain types of files and languages,
6-
you can enter the mods and leave the rest to the editor, everything is automatically managed to you can work with files.
4+
with any file type and have special features like syntax highlighters and linters?
5+
This is where the modes come in, a mode is a special module designed to adapt to certain types of files and languages,
6+
you can install the modes and leave the rest to the editor, everything is automatically managed to you can work with files.
77

8-
## Packages
8+
## Mode Features
9+
10+
There is a list of all standard available features for modes, some mode can have more features with custom solutions and
11+
some modes can haven't one or more feature is this list. In short, you can find optional features with *optional* tag,
12+
features of a mode depends on its developers:
13+
14+
- **Save & Load**
15+
16+
Modes can encode and decode files, with this customizable encoding system you can work with a lot of files, even
17+
with files they aren't text files!
18+
19+
- **Syntax Highlighter** _optional_
20+
21+
We provide both simple and advanced syntax highlighting ability to mode developers, including simple highlighters to
22+
fully customized highlighters. Highlighters currently can just one theme and highlighter colors are completely mode-driven.
23+
24+
- **Advanced Commenting Handling** _optional_
25+
26+
We have easy API for defining comment delimiters and logics. Editor provides line folding and more based on these
27+
information.
28+
29+
- **Mode Panels** _optional_
30+
31+
Modes can have their panels, so you can configure a mode visually based on mode features.
32+
33+
- **Auto Format** & **Auto Indent** _optional_
34+
35+
We provide auto format and auto indent options separately, you can run these options to clean your files with modes'
36+
power. You can use these features from command palette, menus, or with shortcuts; These features are available in
37+
`Edit > Indention > Auto Indent` and `Format > Auto Format`, to see shortcuts, type `Auto Indent` or `Auto Format`
38+
in command palette.
39+
40+
- **Initialization Lifecycle**
41+
42+
We have high standards about your files safety, so a mode will load completely before working with your file, or if
43+
initialization fails, we will cancel task.
44+
45+
- **Code Completion** _optional_
46+
47+
We provide a mode-based code completion to you with complete API for mode developers, so features and smartness of
48+
this feature is based on your current mode.
49+
50+
- **Preview Rendering** _optional_
51+
52+
Modes can generate live preview based on your file, and you can see this preview in **Preview Panel** in right side of editor.
53+
54+
- **File Outline** _optional_
55+
56+
You can navigate between sections in your file or review them in **Outline Panel** in left side of editor, this is a
57+
mode-driven feature too, so this section features are based on your mode.
58+
59+
- **Linting** _optional_
60+
61+
We currently haven't supported LSP & DAP client ([feature tracking issue↗️](https://github.com/text-forge/text-forge/issues/88))
62+
for complete language based features, but we have a simple mode-driven linting feature, and you can see your file
63+
problems in **Problems Panel** in bottom of editor, in this panel all error and warnings provided by mode will show
64+
, and you can navigate between them by clicking on an item.
65+
66+
!!! Note
67+
68+
A lot of above features were added in TFM API v2.0, you can read more about this API [here](mode_development.md#text-forge-mode-api).
69+
We provide a lot of these features as optional features, because a mode can work with simple text or non-code files,
70+
so there is a lot of optional but basic features.
71+
72+
!!! Note
73+
74+
After TFM API v2.0, we use buffer based save and load instead of file based behavior, this new system have safer
75+
error handling and modes can no longer see the file paths in your system directly when you save / load a file.
76+
77+
!!! Important
78+
79+
Modes are unlimited moduless! So you should be sure about a mode before installing it, otherwise modes can get access
80+
to your files content, for completely safe experience download official and community modes in [mode library](https://github.com/text-forge/mode-library).
81+
82+
!!! Note
83+
84+
Auto Format and Auto Indent are triggerable actions, there is an **Auto Indention** toggleable feature in `Format`
85+
menu that will change indention automatically when you create new line.
86+
87+
## Mode Kits
988

1089
In programming word, there is a lot of types of programmers, for example you can be a web developer, in this case you
11-
need to work with some files as your basic workflow, such as `.html`, `.css`, and `.js`. So we provide packages, a
12-
package is a collection from related modes create for a special type of users.
90+
need to work with some files as your basic workflow, such as `.html`, `.css`, and `.js`. So we provide mode kits, a
91+
mode kit is a collection from related modes create for a special type of users.
1392

14-
## Installing Modes & Packages
93+
## Installing Modes & Mode Kits
1594

16-
You can find modes and packages from official library or community created collections, there is some useful link about modes:
95+
You can find modes and mode kits in official library or community created collections, there is some useful link about modes:
1796

1897
- [Currently Available Modes List](https://github.com/text-forge/mode-library#mode-support-status)
1998
- [Official Mode Library](https://github.com/text-forge/mode-library)
20-
- [Latest Modes Release](https://github.com/text-forge/mode-library/releases/latest)
21-
- [Official Packages](https://github.com/text-forge/mode-library/wiki/Packages)
2299

23-
A mode or package is a `.zip` or `.tfmode` file, use **Mode Manager** (`Settings > Mode Manager` in menus) and select
24-
this file with `Import Mode / Package`. After loading, you will receive an **info** notification that says
25-
`"Load mode / package completed"` and you can use your new modes now without restart editor.
100+
A mode or mode kit is a `.zip` or `.tfmode` file, use **Mode Manager** (`Settings > Mode Manager` in menus) and select
101+
this file with `Import Mode / Mode Kit`. After loading, you will receive an **info** notification that says
102+
`"Load mode / mode kit completed"` and you can use your new modes now without restart editor.

0 commit comments

Comments
 (0)