Skip to content

Commit 95fd806

Browse files
authored
Merge pull request #74 from matyalatte/dev
v0.9.0 release
2 parents 3d376f5 + 6afc64b commit 95fd806

File tree

22 files changed

+269
-69
lines changed

22 files changed

+269
-69
lines changed

.github/workflows/build_all.yml

+43-11
Original file line numberDiff line numberDiff line change
@@ -146,25 +146,22 @@ jobs:
146146
strategy:
147147
fail-fast: false
148148
matrix:
149-
arch: [ x64, arm64 ]
150-
runs-on: ubuntu-latest
149+
include:
150+
- host: ubuntu-latest
151+
arch: x64
152+
- host: ubuntu-24.04-arm
153+
arch: arm64
154+
155+
runs-on: ${{ matrix.host }}
151156
needs: setup
152157
steps:
153158
- uses: actions/checkout@v4
154159

155-
- name: Build x64 version on Ubuntu 20.04
156-
if : matrix.arch == 'x64'
160+
- name: Build with docker
157161
run: |
158162
sudo apt-get update
159163
docker build -t tuw_ubuntu -f docker/ubuntu.dockerfile ./
160164
161-
- name: Build ARM64 version on Ubuntu 20.04
162-
if : matrix.arch == 'arm64'
163-
run: |
164-
sudo apt-get update
165-
sudo apt-get install -y qemu-user-static binfmt-support
166-
docker buildx build --platform linux/arm64 -t tuw_ubuntu -f docker/ubuntu.dockerfile ./
167-
168165
- name: Copy files
169166
run: |
170167
docker run --name tuw_ubuntu tuw_ubuntu
@@ -190,3 +187,38 @@ jobs:
190187
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
191188
run: |
192189
gh release upload ${{ needs.setup.outputs.tag }} archive/${{ env.TOOL_NAME }}-${{ needs.setup.outputs.tag }}-${{ runner.os }}-${{ matrix.arch }}.tar.xz
190+
191+
# Upload source files with subprojects
192+
upload-source:
193+
name: upload-source
194+
strategy:
195+
fail-fast: false
196+
197+
runs-on: ubuntu-latest
198+
199+
needs: setup
200+
steps:
201+
- uses: actions/checkout@v4
202+
- uses: actions/setup-python@v5
203+
with:
204+
python-version: '3.x'
205+
206+
- name: Install packages
207+
run: |
208+
sudo apt-get update
209+
sudo apt-get -y install libgtk-3-dev
210+
pip3 install meson ninja
211+
212+
- name: Archive source files with subprojects
213+
run: |
214+
meson setup build
215+
cd build
216+
meson dist --include-subprojects --no-tests --allow-dirty
217+
cd meson-dist
218+
mv ${{ env.TOOL_NAME }}-undefined.tar.xz ${{ env.TOOL_NAME }}-${{ needs.setup.outputs.tag }}_source-with-subprojects.tar.xz
219+
220+
- name: Upload Release Asset
221+
env:
222+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
223+
run: |
224+
gh release upload ${{ needs.setup.outputs.tag }} build/meson-dist/${{ env.TOOL_NAME }}-${{ needs.setup.outputs.tag }}_source-with-subprojects.tar.xz

.github/workflows/test.yml

+4-18
Original file line numberDiff line numberDiff line change
@@ -63,30 +63,16 @@ jobs:
6363
brew install --cask xquartz
6464
bash shell_scripts/test.sh
6565
66-
test_linux_arm64:
67-
runs-on: ubuntu-latest
68-
needs: lint
69-
strategy:
70-
matrix:
71-
os: [ubuntu, alpine]
72-
steps:
73-
- uses: actions/checkout@v4
74-
- name: Run tests on arm64 image
75-
run: |
76-
sudo apt-get update
77-
sudo apt-get install -y qemu-user-static binfmt-support
78-
docker buildx build --platform linux/arm64 -t tuw_arm_test -f docker/${{ matrix.os }}.dockerfile ./
79-
docker run --rm --init -i tuw_arm_test xvfb-run bash test.sh
80-
81-
test_linux_x64:
82-
runs-on: ubuntu-latest
66+
test_linux:
8367
needs: lint
8468
strategy:
8569
matrix:
70+
host: [ubuntu-latest, ubuntu-24.04-arm]
8671
os: [ubuntu, alpine]
72+
runs-on: ${{ matrix.host }}
8773
steps:
8874
- uses: actions/checkout@v4
89-
- name: Run tests on x64 image
75+
- name: Test with docker
9076
run: |
9177
docker build -t tuw_test -f docker/${{ matrix.os }}.dockerfile ./
9278
docker run --rm --init -i tuw_test xvfb-run bash test.sh

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
*.jsonc
77
!examples/**/gui_definition.jsonc
88
!tests/**/*.jsonc
9+
*.tuw
10+
!examples/**/*.tuw
911

1012
*.txt
1113
!changelog.txt

