Skip to content

Commit 64f68fd

Browse files
committed
Merge branch 'develop'
2 parents e03594b + 74abc73 commit 64f68fd

File tree

3 files changed

+120
-30
lines changed

3 files changed

+120
-30
lines changed

.github/workflows/ecode-release.yml

Lines changed: 69 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ permissions: write-all
1717
jobs:
1818
release:
1919
name: Create Release
20-
runs-on: ubuntu-20.04
20+
runs-on: ubuntu-22.04
2121
outputs:
2222
upload_url: ${{ steps.create_release.outputs.upload_url }}
2323
version: ${{ steps.tag.outputs.version }}
@@ -58,12 +58,19 @@ jobs:
5858
matrix:
5959
config:
6060
- arch: x86_64
61-
container: ubuntu-20.04
61+
container: ubuntu-22.04
6262
runs-on: ${{ matrix.config.container }}
63+
container:
64+
image: ubuntu:20.04
6365
env:
6466
CC: gcc
6567
CXX: g++
6668
steps:
69+
- name: Install essentials
70+
run: |
71+
export DEBIAN_FRONTEND=noninteractive
72+
apt-get update
73+
apt-get install -y --no-install-recommends software-properties-common build-essential git ca-certificates
6774
- name: Checkout Code
6875
uses: actions/checkout@v4
6976
with:
@@ -74,33 +81,33 @@ jobs:
7481
- name: Set Environment Variables
7582
run: |
7683
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
77-
echo "/usr/lib/ccache" >> "$GITHUB_PATH"
7884
echo "INSTALL_REF=${{ needs.release.outputs.version }}" >> "$GITHUB_ENV"
7985
echo "RARCH=$(uname -m)" >> "$GITHUB_ENV"
8086
echo $(ldd --version)
81-
echo $(gcc --version)
82-
- name: Update Packages
83-
run: |
84-
sudo add-apt-repository -y universe
85-
sudo add-apt-repository -y multiverse
86-
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
87-
sudo apt-get update
87+
- name: Mark Git directory as safe
88+
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
8889
- name: Install dependencies
8990
run: |
90-
sudo apt-get install -y gcc-13 g++-13 libdw-dev
91-
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 10
92-
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-13 10
93-
sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 30
94-
sudo update-alternatives --set cc /usr/bin/gcc
95-
sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 30
96-
sudo update-alternatives --set c++ /usr/bin/g++
97-
sudo update-alternatives --config gcc
98-
sudo update-alternatives --config g++
99-
sudo apt-get install -y libfuse2 fuse premake4 mesa-common-dev libgl1-mesa-dev
91+
apt-get install -y curl libfuse2 fuse premake4 mesa-common-dev libgl1-mesa-dev sudo file appstream
92+
curl -fsSL https://deb.nodesource.com/setup_lts.x | bash -
93+
apt-get install -y nodejs
94+
add-apt-repository -y universe
95+
add-apt-repository -y multiverse
96+
add-apt-repository -y ppa:ubuntu-toolchain-r/test
97+
apt-get update
98+
apt-get install -y gcc-13 g++-13 libdw-dev
99+
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 10
100+
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-13 10
101+
update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 30
102+
update-alternatives --set cc /usr/bin/gcc
103+
update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 30
104+
update-alternatives --set c++ /usr/bin/g++
105+
update-alternatives --config gcc
106+
update-alternatives --config g++
100107
bash projects/linux/scripts/install_sdl2.sh
101108
- name: Build ecode
102109
run: |
103-
bash projects/linux/ecode/build.app.sh --arch ${{ matrix.config.arch }}
110+
bash projects/linux/ecode/build.app.sh --with-static-cpp --arch ${{ matrix.config.arch }}
104111
- name: Upload Files
105112
uses: softprops/action-gh-release@v2
106113
with:
@@ -375,3 +382,44 @@ jobs:
375382
prerelease: true
376383
files: |
377384
projects/macos/ecode/ecode-macos-${{ env.INSTALL_REF }}-x86_64.dmg
385+
386+
build_freebsd_x86_64:
387+
name: FreeBSD x86_64
388+
needs: release
389+
runs-on: ubuntu-latest
390+
steps:
391+
- name: Checkout Code
392+
uses: actions/checkout@v4
393+
with:
394+
repository: 'SpartanJ/eepp'
395+
fetch-depth: 0
396+
submodules: 'recursive'
397+
ref: 'refs/tags/ecode-${{ needs.release.outputs.version }}'
398+
- name: Set Environment Variables
399+
run: |
400+
echo "INSTALL_REF=${{ needs.release.outputs.version }}" >> "$GITHUB_ENV"
401+
echo "RARCH=$(uname -m)" >> "$GITHUB_ENV"
402+
- uses: vmactions/freebsd-vm@v1
403+
env:
404+
INSTALL_REF: ${{ needs.release.outputs.version }}
405+
with:
406+
release: '14.1'
407+
envs: 'INSTALL_REF'
408+
sync: sshfs
409+
usesh: true
410+
mem: 8192
411+
prepare: |
412+
pkg install -y bash git sdl2 curl premake5 gsed gmake
413+
run: |
414+
export CC=clang
415+
export CXX=clang++
416+
git config --global --add safe.directory "$GITHUB_WORKSPACE"
417+
sh projects/freebsd/ecode/build.app.sh
418+
- name: Upload Files
419+
uses: softprops/action-gh-release@v2
420+
with:
421+
tag_name: ${{ needs.release.outputs.version }}
422+
draft: false
423+
prerelease: true
424+
files: |
425+
projects/freebsd/ecode/ecode-freebsd-${{ env.INSTALL_REF }}-x86_64.tar.gz

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ eepp GUI library as part of one of its main objectives.
1111

