Skip to content

Commit

Permalink
Merge pull request #18 from matyalatte/dev
Browse files Browse the repository at this point in the history
v0.5.1 update
  • Loading branch information
matyalatte authored Jul 22, 2023
2 parents b8332a8 + c2fca6a commit da3e82f
Show file tree
Hide file tree
Showing 56 changed files with 12,309 additions and 443 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

# built files
*.exe
*.new
*.zip

SimpleCommandRunner
Expand Down
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -ffunction-sections -fdata-sections -flto -D wxDEBUG_LEVEL=0")
string(REPLACE "-O2" "-Os" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
string(REPLACE "-O3" "-Os" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
if (NOT BUILD_TESTS)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fno-exceptions")
endif()
endif()
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -no-pie -D wxNO_RTTI")
Expand All @@ -38,9 +41,16 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
string(REPLACE "/O2" "/O1" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /DwxNO_RTTI")
string(REPLACE "/EHsc " "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /EHsc")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /GL /GR- /DwxDEBUG_LEVEL=0")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE
"${CMAKE_EXE_LINKER_FLAGS_RELEASE} /OPT:REF /OPT:ICF /LTCG")
if (BUILD_TESTS)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /EHsc")
else()
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /D_HAS_EXCEPTIONS=0")
endif()
else()
message(WARNING "${PROJECT_NAME} does NOT support your compiler. You might get some problems.")
endif()
Expand Down
12 changes: 8 additions & 4 deletions batch_files/build_wxWidgets.bat
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ REM Edit here if you won't use Visual Studio 2022.
set GENERATOR=Visual Studio 17 2022
echo Generator: %GENERATOR%

set RELEASE_FLAGS=-D CMAKE_CXX_FLAGS_RELEASE="/MT /O1 /DNDEBUG /GL"^
set COMPILER_FLAGS=-D CMAKE_CXX_FLAGS="/DWIN32 /D_WINDOWS"^
-D CMAKE_CXX_FLAGS_DEBUG="/MDd /Zi /Ob0 /Od /RTC1 /GR /EHsc"^
-D CMAKE_CXX_FLAGS_RELEASE="/MT /O1 /DNDEBUG /GL /GR- /D_HAS_EXCEPTIONS=0"^
-D CMAKE_STATIC_LINKER_FLAGS_RELEASE="/LTCG"
echo CXX_FLAGS_RELEASE: %RELEASE_FLAGS%
echo COMPILER_FLAGS: %COMPILER_FLAGS%

REM You can specify build type as an argument like "build_wxWidgets.bat Release"
if /I "%~1"=="Debug" (
Expand Down Expand Up @@ -51,6 +53,8 @@ set NON_GUI_OPTIONS=-D wxUSE_INTL=OFF^
-D wxUSE_ARCHIVE_STREAMS=OFF^
-D wxUSE_BASE64=OFF^
-D wxUSE_STACKWALKER=OFF^
-D wxUSE_ON_FATAL_EXCEPTION=OFF^
-D wxUSE_EXCEPTIONS=OFF^
-D wxUSE_DATETIME=OFF^
-D wxUSE_CMDLINE_PARSER=OFF^
-D wxUSE_DIALUP_MANAGER=OFF^
Expand Down Expand Up @@ -253,8 +257,8 @@ set wxOPTIONS=-D wxBUILD_COMPATIBILITY=3.1^
mkdir %BUILD_TYPE%
cd %BUILD_TYPE%
if "%BUILD_TYPE%"=="Release" (
set CMAKE_OPTIONS=%CMAKE_OPTIONS% %RELEASE_FLAGS%
set wxOPTIONS=%wxOPTIONS% -D wxBUILD_USE_STATIC_RUNTIME=ON -D wxBUILD_DEBUG_LEVEL=0 -D wxUSE_DEBUGREPORT=OFF -D wxUSE_LOG=OFF -D wxUSE_EXCEPTIONS=OFF
set CMAKE_OPTIONS=%CMAKE_OPTIONS% %COMPILER_FLAGS%
set wxOPTIONS=%wxOPTIONS% -D wxBUILD_USE_STATIC_RUNTIME=ON -D wxBUILD_DEBUG_LEVEL=0 -D wxUSE_DEBUGREPORT=OFF -D wxUSE_LOG=OFF
)
echo Cmake options: %CMAKE_OPTIONS%
echo wxOptions: %wxOPTIONS%
Expand Down
8 changes: 8 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
ver 0.5.1
- Added a predefined ID for the user's home directory.
- Added an option to rename the "Browse" button for path pickers.
- Disabled c++ exceptions.
- Removed more codes from wxWidgets.
- Fixed crashes when opening URLs or files via the help menu.
- Removed compilation warnings about overriding.

ver 0.5.0
- Changed the json formats for "choice" and "check_array"
- Added command-line utils to embed json into exe.
Expand Down
4 changes: 2 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Simple Command Runner ver 0.5.0
# Simple Command Runner ver 0.5.1

![build](https://github.com/matyalatte/Simple-Command-Runner/actions/workflows/build_all.yml/badge.svg)
![test](https://github.com/matyalatte/Simple-Command-Runner/actions/workflows/test.yml/badge.svg)
Expand Down Expand Up @@ -77,7 +77,7 @@ You can also make `gui_definition.json` with [web forms](https://rjsf-team.githu
## Want Smaller Executables?

You can use [UPX to compress the executables](./UPX.md).
They will be **under 500KB**!
They will be **under 400KB**!

## License

Expand Down
2 changes: 2 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ Examples for component options.
- [IDs](./comp_options/id/): An option to set ids. You can use them as variable names in commands.
- [Default Values](./comp_options/default/): An option to set default values of components.
- [Tooltip](./comp_options/tooltip/): An option to show a message when the mouse cursor is on a component.
- [Placeholder](./comp_options/placeholder/): An option to show a message when the text box is empty.
- [Renaming Buttons](./comp_options/button/): An option to rename buttons of path pickers.

![tooltip](https://user-images.githubusercontent.com/69258547/223138605-9a9aa6a7-a5c9-4aa6-b0af-dd674b46160a.png)

Expand Down
8 changes: 5 additions & 3 deletions examples/all_keys/gui_definition.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
"id": "file",
"extension": "png or jpg (*.png;*.jpg)|*.png;*.jpg",
"empty_message": "Drop a file here!",
"button": "...",
"default": "test.txt",
"add_quotes": true,
"tooltip": "Tooltip!",
Expand All @@ -91,6 +92,7 @@
"label": "Folder path",
"id": "folder",
"empty_message": "Drop a folder here!",
"button": "Browse",
"default": "testdir",
"add_quotes": true,
"tooltip": "Tooltip?",
Expand Down Expand Up @@ -192,9 +194,9 @@
{
"label": "GUI Optional",
"window_name": "Window Title Here",
"command_win": "echo cwd: %__CWD__% & echo percent: %% & echo sample message!",
"command_linux": "echo cwd: %__CWD__%; echo percent: %%; echo sample message!",
"command_mac": "echo cwd: %__CWD__%; echo percent: %%; echo sample message!",
"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!",
"button": "Run!",
"show_last_line": true,
"check_exit_code": true,
Expand Down
30 changes: 30 additions & 0 deletions examples/comp_options/button/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Renaming Buttons

`button` is an optional key for path pickers.
It'll rename the button of the picker.

![Button](https://github.com/matyalatte/Simple-Command-Runner/assets/69258547/979d987b-842a-4a20-a2e1-4fde85836a3e)

```json
{
"gui": [
{
"label": "Button",
"window_name": "Button sample",
"command": "echo %-% %-%",
"components": [
{
"type": "file",
"label": "Some file",
"button": "..."
},
{
"type": "folder",
"label": "Some folder",
"button": "Open"
}
]
}
]
}
```
21 changes: 21 additions & 0 deletions examples/comp_options/button/gui_definition.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"gui": [
{
"label": "Button",
"window_name": "Button sample",
"command": "echo %-% %-%",
"components": [
{
"type": "file",
"label": "Some file",
"button": "..."
},
{
"type": "folder",
"label": "Some folder",
"button": "Open"
}
]
}
]
}
3 changes: 2 additions & 1 deletion examples/comp_options/id/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,13 @@ When you put an undefined id in `%*%`, it'll use one of the components that have
There are some predefined ids.
`%%` will be replaced with `%` at runtime.
`%__CWD__%` will be replaced with the executable directory at runtime.
`%__HOME__%` will be replaced with the user's home directory at runtime.
Also, all ids that start with `_` are reserved.

```json
{
"label": "Reserved IDs",
"command": "echo percent: %% & echo cwd: %__CWD__%",
"command": "echo percent: %% & echo cwd: %__CWD__% & echo home: %__HOME__%",
"button": "Echo!",
"components": []
}
Expand Down
2 changes: 1 addition & 1 deletion examples/comp_options/id/gui_definition.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
},
{
"label": "Reserved IDs",
"command": "echo percent: %% & echo cwd: %__CWD__%",
"command": "echo percent: %% & echo cwd: %__CWD__% & echo home: %__HOME__%",
"button": "Echo!",
"components": []
}
Expand Down
35 changes: 35 additions & 0 deletions examples/comp_options/placeholder/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Placeholder

`empty_message` is an optional key for path pickers and text boxes.
It will show a message when the text box is empty.

![Placeholder](https://github.com/matyalatte/Simple-Command-Runner/assets/69258547/7694fdec-c739-45b9-980c-64e2f81203d7)

```json
{
"gui": [
{
"label": "Placeholder",
"window_name": "Placeholder sample",
"command": "echo %-% %-% %-%",
"components": [
{
"type": "file",
"label": "Some file",
"empty_message": "Drop a file here!"
},
{
"type": "folder",
"label": "Some folder",
"empty_message": "Drop a folder here!"
},
{
"type": "text",
"label": "Some text",
"empty_message": "Type here!"
}
]
}
]
}
```
26 changes: 26 additions & 0 deletions examples/comp_options/placeholder/gui_definition.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"gui": [
{
"label": "Placeholder",
"window_name": "Placeholder sample",
"command": "echo %-% %-% %-%",
"components": [
{
"type": "file",
"label": "Some file",
"empty_message": "Drop a file here!"
},
{
"type": "folder",
"label": "Some folder",
"empty_message": "Drop a folder here!"
},
{
"type": "text",
"label": "Some text",
"empty_message": "Type here!"
}
]
}
]
}
6 changes: 2 additions & 4 deletions examples/components/path_pickers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ Of course, you can drop files on the pickers to specifiy the paths.
{
"type": "folder",
"label": "Output path",
"add_quotes": true,
"empty_message": "Drop a folder here!"
"add_quotes": true
}
]
}
Expand All @@ -40,8 +39,7 @@ Each component should be defined as a dictionary.
- `type` is component type. `file` for a file picker, and `folder` for a dir picker.
- `label` is a string written above the text box of picker.
- `extension` is an optional key for file picker. It's wildcard for file pickers. Use the same syntax as for [wxWidget's wildcards](https://docs.wxwidgets.org/3.0/classwx_file_dialog.html).
- `add_quotes` is an optional key for components. It will add quotes to the input strings.
- `empty_message` is an optional key for text box. It will show a message when the text box is empty.
- `add_quotes` is an optional key for components. It will add quotes (`""`) to the input strings.

## "command"

Expand Down
3 changes: 1 addition & 2 deletions examples/components/path_pickers/gui_definition.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
{
"type": "folder",
"label": "Output path",
"add_quotes": true,
"empty_message": "Drop a folder here!"
"add_quotes": true
}
]
}
Expand Down
2 changes: 1 addition & 1 deletion examples/get_start/put_component/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ In the example, the value of the text box will be injected in `%-%`.

## IDs

You can also use [`id`](../../comp_options/id) option to name the componets like variables.
You can also use the [`id`](../../comp_options/id) option to name the components like variables.

```json
"gui": [
Expand Down
30 changes: 25 additions & 5 deletions include/custom_wx_obj.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,22 @@ class CustomPickerBase : public wxFileDirPickerCtrlBase {
protected:
CustomTextCtrl* m_custom_text_ctrl;

virtual
wxFileDirPickerWidgetBase* CreatePicker(wxWindow* parent,
const wxString& path,
const wxString& message,
const wxString& wildcard) wxOVERRIDE {
return nullptr;
}

virtual wxFileDirPickerWidgetBase* CreatePicker(wxWindow* parent,
const wxString& path,
const wxString& message,
const wxString& button_label,
const wxString& wildcard) {
return nullptr;
}

public:
CustomPickerBase() : wxFileDirPickerCtrlBase() {
m_custom_text_ctrl = nullptr;
Expand All @@ -78,13 +94,14 @@ class CustomPickerBase : public wxFileDirPickerCtrlBase {
const wxString& message,
const wxString& wildcard,
const wxString& empty_message,
const wxString& button_label,
const wxPoint& pos,
const wxSize& size,
long style,
const wxValidator& validator,
const wxString& name);
void UpdateTextCtrlFromPicker();
void UpdatePickerFromTextCtrl();
void UpdateTextCtrlFromPicker() wxOVERRIDE;
void UpdatePickerFromTextCtrl() wxOVERRIDE;
virtual wxString GetFullPath() {return "";}
};

Expand All @@ -97,6 +114,7 @@ class CustomFilePicker : public CustomPickerBase {
const wxString& message = wxFileSelectorPromptStr,
const wxString& wildcard = wxFileSelectorDefaultWildcardStr,
const wxString& empty_message = wxEmptyString,
const wxString& button_label = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxFLP_DEFAULT_STYLE,
Expand Down Expand Up @@ -124,9 +142,10 @@ class CustomFilePicker : public CustomPickerBase {
wxFileDirPickerWidgetBase* CreatePicker(wxWindow* parent,
const wxString& path,
const wxString& message,
const wxString& button_label,
const wxString& wildcard) wxOVERRIDE {
return new wxFilePickerWidget(parent, wxID_ANY,
wxGetTranslation(wxFilePickerWidgetLabel),
button_label,
path, message, wildcard,
wxDefaultPosition, wxDefaultSize,
GetPickerStyle(GetWindowStyle()));
Expand All @@ -151,6 +170,7 @@ class CustomDirPicker : public CustomPickerBase {
const wxString& path = wxEmptyString,
const wxString& message = wxFileSelectorPromptStr,
const wxString& empty_message = wxEmptyString,
const wxString& button_label = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxFLP_DEFAULT_STYLE,
Expand All @@ -173,15 +193,15 @@ class CustomDirPicker : public CustomPickerBase {
&wxFileDirPickerCtrlBase::OnFileDirChange, eventSink);
}


protected:
virtual
wxFileDirPickerWidgetBase* CreatePicker(wxWindow* parent,
const wxString& path,
const wxString& message,
const wxString& button_label,
const wxString& WXUNUSED(wildcard)) wxOVERRIDE {
return new wxDirPickerWidget(parent, wxID_ANY,
wxGetTranslation(wxDirPickerWidgetLabel),
button_label,
path, message,
wxDefaultPosition, wxDefaultSize,
GetPickerStyle(GetWindowStyle()));
Expand Down
Loading

0 comments on commit da3e82f

Please sign in to comment.