docs/README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,12 @@ You can use it to validate definitions while editing files.
6161
For VSCode, you can add the schema path to `settings.json` (`File > Preferences > Settings > JSON:Schemas > Edit in settings.json`.)
6262

6363
```json
64+
"files.associations": {
65+
"*.tuw": "jsonc"
66+
},
6467
"json.schemas": [
6568
{
66-
"fileMatch": [ "gui_definition.json", "gui_definition.jsonc" ],
69+
"fileMatch": [ "gui_definition.json", "gui_definition.jsonc", "*.tuw" ],
6770
"url": "https://raw.githubusercontent.com/matyalatte/tuw/main/schema/schema.json"
6871
}
6972
]

docs/changelog.txt

+11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
ver 0.9.0
2+
- Tuw now takes the first argument as a JSON path. (#67)
3+
(You can now launch GUI just by clicking *.tuw files
4+
if you rename JSON files to *.tuw and set Tuw as a default application for opening *.tuw.)
5+
- Tuw now uses the default CWD to resolve paths in command-line arguments. (#67)
6+
(Old versions used executable's directory as CWD.)
7+
- Fixed an error when launching tuw as a macOS application. (#68)
8+
- Disabled the best-fit mapping on Windows to remove potential issues. (#71)
9+
- Disabled c++ stack unwinding on Linux and macOS. (#72)
10+
- Uploaded source files with subprojects to the release page. (#69)
11+
112
ver 0.8.1
213
- Fixed a memory leak on Linux. (#59)
314
- Removed std::exception from tuw. (#63)

examples/README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ You can see some JSON files to learn how to use Tuw.
66

77
- [Minimal](./get_start/minimal/): Example for a minimal GUI.
88
- [Title and Button](./get_start/title_button/): Options to rename the window title and the execution button.
9-
- [Putting Components](./get_start/put_component/): Example for a text box.
9+
- [Put Components](./get_start/put_component/): Example for a text box.
1010
- [JSON Embedding](./get_start/json_embed): You can embed JSON into exe!
11+
- [Open a JSON with Tuw](./get_start/open_json_with_tuw): You can open any JSON files with Tuw to launch GUI!
1112

1213
![minimal](https://github.com/matyalatte/tuw/assets/69258547/7be563b8-1ee0-4500-94c4-5ca575ad185f)
1314

examples/all_keys/gui_definition.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"recommended": "0.8.1",
2+
"recommended": "0.9.0",
33
"minimum_required": "0.8.0",
44
"gui": [
55
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Open a JSON file with Tuw
2+
3+
Tuw can take the first argument as a JSON path if the path includes a file extension. By renaming your JSON files to `*.tuw` and setting Tuw as a default application for `*.tuw` files, you can launch GUIs just by clicking on the files.
4+
5+
![default app](https://github.com/user-attachments/assets/73e42775-d609-4f0d-b2a1-43cb8f4455cf)
6+
7+
On Windows, setting Tuw as the default application is straightforward. However, for other operating systems, the process is a bit more complex. Below are examples of how to set it up on Ubuntu 20.04 and macOS 10.15.
8+
9+
## Ubuntu 20.04
10+
11+
### 1. Add `application/x-tuw` to `~/.local/share/mime/packages/Overrides.xml`
12+
13+
(Make `Overrides.xml` if it does not exist.)
14+
15+
```xml
16+
<?xml version="1.0" encoding="UTF-8"?>
17+
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
18+
<mime-type type="application/x-tuw">
19+
<comment>TUW custom file</comment>
20+
<glob pattern="*.tuw"/>
21+
</mime-type>
22+
</mime-info>
23+
```
24+
25+
### 2. Make `~/.local/share/applications/tuw.desktop`
26+
27+
Replace `/full/path/to/Tuw` with your path to Tuw. And save it as `tuw.desktop`.
28+
29+
```ini
30+
[Desktop Entry]
31+
Version=1.0
32+
Type=Application
33+
Name=Tuw
34+
Comment=Tiny GUI wrapper for CLI tools
35+
Exec=/full/path/to/Tuw %f
36+
Terminal=false
37+
MimeType=application/x-tuw;
38+
Categories=Utility;Application;
39+
```
40+
41+
### 3. Update database
42+
43+
You can apply the changes with the following commands.
44+
45+
```console
46+
update-mime-database ~/.local/share/mime
47+
update-desktop-database ~/.local/share/applications/
48+
xdg-mime default tuw.desktop application/x-tuw
49+
```
50+
51+
## macOS 10.15
52+
53+
### 1. Make a wrapper with AppleScript
54+
55+
Open the script editor and write the following AppleScript. And replace `/full/path/to/Tuw` with your path to Tuw.
56+
57+
```scpt
58+
on open fileList
59+
-- Modify this variable for your environment
60+
set exePath to "/full/path/to/Tuw"
61+
62+
set filePath to item 1 of fileList
63+
set posixFilePath to POSIX path of filePath
64+
65+
tell application "Terminal"
66+
do script exePath & " " & posixFilePath & "; exit;"
67+
end tell
68+
end open
69+
```
70+
71+
### 2. Export the script as an application (File > Export...)
72+
73+
![export_applescript](https://github.com/user-attachments/assets/29a9f20f-804c-46ac-b134-a1a127b84153)
74+
75+
### 3. Right click a .tuw file and set Tuw as a default application
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"gui": {
3+
"window_name": "Title here!",
4+
"command": "echo %-%",
5+
"button": "Hello!",
6+
"components": [
7+
{
8+
"type": "text",
9+
"label": "Type 'Hello!'"
10+
}
11+
]
12+
}
13+
}

examples/get_start/put_component/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Putting Components
1+
# Put Components
22

33
You can put a text box in the GUI.
44

include/main_frame.h

+16-4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ struct MenuData {
1313
int menu_id;
1414
};
1515

16+
#define EMPTY_DOCUMENT rapidjson::Document(rapidjson::kObjectType)
17+
1618
// Main window
1719
class MainFrame {
1820
private:
@@ -47,10 +49,20 @@ class MainFrame {
4749
void JsonLoadFailed(const noex::string& msg) noexcept;
4850

4951
public:
50-
explicit MainFrame(const rapidjson::Document& definition =
51-
rapidjson::Document(rapidjson::kObjectType),
52-
const rapidjson::Document& config =
53-
rapidjson::Document(rapidjson::kObjectType)) noexcept;
52+
explicit MainFrame(const rapidjson::Document& definition = EMPTY_DOCUMENT,
53+
const rapidjson::Document& config = EMPTY_DOCUMENT,
54+
const char* json_path = nullptr) noexcept {
55+
Initialize(definition, config, json_path);
56+
}
57+
58+
explicit MainFrame(const char* json_path) noexcept {
59+
Initialize(EMPTY_DOCUMENT, EMPTY_DOCUMENT, json_path);
60+
}
61+
62+
void Initialize(const rapidjson::Document& definition,
63+
const rapidjson::Document& config,
64+
const char* json_path) noexcept;
65+
5466
void UpdatePanel(unsigned definition_id) noexcept;
5567
void OpenURL(int id) noexcept;
5668
bool Validate() noexcept;

include/noex/string.hpp

+14-2
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,25 @@ class basic_string {
8989
}
9090

9191
static const size_t npos;
92-
size_t find(const charT c) const noexcept;
92+
size_t find(charT c) const noexcept;
9393
size_t find(const charT* str) const noexcept;
9494
inline size_t find(const basic_string& str) const noexcept {
9595
return find(str.c_str());
9696
}
9797

98-
inline void push_back(const charT c) noexcept {
98+
inline bool contains(charT c) const noexcept {
99+
return find(c) != npos;
100+
}
101+
inline bool contains(const charT* str) const noexcept {
102+
return find(str) != npos;
103+
}
104+
inline bool contains(const basic_string& str) const noexcept {
105+
return find(str) != npos;
106+
}
107+
108+
bool starts_with(const charT* str) const noexcept;
109+
110+
inline void push_back(charT c) noexcept {
99111
this->append(&c, 1);
100112
}
101113

include/tuw_constants.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ namespace tuw_constants {
1010
" CLI tools\n";
1111
constexpr char TOOL_NAME[] = "Tuw";
1212
constexpr char AUTHOR[] = "matyalatte";
13-
constexpr char VERSION[] = "0.8.1";
14-
constexpr int VERSION_INT = 801;
13+
constexpr char VERSION[] = "0.9.0";
14+
constexpr int VERSION_INT = 900;
1515

1616
#ifdef _WIN32
1717
#define TUW_CONSTANTS_OS "win"

license.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2022-2024 matyalatte
3+
Copyright (c) 2022-2025 matyalatte
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

shell_scripts/build.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ if [ "$1" = "Debug" ]; then
88
preset="--native-file presets/debug.ini"
99
else
1010
build_type="Release"
11-
preset="--native-file presets/release.ini"
11+
preset="--native-file presets/release.ini -Dcpp_eh=none"
1212
fi
1313

1414
echo "Build type: ${build_type}"

shell_scripts/build_universal.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ if [ "$1" = "Debug" ]; then
88
preset="--native-file presets/debug.ini"
99
else
1010
build_type="Release"
11-
preset="--native-file presets/release.ini"
11+
preset="--native-file presets/release.ini -Dcpp_eh=none"
1212
fi
1313

1414
echo "Build type: ${build_type}"

shell_scripts/test.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ if [ "$1" = "Debug" ]; then
77
preset="--native-file presets/debug.ini --native-file presets/test.ini"
88
else
99
build_type="Release"
10-
preset="--native-file presets/release.ini --native-file presets/test.ini"
10+
preset="--native-file presets/release.ini --native-file presets/test.ini -Dcpp_eh=none"
1111
fi
1212
echo "Build type: ${build_type}"
1313

0 commit comments

Comments
 (0)