Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make GUI labels optional #54

Merged
merged 3 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
- Array brackets can now be omitted when there is only one element.
- GUI elements can now be defined in root object.
- GUI labels became optional.
- "window_name" can now be default values of GUI labels.

ver 0.7.2
- Added "optional" to ignore some options when a text box is empty.
Expand Down
8 changes: 4 additions & 4 deletions examples/all_keys/gui_definition.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"minimum_required": "0.7.1",
"gui": [
{
"label": "Components Minimal",
"window_name": "Components Minimal",
"command": "echo file: %-% & echo folder: %-% & echo combo: %-% & echo radio: %-% & echo check: %-% & echo check_array: %-% & echo textbox: %-% & echo int: %-% & echo float: %-%",
"components": [
{
Expand Down Expand Up @@ -82,7 +82,7 @@
]
},
{
"label": "Components Optional",
"window_name": "Components Optional",
"command": "echo file: %file% & echo folder: %folder% & echo combo: %combo% & echo radio: %radio% & echo check: %check% & echo check_array: %options% & echo textbox: %text% & echo int: %integer% & echo float: %double%",
"components": [
{
Expand Down Expand Up @@ -248,8 +248,8 @@
]
},
{
"label": "GUI Optional",
"window_name": "Window Title Here",
"window_name": "GUI Optional",
"label": "GUI Optional (this string is for a menu item)",
"command_win": "echo home: %__HOME__% & echo cwd: %__CWD__% & echo percent: %% & echo sample message!",
"command_linux": "echo home: %__HOME__%; echo cwd: %__CWD__%; echo percent: %%; echo sample message!",
"command_mac": "echo home: %__HOME__%; echo cwd: %__CWD__%; echo percent: %%; echo sample message!",
Expand Down
1 change: 0 additions & 1 deletion examples/comp_options/affix/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
```json
{
"gui": {
"label": "Affix example",
"command": "echo %-%",
"components": [
{
Expand Down
1 change: 0 additions & 1 deletion examples/comp_options/affix/gui_definition.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"gui": {
"label": "Affix example",
"command": "echo %-%",
"components": [
{
Expand Down
1 change: 0 additions & 1 deletion examples/comp_options/button/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ It allows you to rename the button associated with the picker component.
```json
{
"gui": {
"label": "Button",
"window_name": "Button sample",
"command": "echo %-% %-%",
"components": [
Expand Down
1 change: 0 additions & 1 deletion examples/comp_options/button/gui_definition.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"gui": {
"label": "Button",
"window_name": "Button sample",
"command": "echo %-% %-%",
"components": [
Expand Down
1 change: 0 additions & 1 deletion examples/comp_options/default/gui_definition.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"gui": {
"label": "Sample GUI",
"command": "echo file: %-% & echo options: %-%",
"components": [
{
Expand Down
3 changes: 0 additions & 3 deletions examples/comp_options/id/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ You can use the defined ids as variable names in commands.

```json
{
"label": "IDs",
"command": "echo x: %x% & echo y: %y% & echo x: %x%",
"button": "Echo!",
"components": [
Expand All @@ -29,7 +28,6 @@ When you put an undefined id in `%*%`, it'll use one of the components that have

```json
{
"label": "Undefined IDs",
"command": "echo x: %-% & echo y: %y% & echo z: %foo%",
"button": "Echo!",
"components": [
Expand Down Expand Up @@ -61,7 +59,6 @@ There are some predefined ids.

```json
{
"label": "Reserved IDs",
"command": "echo percent: %% & echo cwd: %__CWD__% & echo home: %__HOME__%",
"button": "Echo!",
"components": []
Expand Down
1 change: 0 additions & 1 deletion examples/comp_options/optional/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
```json
{
"gui": {
"label": "Optional component",
"command": "echo %-%",
"components": [
{
Expand Down
1 change: 0 additions & 1 deletion examples/comp_options/optional/gui_definition.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"gui": {
"label": "Optional component",
"command": "echo %-%",
"components": [
{
Expand Down
1 change: 0 additions & 1 deletion examples/comp_options/placeholder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ It displays a message when the text box is empty.
```json
{
"gui": {
"label": "Placeholder",
"window_name": "Placeholder sample",
"command": "echo %-% %-% %-%",
"components": [
Expand Down
1 change: 0 additions & 1 deletion examples/comp_options/placeholder/gui_definition.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"gui": {
"label": "Placeholder",
"window_name": "Placeholder sample",
"command": "echo %-% %-% %-%",
"components": [
Expand Down
1 change: 0 additions & 1 deletion examples/comp_options/tooltip/gui_definition.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"gui": {
"label": "Sample GUI",
"command": "echo file: %-% & echo folder: %-% & echo options: %-%",
"components": [
{
Expand Down
1 change: 0 additions & 1 deletion examples/components/check_boxes/gui_definition.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"gui": {
"label": "Check Boxes",
"command": "echo checkbox: %-% & echo options:%-%",
"button": "Echo!",
"components": [
Expand Down
1 change: 0 additions & 1 deletion examples/components/choices/gui_definition.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"gui": {
"label": "Component Sample",
"command": "echo combo: %a% & echo radio: %b%",
"button": "Echo!",
"components": [
Expand Down
1 change: 0 additions & 1 deletion examples/components/num_pickers/gui_definition.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"gui": {
"label": "Select numbers",
"window_name": "Picker sample",
"command": "echo int: %-% & echo float: %-%",
"components": [
Expand Down
1 change: 0 additions & 1 deletion examples/components/other_components/gui_definition.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"gui": {
"label": "Component Sample",
"command": "echo textbox: %c%",
"button": "Echo!",
"components": [
Expand Down
1 change: 0 additions & 1 deletion examples/components/path_pickers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ Of course, you can drop files on the pickers to specify the paths.
```json
{
"gui": {
"label": "Copy file",
"window_name": "Picker sample",
"command": "copy %foo% %bar%",
"button": "copy",
Expand Down
1 change: 0 additions & 1 deletion examples/components/path_pickers/gui_definition.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"gui": {
"label": "Copy file",
"window_name": "Picker sample",
"command": "copy %foo% %bar%",
"button": "copy",
Expand Down
2 changes: 0 additions & 2 deletions examples/get_start/minimal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ It has only a button to echo `Hello!`.
```json
{
"gui": {
"label": "Minimal Sample",
"command": "echo Hello!",
"components": []
}
Expand All @@ -19,6 +18,5 @@ It has only a button to echo `Hello!`.

You can write a definition of your GUI in `"gui": {}`.

- `label` is the label for your definition. You can type anything you like here.
- `command` is the command you want to execute when clicking the execution button.
- `components` is an array of GUI components (e.g., file pickers). `[]` means no components.
1 change: 0 additions & 1 deletion examples/get_start/minimal/gui_definition.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"gui": {
"label": "Minimal Sample",
"command": "echo Hello!",
"components": []
}
Expand Down
1 change: 0 additions & 1 deletion examples/get_start/put_component/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ You can put a text box in the GUI.
```json
{
"gui": {
"label": "Text Box Sample",
"window_name": "Title here!",
"command": "echo %-%",
"button": "Hello!",
Expand Down
1 change: 0 additions & 1 deletion examples/get_start/put_component/gui_definition.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"gui": {
"label": "Minimal Sample",
"window_name": "Title here!",
"command": "echo %-%",
"button": "Hello!",
Expand Down
1 change: 0 additions & 1 deletion examples/get_start/title_button/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ You can rename the window title and the execution button.
```json
{
"gui": {
"label": "Minimal Sample",
"window_name": "Title here!",
"command": "echo Hello!",
"button": "Hello!",
Expand Down
1 change: 0 additions & 1 deletion examples/get_start/title_button/gui_definition.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"gui": {
"label": "Minimal Sample",
"window_name": "Title here!",
"command": "echo Hello!",
"button": "Hello!",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"gui": {
"label": "Alternate Spellings",
"command": "echo folder: %-% & echo combo: %-% & echo check_array: %-% & echo textbox: %-% & echo int: %-%",
"title": "Alternate Spellings Sample",
"component_array": [
Expand Down
2 changes: 1 addition & 1 deletion examples/other_features/codepage/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Tuw expects user's default locale for stdout on Windows. If you want to use UTF-
```json
{
"gui": {
"label": "Use UTF-8 outputs on Windows",
"window_name": "Use UTF-8 outputs on Windows",
"command": "powershell -ExecutionPolicy Bypass -File \"utf.ps1\"",
"codepage": "utf8",
"components": []
Expand Down
2 changes: 1 addition & 1 deletion examples/other_features/codepage/gui_definition.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"gui": {
"label": "Use UTF-8 outputs on Windows",
"window_name": "Use UTF-8 outputs on Windows",
"command": "powershell -ExecutionPolicy Bypass -File \"utf.ps1\"",
"codepage": "utf8",
"components": []
Expand Down
2 changes: 0 additions & 2 deletions examples/other_features/cross_platform/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ Tuw will use the platform-specific command instead of the default `command` valu

```json
{
"label": "Platform Specific Commands",
"command_win": "echo Windows!",
"command_mac": "echo macOS!",
"command_linux": "echo Linux!",
Expand All @@ -35,7 +34,6 @@ Tuw will ignore the component if the current OS does not match the specified pla

```json
{
"label": "Platform Specific Components",
"command": "echo %os%",
"show_last_line": true,
"components": [
Expand Down
11 changes: 2 additions & 9 deletions examples/other_features/error/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,8 @@ When the executed command outputs something to `stderr`, Tuw will display an err

```json
{
"gui": [
{
"label": "Error Sample",
"command": "notcommand",
"components": []
}
]
"command": "notcommand",
"components": []
}
```

Expand All @@ -26,7 +21,6 @@ You can also customize the success code using the `exit_success` option.

```json
{
"label": "check_exit_code Sample",
"command": "echo exit code is zero.",
"check_exit_code": true,
"exit_success": 10,
Expand All @@ -44,7 +38,6 @@ When `check_exit_code` is enabled, it can also show the last line in the error d

```json
{
"label": "show_last_line Sample",
"command": "echo Fake Error!",
"show_last_line": true,
"components": []
Expand Down
2 changes: 1 addition & 1 deletion examples/other_features/help/gui_definition.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"gui": {
"label": "Sample GUI",
"window_name": "Sample GUI",
"command": "echo file: %-% & echo folder: %-% & echo checkbox: %-%",
"components": [
{
Expand Down
33 changes: 32 additions & 1 deletion examples/other_features/multiple/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,37 @@
# Multiple Definitions

`"gui"` can be an array of gui definitions.
Users can select one of the definitions from the `Menu` in the executable.
Users can select one of these definitions from the `Menu` in the executable.
You can also use `"label"` to modify strings that are displayed in the menu bar.
When `"label"` is not defined, `"window_name"` will be used as the GUI label.

![advanced](https://github.com/matyalatte/tuw/assets/69258547/956be42e-6931-4b71-ae3c-180103a93714)

```json
{
"gui": [
{
"label": "Sample GUI",
"command": "echo file: %-%",
"button": "Echo!",
"components": [
{
"type": "file",
"label": "Some file path"
}
]
},
{
"window_name": "Sample GUI2",
"command": "echo text_box: %-%",
"button": "Echo!",
"components": [
{
"type": "text",
"label": "Some text"
}
]
}
]
}
```
Loading
Loading