Basic syntax highlighting for C++
This commit is contained in:
parent
6baf169283
commit
cdda8c2ffe
@ -77,7 +77,7 @@ string SFTP::getFile(const char *path)
|
|||||||
|
|
||||||
void SFTP::ssh_connect(const char *host, const char *user, const char *pass, const char *port)
|
void SFTP::ssh_connect(const char *host, const char *user, const char *pass, const char *port)
|
||||||
{
|
{
|
||||||
#ifdef __WXWIN__
|
#ifdef WIN32
|
||||||
WSADATA wsadata;
|
WSADATA wsadata;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
|
@ -11,7 +11,9 @@ EditPane::EditPane(
|
|||||||
{"cpp", wxSTC_LEX_CPP},
|
{"cpp", wxSTC_LEX_CPP},
|
||||||
{"cxx", wxSTC_LEX_CPP},
|
{"cxx", wxSTC_LEX_CPP},
|
||||||
{"py", wxSTC_LEX_PYTHON},
|
{"py", wxSTC_LEX_PYTHON},
|
||||||
{"php", wxSTC_LEX_PHPSCRIPT}
|
{"php", wxSTC_LEX_PHPSCRIPT},
|
||||||
|
{"js", wxSTC_LEX_ESCRIPT},
|
||||||
|
{"json", wxSTC_LEX_ESCRIPT}
|
||||||
};
|
};
|
||||||
|
|
||||||
lexer_map = StringConstMap(
|
lexer_map = StringConstMap(
|
||||||
@ -22,6 +24,11 @@ EditPane::EditPane(
|
|||||||
|
|
||||||
EditPane::~EditPane() {}
|
EditPane::~EditPane() {}
|
||||||
|
|
||||||
|
void EditPane::OnSize(wxSizeEvent &event)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encapsulate lexer selection when opening a file
|
* Encapsulate lexer selection when opening a file
|
||||||
*
|
*
|
||||||
@ -32,9 +39,51 @@ bool EditPane::LoadAndHighlight(wxString filePath)
|
|||||||
{
|
{
|
||||||
wxFileName file(filePath);
|
wxFileName file(filePath);
|
||||||
wxString ext = file.GetExt();
|
wxString ext = file.GetExt();
|
||||||
|
|
||||||
|
this->StyleSetForeground (wxSTC_STYLE_DEFAULT, wxColor(101, 123, 131));
|
||||||
|
this->StyleSetBackground (wxSTC_STYLE_DEFAULT, wxColor(253, 246, 227));
|
||||||
|
this->StyleSetForeground(wxSTC_STYLE_INDENTGUIDE, wxColor(147, 161, 161));
|
||||||
|
|
||||||
|
this->SetMarginWidth (MARGIN_LINE_NUMBERS, 50);
|
||||||
|
this->StyleSetForeground (wxSTC_STYLE_LINENUMBER, wxColor(147, 161, 161));
|
||||||
|
this->StyleSetBackground (wxSTC_STYLE_LINENUMBER, wxColor(238, 232, 213));
|
||||||
|
this->SetMarginType (MARGIN_LINE_NUMBERS, wxSTC_MARGIN_NUMBER);
|
||||||
|
|
||||||
|
this->SetProperty (wxT("fold"), wxT("1") );
|
||||||
|
this->SetProperty (wxT("fold.comment"), wxT("1") );
|
||||||
|
this->SetProperty (wxT("fold.compact"), wxT("1") );
|
||||||
|
|
||||||
|
|
||||||
|
this->StyleSetForeground (wxSTC_C_STRING, wxColour(150,0,0));
|
||||||
|
this->StyleSetBackground (wxSTC_C_STRING, wxColor(253, 246, 227));
|
||||||
|
this->StyleSetForeground (wxSTC_C_PREPROCESSOR, wxColour(165,105,0));
|
||||||
|
this->StyleSetBackground (wxSTC_C_PREPROCESSOR, wxColor(253, 246, 227));
|
||||||
|
this->StyleSetForeground (wxSTC_C_IDENTIFIER, wxColour(40,0,60));
|
||||||
|
this->StyleSetBackground (wxSTC_C_IDENTIFIER, wxColor(253, 246, 227));
|
||||||
|
this->StyleSetForeground (wxSTC_C_NUMBER, wxColour(0,150,0));
|
||||||
|
this->StyleSetBackground (wxSTC_C_NUMBER, wxColor(253, 246, 227));
|
||||||
|
this->StyleSetForeground (wxSTC_C_CHARACTER, wxColour(150,0,0));
|
||||||
|
this->StyleSetBackground (wxSTC_C_CHARACTER, wxColor(253, 246, 227));
|
||||||
|
this->StyleSetForeground (wxSTC_C_WORD, wxColour(0,0,150));
|
||||||
|
this->StyleSetBackground (wxSTC_C_WORD, wxColor(253, 246, 227));
|
||||||
|
this->StyleSetForeground (wxSTC_C_WORD2, wxColour(0,150,0));
|
||||||
|
this->StyleSetBackground (wxSTC_C_WORD2, wxColor(253, 246, 227));
|
||||||
|
this->StyleSetForeground (wxSTC_C_COMMENT, wxColor(147, 161, 161));
|
||||||
|
this->StyleSetBackground (wxSTC_C_COMMENT, wxColor(253, 246, 227));
|
||||||
|
this->StyleSetForeground (wxSTC_C_COMMENTLINE, wxColor(147, 161, 161));
|
||||||
|
this->StyleSetBackground (wxSTC_C_COMMENTLINE, wxColor(253, 246, 227));
|
||||||
|
this->StyleSetForeground (wxSTC_C_COMMENTDOC, wxColor(147, 161, 161));
|
||||||
|
this->StyleSetBackground (wxSTC_C_COMMENTDOC, wxColor(253, 246, 227));
|
||||||
|
this->StyleSetForeground (wxSTC_C_COMMENTDOCKEYWORD, wxColour(0,0,200));
|
||||||
|
this->StyleSetBackground (wxSTC_C_COMMENTDOCKEYWORD, wxColor(253, 246, 227));
|
||||||
|
this->StyleSetForeground (wxSTC_C_COMMENTDOCKEYWORDERROR, wxColour(0,0,200));
|
||||||
|
this->StyleSetBackground (wxSTC_C_COMMENTDOCKEYWORDERROR, wxColor(253, 246, 227));
|
||||||
|
/*this->StyleSetBold(wxSTC_C_WORD, true);
|
||||||
|
this->StyleSetBold(wxSTC_C_WORD2, true);
|
||||||
|
this->StyleSetBold(wxSTC_C_COMMENTDOCKEYWORD, true);*/
|
||||||
|
|
||||||
//lexer_map_it = lexer_map.find((string) ext);
|
lexer_map_it = lexer_map.find((string) ext);
|
||||||
//this->SetLexer(lexer_map_it->second);
|
this->SetLexer(lexer_map_it->second);
|
||||||
|
|
||||||
return this->LoadFile(filePath);
|
return this->LoadFile(filePath);
|
||||||
}
|
}
|
||||||
|
@ -22,8 +22,14 @@ public:
|
|||||||
wxVSCROLL
|
wxVSCROLL
|
||||||
);
|
);
|
||||||
~EditPane();
|
~EditPane();
|
||||||
|
void OnSize(wxSizeEvent &event);
|
||||||
bool LoadAndHighlight(wxString filePath);
|
bool LoadAndHighlight(wxString filePath);
|
||||||
private:
|
private:
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
MARGIN_LINE_NUMBERS,
|
||||||
|
MARGIN_FOLD
|
||||||
|
};
|
||||||
StringConstMap lexer_map;
|
StringConstMap lexer_map;
|
||||||
StringConstMap::iterator lexer_map_it;
|
StringConstMap::iterator lexer_map_it;
|
||||||
};
|
};
|
||||||
|
@ -92,6 +92,7 @@ void MainFrame::SetupMenu()
|
|||||||
// Create Base menus
|
// Create Base menus
|
||||||
fileMenu = new wxMenu(_T(""));
|
fileMenu = new wxMenu(_T(""));
|
||||||
editMenu = new wxMenu(_T(""));
|
editMenu = new wxMenu(_T(""));
|
||||||
|
viewMenu = new wxMenu(_T(""));
|
||||||
helpMenu = new wxMenu(_T(""));
|
helpMenu = new wxMenu(_T(""));
|
||||||
|
|
||||||
// Add items to top-level menus
|
// Add items to top-level menus
|
||||||
@ -108,6 +109,7 @@ void MainFrame::SetupMenu()
|
|||||||
fileMenu->Enable(wxID_SAVEAS, false);
|
fileMenu->Enable(wxID_SAVEAS, false);
|
||||||
fileMenu->Enable(wxID_CLOSE, false);
|
fileMenu->Enable(wxID_CLOSE, false);
|
||||||
|
|
||||||
|
|
||||||
editMenu->Append(wxID_UNDO, _T("&Undo\tCtrl+Z"), _T("Undo last action"));
|
editMenu->Append(wxID_UNDO, _T("&Undo\tCtrl+Z"), _T("Undo last action"));
|
||||||
editMenu->Append(wxID_REDO, _T("&Redo\tCtrl+Y"), _T("Redo last action"));
|
editMenu->Append(wxID_REDO, _T("&Redo\tCtrl+Y"), _T("Redo last action"));
|
||||||
editMenu->AppendSeparator();
|
editMenu->AppendSeparator();
|
||||||
@ -127,13 +129,14 @@ void MainFrame::SetupMenu()
|
|||||||
editMenu->Enable(wxID_PASTE, false);
|
editMenu->Enable(wxID_PASTE, false);
|
||||||
editMenu->Enable(wxID_CLEAR, false);
|
editMenu->Enable(wxID_CLEAR, false);
|
||||||
editMenu->Enable(wxID_FIND, false);
|
editMenu->Enable(wxID_FIND, false);
|
||||||
editMenu->Enable(wxID_SELECTALL, false);
|
editMenu->Enable(wxID_SELECTALL, false);
|
||||||
|
|
||||||
helpMenu->Append(wxID_ABOUT, _T("&About...\tF1"), _T("Show info about this application"));
|
helpMenu->Append(wxID_ABOUT, _T("&About...\tF1"), _T("Show info about this application"));
|
||||||
|
|
||||||
// Add the menus to the menubar
|
// Add the menus to the menubar
|
||||||
mbar->Append(fileMenu, _T("&File"));
|
mbar->Append(fileMenu, _T("&File"));
|
||||||
mbar->Append(editMenu, _T("&Edit"));
|
mbar->Append(editMenu, _T("&Edit"));
|
||||||
|
mbar->Append(viewMenu, _T("&View"));
|
||||||
mbar->Append(helpMenu, _T("&Help"));
|
mbar->Append(helpMenu, _T("&Help"));
|
||||||
|
|
||||||
#ifdef __WXMAC__
|
#ifdef __WXMAC__
|
||||||
@ -178,18 +181,18 @@ void MainFrame::OnOpen(wxCommandEvent &WXUNUSED(event))
|
|||||||
|
|
||||||
void MainFrame::OnFileClose(wxCommandEvent &WXUNUSED(event))
|
void MainFrame::OnFileClose(wxCommandEvent &WXUNUSED(event))
|
||||||
{
|
{
|
||||||
|
// @TODO Implement OnFileClose
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainFrame::OnSave(wxCommandEvent &WXUNUSED(event))
|
void MainFrame::OnSave(wxCommandEvent &WXUNUSED(event))
|
||||||
{
|
{
|
||||||
|
// @TODO Implement OnSave
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainFrame::OnSaveAs(wxCommandEvent &WXUNUSED(event))
|
void MainFrame::OnSaveAs(wxCommandEvent &WXUNUSED(event))
|
||||||
{
|
{
|
||||||
|
// @TODO Implement OnSaveAs
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainFrame::OnQuit(wxCommandEvent &WXUNUSED(event))
|
void MainFrame::OnQuit(wxCommandEvent &WXUNUSED(event))
|
||||||
{
|
{
|
||||||
@ -247,7 +250,5 @@ void MainFrame::OnAbout(wxCommandEvent &WXUNUSED(event))
|
|||||||
info.SetDescription("Tyro, a text editor for all development");
|
info.SetDescription("Tyro, a text editor for all development");
|
||||||
info.SetCopyright(_T(" (C) 2015, Timothy J Warren"));
|
info.SetCopyright(_T(" (C) 2015, Timothy J Warren"));
|
||||||
|
|
||||||
wxGenericAboutDialog dlg;
|
wxAboutBox(info);
|
||||||
dlg.Create(info, this);
|
|
||||||
dlg.ShowModal();
|
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
#include "../TyroApp.h"
|
#include "../TyroApp.h"
|
||||||
|
|
||||||
#include <wx/aboutdlg.h>
|
#include <wx/aboutdlg.h>
|
||||||
#include <wx/generic/aboutdlgg.h>
|
|
||||||
|
|
||||||
#include "TabContainer.h"
|
#include "TabContainer.h"
|
||||||
|
|
||||||
@ -25,6 +24,7 @@ class MainFrame: public wxFrame
|
|||||||
wxMenuBar *mbar;
|
wxMenuBar *mbar;
|
||||||
wxMenu *fileMenu;
|
wxMenu *fileMenu;
|
||||||
wxMenu *editMenu;
|
wxMenu *editMenu;
|
||||||
|
wxMenu *viewMenu;
|
||||||
wxMenu *helpMenu;
|
wxMenu *helpMenu;
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user