1212
## Screenshots
1313

14-
![ecode - Code Editor](https://github.com/SpartanJ/ecode/assets/650416/7926c3f3-1b3b-4fe5-859a-3099df73b7e8)
14+
![ecode - Code Editor](https://github.com/user-attachments/assets/fa995b21-a612-4565-b08e-bb6c72799ef1)
1515

1616
For more screenshots checkout
1717
[running on macOS](https://github.com/SpartanJ/ecode/assets/650416/9e8e00a7-fbcc-479b-8588-0023d8f86a9a),

docs/customlanguages.md

Lines changed: 50 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,18 @@ Custom languages support can be added in the languages directory found at:
66
* *macOS*: uses `Application Support` folder in `HOME`, usually translates to `~/Library/Application Support/ecode/languages`
77
* *Windows*: uses `APPDATA`, usually translates to `C:\Users\{username}\AppData\Roaming\ecode\languages`
88

9-
ecode will read each file located at that directory with `json` extension. Each file can contain one
10-
or several languages. In order to set several languages the root element of the json file should be
11-
an array, containing one object for each language, otherwise if the root element is an object, it
12-
should contain the language definition. Language definitions can override any currently supported
13-
definition. ecode will prioritize user defined definitions.
9+
ecode will read each file located at that directory with `json` extension. Each file can contain one or several language definitions.
10+
11+
* **Single Language:** If the root element of the JSON file is an object, it defines a single language.
12+
* **Multiple Languages / Sub-Grammars:** If the root element is an array, it can define multiple independent languages *or* a main language along with **sub-language definitions** used for nesting within the main language (see Nested Syntaxes below). Each object in the array must be a complete language definition with at least a unique `"name"`.
13+
14+
Language definitions can override any currently supported definition. ecode will prioritize user defined definitions. Sub-language definitions used only for nesting might not need fields like `"files"` or `"headers"` if they aren't intended to be selectable top-level languages.
1415

1516
### Language definition format
1617

1718
```json
1819
{
19-
"name": "language_name", // (Required) The display name of the language.
20+
"name": "language_name", // (Required) The display name of the language. Must be unique, especially if referenced by other definitions for nesting.
2021
"files": [ // (Required if `visible` is `true`) An array of Lua patterns matching filenames for this language.
2122
"%.ext$", // Example: Matches files ending in .ext
2223
"^Makefile$" // Example: Matches the exact filename Makefile
@@ -28,13 +29,13 @@ definition. ecode will prioritize user defined definitions.
2829
// Rule using Lua patterns with capture groups mapping to different types:
2930
{ "pattern": "no_capture(pattern_capture_1)(pattern_capture_2)", "type": [ "no_capture_type_name", "capture_1_type_name", "capture_2_type_name" ] },
3031
// Rule defining a multi-line block using Lua patterns (start, end, escape character):
31-
{ "pattern": ["lua_pattern_start", "lua_pattern_end", "escape_character"], "type": "type_name" },
32+
{ "pattern": ["lua_pattern_start", "lua_pattern_end", "escape_character"], "type": "type_name" }, // This rule highlights the entire block, including delimiters, with the specified `type_name`.
3233
// Rule using Perl-compatible regular expressions (PCRE):
3334
{ "regex": "perl_regex", "type": "type_name" },
3435
// Rule using PCRE with capture groups mapping to different types:
3536
{ "regex": "no_capture(pattern_capture_1)(pattern_capture_2)", "type": [ "no_capture_type_name", "capture_1_type_name", "capture_2_type_name" ] },
3637
// Rule defining a multi-line block using PCRE (start, end, escape character):
37-
{ "regex": ["regex_start", "regex_end", "escape_character"], "type": "type_name" },
38+
{ "regex": ["regex_start", "regex_end", "escape_character"], "type": "type_name" }, // Similar to the Lua pattern block, highlights the entire block with `type_name`.
3839
// Rule using a custom parser implemented in native code for performance (e.g., number parsing):
3940
{ "parser": "custom_parser_name", "type": "type_name" } // Currently available: "cpp_number_parser", "c_number_parser", "js_number_parser", "common_number_parser" (matches decimal and hexa), "common_number_parser_o" (matches the same as "common_number_parser" plus octal numbers), "common_number_parser_ob" (matches the same as "common_number_parser_o" plus binary numbers)
4041

@@ -54,6 +55,28 @@ definition. ecode will prioritize user defined definitions.
5455
// - The third capture (word with extra allowed chars) is typed as "symbol".
5556
// Similar to the above, when the third group matches text (e.g., "true"), ecode looks up "true" in the "symbols" definition.
5657
// If { "true": "literal" } exists, the matched text "true" will be highlighted as "literal". Otherwise, it defaults to "normal".
58+
59+
// --- NESTED SYNTAX RULE ---
60+
// Rule defining a multi-line block that switches to a DIFFERENT language syntax inside:
61+
{
62+
"pattern": ["lua_pattern_start", "lua_pattern_end", "escape_character"], // Can also use "regex"
63+
"syntax": "NestedLanguageName", // (Optional) The 'name' of another language definition to use for highlighting *within* this block.
64+
"type": "type_name" // OR ["type_for_start_capture1", "type_for_start_capture2", ...] // (Optional) Defines the type(s) for the text matched by the START and END patterns themselves (using capture groups if needed). If omitted, delimiters usually get 'normal' type.
65+
},
66+
// How nesting works:
67+
// 1. The `pattern` (or `regex`) defines the start and end delimiters of the block.
68+
// 2. The `syntax` key specifies the `name` of another language definition (which must be loaded, often defined in the same JSON file using an array).
69+
// 3. The text *between* the start and end delimiters will be highlighted using the rules defined in the "NestedLanguageName" language definition.
70+
// 4. The `type` key here applies ONLY to the text matched by the start and end patterns themselves. If the start/end patterns have capture groups, you can provide an array of types matching those captures.
71+
// 5. Nesting can occur up to 4 levels deep (e.g., Language A contains Language B, which contains Language C, etc.).
72+
// Use Case: Essential for languages embedding other languages, like HTML containing CSS and JavaScript.
73+
74+
// Example of a nested syntax rule (C++ raw string containing XML):
75+
{
76+
"pattern": [ "R%\"(xml)%(", "%)(xml)%\"" ], // Start: R"(xml)(, End: )(xml)"
77+
"syntax": "XML", // Use the "XML" language definition inside.
78+
"type": [ "string", "keyword2", "string", "keyword2" ] // Types for captures in start/end: "R\"(" + "xml" + ")(" and ")(" + "xml" + ")\"". Needs adjustment based on exact captures. Assumes captures are (xml) in start and (xml) in end. Often, the delimiters are just styled as 'string' or 'keyword2'. Example simplification: "type": "string" might apply to the whole delimiter match if no captures are typed.
79+
},
5780
],
5881
"symbols": [ // (Optional) An array defining specific types for exact words, primarily used in conjunction with patterns having `type: "symbol"`.
5982
// Structure: An array where each element is an object containing exactly one key-value pair.
@@ -102,6 +125,25 @@ definition. ecode will prioritize user defined definitions.
102125
]
103126
}
104127
```
128+
### Nested Syntaxes (Sub-Grammars)
129+
130+
ecode supports **nested syntaxes**, allowing a block of code within one language to be highlighted according to the rules of another language. This is crucial for accurately representing modern languages that often embed other languages or domain-specific languages.
131+
132+
**How it works:**
133+
134+
1. **Define Sub-Languages:** Define the syntax for the language to be embedded (e.g., "CSS", "JavaScript", "XML", "SQL") as a separate language definition. Often, these are defined within the *same JSON file* as the main language, using a JSON array as the root element (see [Custom languages support](#custom-languages-support)). The sub-language definition needs a unique `"name"`.
135+
2. **Reference in Patterns:** In the main language's `"patterns"`, use a multi-line block rule (`pattern` or `regex` array). Add the `"syntax"` key to this rule, setting its value to the `"name"` of the sub-language definition you want to use inside the block.
136+
3. **Highlighting:** When ecode encounters this block, it applies the highlighting rules from the specified sub-language to the content *between* the start and end delimiters. The delimiters themselves are styled according to the `type` specified in the *outer* rule.
137+
138+
**Example Use Cases:**
139+
140+
* HTML files containing `<style>` blocks (CSS) and `<script>` blocks (JavaScript).
141+
* Markdown files with fenced code blocks (e.g., ```python ... ```).
142+
* Templating languages embedding HTML and code.
143+
144+
**Nesting Depth:** Syntax nesting is supported up to 4 levels deep.
145+
146+
See the description of the `syntax` key under the [`patterns`](#language-definition-format) section for the exact rule format.
105147

106148
### Type Names
107149

0 commit comments

Comments
 (0)