Open multiple files, and toggle viewing of whitespace characters
This commit is contained in:
parent
a3e7c1b1f0
commit
dcdff24a87
13
Makefile
13
Makefile
@ -1,6 +1,6 @@
|
|||||||
CXX += -I include
|
CXX += -I include -I.
|
||||||
|
|
||||||
SOURCES = $(wildcard include/**/*.cpp include/*.cpp src/settings/*.cpp)
|
SOURCES = $(wildcard include/**/*.cpp include/*.cpp src/network/*.cpp src/settings/*.cpp)
|
||||||
OBJECTS = $(patsubst %.cpp,%.o, $(SOURCES))
|
OBJECTS = $(patsubst %.cpp,%.o, $(SOURCES))
|
||||||
TYRO_LIB = build/Tyro.a
|
TYRO_LIB = build/Tyro.a
|
||||||
|
|
||||||
@ -14,8 +14,8 @@ WX_LDLIBS = $(shell wx-config --libs base core aui stc adv)
|
|||||||
WX_CXXFLAGS = $(shell wx-config --cxxflags)
|
WX_CXXFLAGS = $(shell wx-config --cxxflags)
|
||||||
WX_RES = $(shell wx-config --rescomp)
|
WX_RES = $(shell wx-config --rescomp)
|
||||||
|
|
||||||
DEV_CXXFLAGS = -g -Wall -Wextra -DDEBUG
|
DEV_CXXFLAGS = -g -Wall -Wextra -DDEBUG -DSTATIC_BUILD
|
||||||
CXXFLAGS = -Os -DNDEBUG
|
CXXFLAGS = -Os -DNDEBUG -DSTATIC_BUILD
|
||||||
|
|
||||||
TEST_SRC = $(wildcard tests/*.cpp)
|
TEST_SRC = $(wildcard tests/*.cpp)
|
||||||
TESTS = $(patsubst %.cpp,%,$(TEST_SRC))
|
TESTS = $(patsubst %.cpp,%,$(TEST_SRC))
|
||||||
@ -51,11 +51,6 @@ json_wrapper_build:
|
|||||||
build:
|
build:
|
||||||
@mkdir -p build
|
@mkdir -p build
|
||||||
|
|
||||||
sftp_o:
|
|
||||||
$(CXX) -static $(CXXFLAGS) $(LDLIBS) -c -o src/network/SFTP.o src/network/SFTP.cpp
|
|
||||||
|
|
||||||
$(TYRO_LIB): build sftp_o
|
|
||||||
$(TYRO_LIB): OBJECTS += src/network/SFTP.o
|
|
||||||
$(TYRO_LIB): $(OBJECTS)
|
$(TYRO_LIB): $(OBJECTS)
|
||||||
ar rcs $@ $(OBJECTS)
|
ar rcs $@ $(OBJECTS)
|
||||||
ranlib $@
|
ranlib $@
|
||||||
|
File diff suppressed because one or more lines are too long
@ -55,8 +55,6 @@
|
|||||||
"error": [220, 50, 47]
|
"error": [220, 50, 47]
|
||||||
},
|
},
|
||||||
"bold": {
|
"bold": {
|
||||||
"keyword1": true,
|
|
||||||
"keyword2": true,
|
|
||||||
"operator": true,
|
"operator": true,
|
||||||
"label": true,
|
"label": true,
|
||||||
"error": true,
|
"error": true,
|
||||||
|
@ -1,11 +1,6 @@
|
|||||||
/***************************************************************
|
/**
|
||||||
* Name: TyroApp.cpp
|
* Main application file
|
||||||
* Purpose: Code for Application Class
|
*/
|
||||||
* Author: Timothy J Warren (tim@timshomepage.net)
|
|
||||||
* Created: 2015-03-30
|
|
||||||
* Copyright: Timothy J Warren (https://timshomepage.net)
|
|
||||||
* License:
|
|
||||||
**************************************************************/
|
|
||||||
|
|
||||||
#include "wx_common.h"
|
#include "wx_common.h"
|
||||||
|
|
||||||
@ -27,6 +22,11 @@ private:
|
|||||||
|
|
||||||
IMPLEMENT_APP(TyroApp);
|
IMPLEMENT_APP(TyroApp);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start the event loop and create the main window
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
bool TyroApp::OnInit()
|
bool TyroApp::OnInit()
|
||||||
{
|
{
|
||||||
this->SetAppName(APP_NAME);
|
this->SetAppName(APP_NAME);
|
||||||
@ -43,6 +43,11 @@ bool TyroApp::OnInit()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exit handler
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
int TyroApp::OnExit()
|
int TyroApp::OnExit()
|
||||||
{
|
{
|
||||||
return close(true);
|
return close(true);
|
||||||
|
@ -5,15 +5,6 @@
|
|||||||
#ifndef DEFINITIONS_H
|
#ifndef DEFINITIONS_H
|
||||||
#define DEFINITIONS_H
|
#define DEFINITIONS_H
|
||||||
|
|
||||||
// Top level menus
|
|
||||||
enum {
|
|
||||||
myFILE_MENU,
|
|
||||||
myEDIT_MENU,
|
|
||||||
myVIEW_MENU,
|
|
||||||
myLANG_MENU,
|
|
||||||
myHELP_MENU
|
|
||||||
};
|
|
||||||
|
|
||||||
// Application config
|
// Application config
|
||||||
const wxString APP_NAME = "Tyro";
|
const wxString APP_NAME = "Tyro";
|
||||||
const wxString APP_VENDOR = "Aviat Ion";
|
const wxString APP_VENDOR = "Aviat Ion";
|
||||||
@ -27,6 +18,7 @@ const wxString TYRO_OPEN_ERROR_CAPTION = "Open Failed";
|
|||||||
|
|
||||||
// EditPane file extension to lexer mapping
|
// EditPane file extension to lexer mapping
|
||||||
typedef map<string, int> StringConstMap;
|
typedef map<string, int> StringConstMap;
|
||||||
|
typedef map<string, string> StringMap;
|
||||||
|
|
||||||
const wxString TYRO_FILE_OPEN_WILDCARDS =
|
const wxString TYRO_FILE_OPEN_WILDCARDS =
|
||||||
"All files (*.*)|*|"
|
"All files (*.*)|*|"
|
||||||
|
@ -5,11 +5,11 @@ EditPane::EditPane(
|
|||||||
const wxSize &size, long style
|
const wxSize &size, long style
|
||||||
) : wxStyledTextCtrl (parent, id, pos, size, style)
|
) : wxStyledTextCtrl (parent, id, pos, size, style)
|
||||||
{
|
{
|
||||||
#include "../../config/languages_json.h"
|
#include <config/languages_json.h>
|
||||||
lang_config = new TyroConfig();
|
lang_config = new TyroConfig();
|
||||||
lang_config->LoadJson(languages_json);
|
lang_config->LoadJson(languages_json);
|
||||||
|
|
||||||
#include "../../config/themes_json.h"
|
#include <config/themes_json.h>
|
||||||
theme_config = new TyroConfig();
|
theme_config = new TyroConfig();
|
||||||
theme_config->LoadJson(themes_json);
|
theme_config->LoadJson(themes_json);
|
||||||
|
|
||||||
@ -105,8 +105,6 @@ void EditPane::Highlight(wxString filePath)
|
|||||||
this->MarkerDefine (wxSTC_MARKNUM_FOLDERTAIL, wxSTC_MARK_LCORNER, "BLACK", "BLACK");
|
this->MarkerDefine (wxSTC_MARKNUM_FOLDERTAIL, wxSTC_MARK_LCORNER, "BLACK", "BLACK");
|
||||||
|
|
||||||
this->SetLayoutCache (wxSTC_CACHE_CARET);
|
this->SetLayoutCache (wxSTC_CACHE_CARET);
|
||||||
//this->SetViewWhiteSpace(wxSTC_WS_VISIBLEALWAYS);
|
|
||||||
|
|
||||||
|
|
||||||
// set spaces and indention
|
// set spaces and indention
|
||||||
this->SetTabWidth(4);
|
this->SetTabWidth(4);
|
||||||
|
@ -3,6 +3,20 @@
|
|||||||
*/
|
*/
|
||||||
#include "MainFrame.h"
|
#include "MainFrame.h"
|
||||||
|
|
||||||
|
// Top level menus
|
||||||
|
enum {
|
||||||
|
myFILE_MENU,
|
||||||
|
myEDIT_MENU,
|
||||||
|
myVIEW_MENU,
|
||||||
|
myLANG_MENU,
|
||||||
|
myHELP_MENU
|
||||||
|
};
|
||||||
|
|
||||||
|
// Menu ids
|
||||||
|
enum {
|
||||||
|
myID_VIEW_WHITESPACE = wxID_HIGHEST
|
||||||
|
};
|
||||||
|
|
||||||
MainFrame::MainFrame(wxFrame *frame, const wxString &title)
|
MainFrame::MainFrame(wxFrame *frame, const wxString &title)
|
||||||
: wxFrame(frame, -1, title)
|
: wxFrame(frame, -1, title)
|
||||||
{
|
{
|
||||||
@ -102,7 +116,7 @@ void MainFrame::SetupToolbar()
|
|||||||
void MainFrame::SetupMenu()
|
void MainFrame::SetupMenu()
|
||||||
{
|
{
|
||||||
// create a menu bar
|
// create a menu bar
|
||||||
mbar = new wxMenuBar();
|
this->mbar = new wxMenuBar();
|
||||||
|
|
||||||
// Create Base menus
|
// Create Base menus
|
||||||
fileMenu = new wxMenu("");
|
fileMenu = new wxMenu("");
|
||||||
@ -132,16 +146,18 @@ void MainFrame::SetupMenu()
|
|||||||
//editMenu->Append(wxID_FIND, "&Find\tCtrl+F");
|
//editMenu->Append(wxID_FIND, "&Find\tCtrl+F");
|
||||||
//editMenu->Append(wxID_REPLACE, "&Replace\tCtrl+R");
|
//editMenu->Append(wxID_REPLACE, "&Replace\tCtrl+R");
|
||||||
//editMenu->AppendSeparator();
|
//editMenu->AppendSeparator();
|
||||||
editMenu->Append(wxID_SELECTALL, "Select All\tCtrl+A", "Select all the text in the current document");
|
editMenu->Append(wxID_SELECTALL, "Select All\tCtrl+A", "Select all the text in the current document");
|
||||||
|
|
||||||
|
viewMenu->AppendCheckItem(myID_VIEW_WHITESPACE, "Show Invisible Characters\tCtrl+Shift+I", "Toggle visibility of white space characters");
|
||||||
|
|
||||||
helpMenu->Append(wxID_ABOUT, "&About...\tF1", "Show info about this application");
|
helpMenu->Append(wxID_ABOUT, "&About...\tF1", "Show info about this application");
|
||||||
|
|
||||||
// Add the menus to the menubar
|
// Add the menus to the menubar
|
||||||
mbar->Append(fileMenu, "&File");
|
this->mbar->Append(fileMenu, "&File");
|
||||||
mbar->Append(editMenu, "&Edit");
|
this->mbar->Append(editMenu, "&Edit");
|
||||||
//mbar->Append(viewMenu, "&View");
|
this->mbar->Append(viewMenu, "&View");
|
||||||
//mbar->Append(langMenu, "&Language");
|
this->mbar->Append(langMenu, "&Language");
|
||||||
mbar->Append(helpMenu, "&Help");
|
this->mbar->Append(helpMenu, "&Help");
|
||||||
|
|
||||||
#ifdef __WXMAC__
|
#ifdef __WXMAC__
|
||||||
wxMenuBar::MacSetCommonMenuBar(mbar);
|
wxMenuBar::MacSetCommonMenuBar(mbar);
|
||||||
@ -171,6 +187,7 @@ void MainFrame::BindEvents()
|
|||||||
Bind(wxEVT_COMMAND_MENU_SELECTED, &MainFrame::OnEditSelectAll, this, wxID_SELECTALL);
|
Bind(wxEVT_COMMAND_MENU_SELECTED, &MainFrame::OnEditSelectAll, this, wxID_SELECTALL);
|
||||||
Bind(wxEVT_COMMAND_MENU_SELECTED, &MainFrame::OnEditUndo, this, wxID_UNDO);
|
Bind(wxEVT_COMMAND_MENU_SELECTED, &MainFrame::OnEditUndo, this, wxID_UNDO);
|
||||||
Bind(wxEVT_COMMAND_MENU_SELECTED, &MainFrame::OnEditRedo, this, wxID_REDO);
|
Bind(wxEVT_COMMAND_MENU_SELECTED, &MainFrame::OnEditRedo, this, wxID_REDO);
|
||||||
|
Bind(wxEVT_COMMAND_MENU_SELECTED, &MainFrame::OnToggleWhitespace, this, myID_VIEW_WHITESPACE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainFrame::OnNew(wxCommandEvent &WXUNUSED(event))
|
void MainFrame::OnNew(wxCommandEvent &WXUNUSED(event))
|
||||||
@ -181,18 +198,24 @@ void MainFrame::OnNew(wxCommandEvent &WXUNUSED(event))
|
|||||||
|
|
||||||
void MainFrame::OnOpen(wxCommandEvent &WXUNUSED(event))
|
void MainFrame::OnOpen(wxCommandEvent &WXUNUSED(event))
|
||||||
{
|
{
|
||||||
wxString filename;
|
wxArrayString filelist;
|
||||||
|
int listcount;
|
||||||
|
|
||||||
wxFileDialog dlg (this, _T("Open file"), wxEmptyString, wxEmptyString,
|
wxFileDialog dlg (this, "Open file(s)", wxEmptyString, wxEmptyString,
|
||||||
TYRO_FILE_OPEN_WILDCARDS, wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_CHANGE_DIR);
|
TYRO_FILE_OPEN_WILDCARDS, wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_CHANGE_DIR | wxFD_MULTIPLE);
|
||||||
|
|
||||||
if (dlg.ShowModal() != wxID_OK) return;
|
if (dlg.ShowModal() != wxID_OK) return;
|
||||||
|
|
||||||
filename = dlg.GetPath();
|
dlg.GetPaths(filelist);
|
||||||
|
listcount = filelist.GetCount();
|
||||||
|
|
||||||
this->EnableEditControls();
|
// Open a new tab for each file
|
||||||
|
for (int i = 0; i < listcount; i++)
|
||||||
|
{
|
||||||
|
notebook->AddTab(filelist[i]);
|
||||||
|
}
|
||||||
|
|
||||||
notebook->AddTab(filename);
|
this->EnableEditControls(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainFrame::OnClose(wxAuiNotebookEvent &event)
|
void MainFrame::OnClose(wxAuiNotebookEvent &event)
|
||||||
@ -228,6 +251,12 @@ void MainFrame::OnClose(wxAuiNotebookEvent &event)
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event handler triggered after a tab is closed
|
||||||
|
*
|
||||||
|
* @param WXUNUSED
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
void MainFrame::OnClosed(wxAuiNotebookEvent &WXUNUSED(event))
|
void MainFrame::OnClosed(wxAuiNotebookEvent &WXUNUSED(event))
|
||||||
{
|
{
|
||||||
if (notebook->GetPageCount() == 0)
|
if (notebook->GetPageCount() == 0)
|
||||||
@ -350,6 +379,21 @@ void MainFrame::OnAbout(wxCommandEvent &WXUNUSED(event))
|
|||||||
wxAboutBox(info);
|
wxAboutBox(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Toggle display of invisibles
|
||||||
|
*
|
||||||
|
* @param wxCommandEvent& event
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
void MainFrame::OnToggleWhitespace(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
int flag = (event.IsChecked())
|
||||||
|
? wxSTC_WS_VISIBLEALWAYS
|
||||||
|
: wxSTC_WS_INVISIBLE;
|
||||||
|
|
||||||
|
notebook->GetCurrentEditor()->SetViewWhiteSpace(flag);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Toggle enable/disable of document-specific controls
|
* Toggle enable/disable of document-specific controls
|
||||||
*
|
*
|
||||||
@ -358,20 +402,18 @@ void MainFrame::OnAbout(wxCommandEvent &WXUNUSED(event))
|
|||||||
*/
|
*/
|
||||||
void MainFrame::EnableEditControls(bool enable)
|
void MainFrame::EnableEditControls(bool enable)
|
||||||
{
|
{
|
||||||
fileMenu->Enable(wxID_SAVE, enable);
|
this->fileMenu->Enable(wxID_SAVE, enable);
|
||||||
fileMenu->Enable(wxID_SAVEAS, enable);
|
this->fileMenu->Enable(wxID_SAVEAS, enable);
|
||||||
fileMenu->Enable(wxID_CLOSE, enable);
|
this->fileMenu->Enable(wxID_CLOSE, enable);
|
||||||
|
|
||||||
editMenu->Enable(wxID_CUT, enable);
|
// Enable/disable top level menus
|
||||||
editMenu->Enable(wxID_COPY, enable);
|
this->mbar->EnableTop(myEDIT_MENU, enable);
|
||||||
editMenu->Enable(wxID_PASTE, enable);
|
this->mbar->EnableTop(myVIEW_MENU, enable);
|
||||||
editMenu->Enable(wxID_CLEAR, enable);
|
this->mbar->EnableTop(myLANG_MENU, enable);
|
||||||
//editMenu->Enable(wxID_FIND, enable);
|
|
||||||
editMenu->Enable(wxID_SELECTALL, enable);
|
|
||||||
|
|
||||||
toolBar->EnableTool(wxID_SAVE, enable);
|
this->toolBar->EnableTool(wxID_SAVE, enable);
|
||||||
toolBar->EnableTool(wxID_CLOSE, enable);
|
this->toolBar->EnableTool(wxID_CLOSE, enable);
|
||||||
toolBar->EnableTool(wxID_COPY, enable);
|
this->toolBar->EnableTool(wxID_COPY, enable);
|
||||||
toolBar->EnableTool(wxID_CUT, enable);
|
this->toolBar->EnableTool(wxID_CUT, enable);
|
||||||
toolBar->EnableTool(wxID_PASTE, enable);
|
this->toolBar->EnableTool(wxID_PASTE, enable);
|
||||||
}
|
}
|
||||||
|
@ -49,6 +49,7 @@ class MainFrame: public wxFrame
|
|||||||
void OnEditUndo(wxCommandEvent &event);
|
void OnEditUndo(wxCommandEvent &event);
|
||||||
void OnEditRedo(wxCommandEvent &event);
|
void OnEditRedo(wxCommandEvent &event);
|
||||||
void OnCloseTab(wxCommandEvent &event);
|
void OnCloseTab(wxCommandEvent &event);
|
||||||
|
void OnToggleWhitespace(wxCommandEvent &event);
|
||||||
void OnQuit(wxCommandEvent &event);
|
void OnQuit(wxCommandEvent &event);
|
||||||
void OnAbout(wxCommandEvent &event);
|
void OnAbout(wxCommandEvent &event);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user