New file style matches open file style, fiddling with find/replace logic
This commit is contained in:
parent
79650c6dbd
commit
bb91005549
@ -37,6 +37,41 @@ EditPane::EditPane(
|
|||||||
lexerMap["yaml"] = wxSTC_LEX_YAML;
|
lexerMap["yaml"] = wxSTC_LEX_YAML;
|
||||||
|
|
||||||
this->BindEvents();
|
this->BindEvents();
|
||||||
|
|
||||||
|
// Some basic properties to set
|
||||||
|
this->SetStyleBits(8);
|
||||||
|
this->SetScrollWidthTracking(true);// Set scroll width by longest line
|
||||||
|
this->SetProperty("technology", "2");
|
||||||
|
this->SetProperty("error.inline", "0");
|
||||||
|
this->SetProperty("styling.within.preprocessor", "1");
|
||||||
|
this->SetProperty("lexer.cpp.track.preprocessor", "1");
|
||||||
|
this->SetProperty("font.quality", "3"); // LCD Optimized
|
||||||
|
|
||||||
|
// Set up Code folding
|
||||||
|
this->SetProperty("fold", "1");
|
||||||
|
this->SetProperty("fold.comment", "1");
|
||||||
|
this->SetProperty("fold.compact", "1");
|
||||||
|
this->SetProperty("fold.html", "1");
|
||||||
|
this->SetFoldFlags(wxSTC_FOLDFLAG_LINEBEFORE_CONTRACTED | wxSTC_FOLDFLAG_LINEAFTER_CONTRACTED);
|
||||||
|
this->SetMarginType(MARGIN_FOLD, wxSTC_MARGIN_SYMBOL);
|
||||||
|
this->SetMarginWidth(MARGIN_FOLD, 16);
|
||||||
|
this->SetMarginSensitive(MARGIN_FOLD, true);
|
||||||
|
this->SetMarginMask(MARGIN_FOLD, wxSTC_MASK_FOLDERS);
|
||||||
|
this->MarkerDefine(wxSTC_MARKNUM_FOLDER, wxSTC_MARK_BOXPLUSCONNECTED, "WHITE", "BLACK");
|
||||||
|
this->MarkerDefine(wxSTC_MARKNUM_FOLDEROPEN, wxSTC_MARK_BOXMINUSCONNECTED, "WHITE", "BLACK");
|
||||||
|
this->MarkerDefine(wxSTC_MARKNUM_FOLDERSUB, wxSTC_MARK_VLINE, "BLACK", "BLACK");
|
||||||
|
this->MarkerDefine(wxSTC_MARKNUM_FOLDEREND, wxSTC_MARK_CIRCLEPLUSCONNECTED, "WHITE", "BLACK");
|
||||||
|
this->MarkerDefine(wxSTC_MARKNUM_FOLDEROPENMID, wxSTC_MARK_CIRCLEMINUSCONNECTED, "WHITE", "BLACK");
|
||||||
|
this->MarkerDefine(wxSTC_MARKNUM_FOLDERMIDTAIL, wxSTC_MARK_TCORNER, "BLACK", "BLACK");
|
||||||
|
this->MarkerDefine(wxSTC_MARKNUM_FOLDERTAIL, wxSTC_MARK_LCORNER, "BLACK", "BLACK");
|
||||||
|
|
||||||
|
this->SetLayoutCache (wxSTC_CACHE_DOCUMENT);
|
||||||
|
|
||||||
|
// set spaces and indention
|
||||||
|
this->SetTabWidth(4);
|
||||||
|
|
||||||
|
// Blank highlight
|
||||||
|
this->Highlight("");
|
||||||
}
|
}
|
||||||
|
|
||||||
EditPane::~EditPane()
|
EditPane::~EditPane()
|
||||||
@ -70,40 +105,9 @@ void EditPane::Highlight(wxString filePath)
|
|||||||
this->SetLexer(wxSTC_LEX_NULL);
|
this->SetLexer(wxSTC_LEX_NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Some basic properties to set
|
|
||||||
this->SetStyleBits(8);
|
|
||||||
this->SetProperty("technology", "2");
|
|
||||||
this->SetProperty("error.inline", "0");
|
|
||||||
this->SetProperty("styling.within.preprocessor", "1");
|
|
||||||
this->SetProperty("lexer.cpp.track.preprocessor", "1");
|
|
||||||
this->SetProperty("font.quality", "3"); // LCD Optimized
|
|
||||||
|
|
||||||
// Apply the theme
|
// Apply the theme
|
||||||
this->ApplyTheme(lang);
|
this->ApplyTheme(lang);
|
||||||
|
|
||||||
// Set up Code folding
|
|
||||||
this->SetProperty("fold", "1");
|
|
||||||
this->SetProperty("fold.comment", "1");
|
|
||||||
this->SetProperty("fold.compact", "1");
|
|
||||||
this->SetProperty("fold.html", "1");
|
|
||||||
this->SetFoldFlags(wxSTC_FOLDFLAG_LINEBEFORE_CONTRACTED | wxSTC_FOLDFLAG_LINEAFTER_CONTRACTED);
|
|
||||||
this->SetMarginType(MARGIN_FOLD, wxSTC_MARGIN_SYMBOL);
|
|
||||||
this->SetMarginWidth(MARGIN_FOLD, 16);
|
|
||||||
this->SetMarginSensitive(MARGIN_FOLD, true);
|
|
||||||
this->SetMarginMask(MARGIN_FOLD, wxSTC_MASK_FOLDERS);
|
|
||||||
this->MarkerDefine (wxSTC_MARKNUM_FOLDER, wxSTC_MARK_BOXPLUSCONNECTED, "WHITE", "BLACK");
|
|
||||||
this->MarkerDefine (wxSTC_MARKNUM_FOLDEROPEN, wxSTC_MARK_BOXMINUSCONNECTED, "WHITE", "BLACK");
|
|
||||||
this->MarkerDefine (wxSTC_MARKNUM_FOLDERSUB, wxSTC_MARK_VLINE, "BLACK", "BLACK");
|
|
||||||
this->MarkerDefine (wxSTC_MARKNUM_FOLDEREND, wxSTC_MARK_CIRCLEPLUSCONNECTED, "WHITE", "BLACK");
|
|
||||||
this->MarkerDefine (wxSTC_MARKNUM_FOLDEROPENMID, wxSTC_MARK_CIRCLEMINUSCONNECTED, "WHITE", "BLACK");
|
|
||||||
this->MarkerDefine (wxSTC_MARKNUM_FOLDERMIDTAIL, wxSTC_MARK_TCORNER, "BLACK", "BLACK");
|
|
||||||
this->MarkerDefine (wxSTC_MARKNUM_FOLDERTAIL, wxSTC_MARK_LCORNER, "BLACK", "BLACK");
|
|
||||||
|
|
||||||
this->SetLayoutCache (wxSTC_CACHE_DOCUMENT);
|
|
||||||
|
|
||||||
// set spaces and indention
|
|
||||||
this->SetTabWidth(4);
|
|
||||||
|
|
||||||
bool use_tabs = (lang != "yaml");
|
bool use_tabs = (lang != "yaml");
|
||||||
|
|
||||||
this->SetUseTabs(use_tabs);
|
this->SetUseTabs(use_tabs);
|
||||||
@ -400,7 +404,7 @@ void EditPane::_ApplyTheme(JsonValue &lexer_map)
|
|||||||
this->StyleSetForeground (wxSTC_STYLE_DEFAULT, default_foreground);
|
this->StyleSetForeground (wxSTC_STYLE_DEFAULT, default_foreground);
|
||||||
this->StyleSetForeground(wxSTC_STYLE_INDENTGUIDE, wxColor(147, 161, 161));
|
this->StyleSetForeground(wxSTC_STYLE_INDENTGUIDE, wxColor(147, 161, 161));
|
||||||
|
|
||||||
this->SetMarginWidth (MARGIN_LINE_NUMBERS, TextWidth(wxSTC_STYLE_LINENUMBER, _T("_99999")));
|
this->SetMarginWidth (MARGIN_LINE_NUMBERS, TextWidth(wxSTC_STYLE_LINENUMBER, "_999"));
|
||||||
this->StyleSetForeground (wxSTC_STYLE_LINENUMBER, line_number_foreground);
|
this->StyleSetForeground (wxSTC_STYLE_LINENUMBER, line_number_foreground);
|
||||||
this->StyleSetBackground (wxSTC_STYLE_LINENUMBER, line_number_background);
|
this->StyleSetBackground (wxSTC_STYLE_LINENUMBER, line_number_background);
|
||||||
this->SetMarginType (MARGIN_LINE_NUMBERS, wxSTC_MARGIN_NUMBER);
|
this->SetMarginType (MARGIN_LINE_NUMBERS, wxSTC_MARGIN_NUMBER);
|
||||||
|
@ -8,7 +8,7 @@ MainFrame::MainFrame(wxFrame *frame, const wxString &title)
|
|||||||
{
|
{
|
||||||
#include "../../resources/xpm/tyro.xpm"
|
#include "../../resources/xpm/tyro.xpm"
|
||||||
|
|
||||||
findReplaceData = new wxFindReplaceData();
|
findReplaceData = new wxFindReplaceData(wxFR_DOWN);
|
||||||
|
|
||||||
wxIcon app_icon(tyro_icon);
|
wxIcon app_icon(tyro_icon);
|
||||||
this->SetIcon(app_icon);
|
this->SetIcon(app_icon);
|
||||||
@ -475,39 +475,70 @@ void MainFrame::OnFindDialog(wxFindDialogEvent &event)
|
|||||||
int stc_flags = 0;
|
int stc_flags = 0;
|
||||||
int fr_flags = event.GetFlags();
|
int fr_flags = event.GetFlags();
|
||||||
|
|
||||||
if ((fr_flags & wxFR_WHOLEWORD) != 0) stc_flags |= wxSTC_FIND_WHOLEWORD;
|
if (fr_flags & wxFR_WHOLEWORD) stc_flags |= wxSTC_FIND_WHOLEWORD;
|
||||||
if ((fr_flags & wxFR_MATCHCASE) != 0) stc_flags |= wxSTC_FIND_MATCHCASE;
|
if (fr_flags & wxFR_MATCHCASE) stc_flags |= wxSTC_FIND_MATCHCASE;
|
||||||
|
|
||||||
|
// Position after search
|
||||||
|
int new_pos = 0;
|
||||||
|
int new_line = 1;
|
||||||
|
|
||||||
// Send find flags to editor control
|
// Send find flags to editor control
|
||||||
editor->SetSearchFlags(stc_flags);
|
editor->SetSearchFlags(stc_flags);
|
||||||
|
|
||||||
if (type == wxEVT_FIND)
|
if (type == wxEVT_FIND)
|
||||||
{
|
{
|
||||||
editor->SearchAnchor(); // Set staring search position at current position
|
wxLogDebug("wxEVT_FIND");
|
||||||
editor->SearchNext(stc_flags, event.GetFindString());
|
|
||||||
}
|
editor->SearchAnchor();
|
||||||
else if (type == wxEVT_FIND_NEXT)
|
|
||||||
{
|
|
||||||
if ((fr_flags & wxFR_DOWN) != 0)
|
if ((fr_flags & wxFR_DOWN) != 0)
|
||||||
{
|
{
|
||||||
editor->SearchNext(stc_flags, event.GetFindString());
|
new_pos = editor->SearchNext(stc_flags, event.GetFindString());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
editor->SearchPrev(stc_flags, event.GetFindString());
|
new_pos = editor->SearchPrev(stc_flags, event.GetFindString());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (new_pos >= 0)
|
||||||
|
{
|
||||||
|
new_line = editor->LineFromPosition(new_pos);
|
||||||
|
editor->ScrollToLine(new_line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (type == wxEVT_FIND_NEXT)
|
||||||
|
{
|
||||||
|
wxLogDebug("wxEVT_FIND_NEXT");
|
||||||
|
|
||||||
|
if ((fr_flags & wxFR_DOWN) != 0)
|
||||||
|
{
|
||||||
|
new_pos = editor->SearchNext(stc_flags, event.GetFindString());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
new_pos = editor->SearchPrev(stc_flags, event.GetFindString());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (new_pos >= 0)
|
||||||
|
{
|
||||||
|
/*editor->SetSelectionStart(editor->GetAnchor());
|
||||||
|
editor->SetSelectionEnd(new_pos);*/
|
||||||
|
|
||||||
|
new_line = editor->LineFromPosition(new_pos);
|
||||||
|
editor->ScrollToLine(new_line);
|
||||||
}
|
}
|
||||||
editor->SearchAnchor();
|
|
||||||
}
|
}
|
||||||
else if (type == wxEVT_FIND_REPLACE)
|
else if (type == wxEVT_FIND_REPLACE)
|
||||||
{
|
{
|
||||||
|
wxLogDebug("wxEVT_FIND_REPLACE");
|
||||||
}
|
}
|
||||||
else if (type == wxEVT_FIND_REPLACE_ALL)
|
else if (type == wxEVT_FIND_REPLACE_ALL)
|
||||||
{
|
{
|
||||||
|
wxLogDebug("wxEVT_FIND_REPLACE_ALL");
|
||||||
}
|
}
|
||||||
else if (type == wxEVT_FIND_CLOSE)
|
else if (type == wxEVT_FIND_CLOSE)
|
||||||
{
|
{
|
||||||
|
wxLogDebug("wxEVT_FIND_CLOSE");
|
||||||
event.GetDialog()->Destroy();
|
event.GetDialog()->Destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user