Skip to content

Commit bb31f5e

Browse files
committed
Support Windows
1 parent f25851a commit bb31f5e

File tree

5 files changed

+28
-8
lines changed

5 files changed

+28
-8
lines changed

CMakeLists.txt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
cmake_minimum_required(VERSION 3.5)
22
project(launch_ssh)
33

4-
set(CMAKE_CXX_STANDARD 11)
4+
set(CMAKE_CXX_STANDARD 17)
5+
6+
IF (WIN32)
7+
set(wxWidgets_ROOT_DIR C:/wx)
8+
set(wxWidgets_LIB_DIR C:/wx/lib/gcc810_x64_dll)
9+
set(wxWidgets_EXCLUDE_COMMON_LIBRARIES true)
10+
11+
set(CMAKE_EXE_LINKER_FLAGS -mwindows)
12+
ENDIF()
513

614
find_package(wxWidgets COMPONENTS core base REQUIRED)
715
include(${wxWidgets_USE_FILE})
816

9-
add_executable(launch_ssh src/App.cpp src/MainFrame.cpp src/HistoryFile.cpp src/strnatcmp.c)
17+
add_executable(launch_ssh src/resources.rc src/App.cpp src/MainFrame.cpp src/HistoryFile.cpp src/strnatcmp.c)
1018
target_link_libraries(launch_ssh ${wxWidgets_LIBRARIES})

src/HistoryFile.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@
66
HistoryFile::HistoryFile() {
77
auto standardPaths = wxStandardPaths::Get();
88

9-
// TODO: Windows/mac compatibility
9+
#if defined(__WINDOWS__)
10+
filename = standardPaths.GetUserConfigDir().Append("launch-ssh-history");
11+
#else
1012
filename = standardPaths.GetUserConfigDir().Append("/.config/launch-ssh-history");
13+
#endif
1114
}
1215

1316
void HistoryFile::Load(wxArrayString &history) {

src/MainFrame.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@ MainFrame::MainFrame(const wxString &title, const wxPoint &pos, const wxSize &si
1313
}
1414

1515
void MainFrame::Initialize() {
16-
txtInput = new wxTextCtrl(this, ID_Input, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_DONTWRAP);
16+
#if defined(__WINDOWS__)
17+
command = _("\"C:\\Program Files (x86)\\PuTTY\\putty.exe\" ");
18+
#else
19+
command = _("x-terminal-emulator -e ssh ");
20+
#endif
21+
22+
txtInput = new wxTextCtrl(this, ID_Input, wxEmptyString, wxDefaultPosition, wxDefaultSize);
1723
lstHistory = new wxListBox(this, ID_History);
1824

1925
auto sizer = new wxBoxSizer(wxVERTICAL);
@@ -157,10 +163,7 @@ void MainFrame::Launch() {
157163
}
158164

159165
void MainFrame::Launch(const wxString &target) {
160-
auto command = _("x-terminal-emulator -e ssh ");
161-
command.Append(target);
162-
163-
wxExecute(command);
166+
wxExecute(command + target);
164167

165168
Close();
166169

src/MainFrame.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ class MainFrame : public wxFrame {
4141
wxArrayString matches;
4242
wxString query;
4343

44+
wxString command;
45+
4446
wxTextCtrl * txtInput = nullptr;
4547
wxListBox * lstHistory = nullptr;
4648
};

src/resources.rc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
//lumetron ICON "resources\\launch-ssh.ico"
2+
3+
#define wxUSE_NO_MANIFEST 0
4+
#include "wx/msw/wx.rc"

0 commit comments

Comments
 (0)