Yet another progress commit

This commit is contained in:
Timothy Warren 2019-05-16 15:21:32 -04:00
parent 72be1d808f
commit c13750b06e
7 changed files with 82 additions and 98 deletions

20
.editorconfig Normal file
View File

@ -0,0 +1,20 @@
# EditorConfig is awesome: http://EditorConfig.org
# top-most EditorConfig file
root = true
# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = false
charset = utf-8
indent_style = tab
trim_trailing_whitespace = true
[*.{cpp,c,h,hpp,cxx}]
insert_final_newline = true
# Yaml files
[*.{yml,yaml}]
indent_style = space
indent_size = 4

View File

@ -8,11 +8,9 @@
#include <wx/app.h> #include <wx/app.h>
#include <wx/sysopt.h> #include <wx/sysopt.h>
#include <wx/vidmode.h> #include <wx/vidmode.h>
#include <wx/display.h>
#include "src/widgets/MainFrame.h" #include "src/widgets/MainFrame.h"
// Some global stuff // Some global stuff
wxConfigBase *Glob_config = nullptr; wxConfigBase *Glob_config = nullptr;
TyroMenu *Glob_menu_bar = nullptr; TyroMenu *Glob_menu_bar = nullptr;
@ -51,7 +49,7 @@ public:
this->InitLexerMap(); this->InitLexerMap();
Glob_config = wxConfigBase::Get(); Glob_config = wxConfigBase::Get();
Glob_menu_bar = new TyroMenu(); Glob_menu_bar = new TyroMenu();
Glob_main_frame = new MainFrame(nullptr, APP_NAME, this->CalculateWindowSize()); Glob_main_frame = new MainFrame(nullptr, APP_NAME, CalculateWindowSize());
#ifndef TRAVIS #ifndef TRAVIS
Glob_pref_pane = new PrefPane(); Glob_pref_pane = new PrefPane();
#endif #endif
@ -152,21 +150,6 @@ private:
Glob_lexer_map["yaml"] = wxSTC_LEX_YAML; Glob_lexer_map["yaml"] = wxSTC_LEX_YAML;
} }
/**
* Calculate original window size based on size of the current monitor
*/
wxSize CalculateWindowSize()
{
wxDisplay display;
wxVideoMode mode = display.GetCurrentMode();
wxLogDebug("Current display: %ix%i", mode.w, mode.h);
wxSize base((int)((float)mode.w * 0.9), (int)((float)mode.h * 0.9));
return base;
}
/** /**
* Toolkit-specific settings * Toolkit-specific settings
*/ */

View File

@ -17,8 +17,8 @@ const wxString APP_VERSION_MORE = "Pre-release";
const wxCmdLineEntryDesc Glob_cmdLineDesc[] = { const wxCmdLineEntryDesc Glob_cmdLineDesc[] = {
{ {
wxCMD_LINE_PARAM, wxCMD_LINE_PARAM,
NULL, nullptr,
NULL, nullptr,
"input file(s)", "input file(s)",
wxCMD_LINE_VAL_STRING, wxCMD_LINE_VAL_STRING,
wxCMD_LINE_PARAM_OPTIONAL | wxCMD_LINE_PARAM_MULTIPLE wxCMD_LINE_PARAM_OPTIONAL | wxCMD_LINE_PARAM_MULTIPLE

View File

@ -175,9 +175,7 @@ bool EditPane::SaveFile()
{ {
wxString fname = this->fileName.GetFullPath(); wxString fname = this->fileName.GetFullPath();
const wxString cfname(fname); return this->SaveFile(fname);
return this->SaveFile(cfname);
} }
/** /**
@ -332,8 +330,6 @@ void EditPane::_ApplyTheme(JsonValue &lexer_map)
this->StyleSetBackground(i, default_background); this->StyleSetBackground(i, default_background);
this->StyleSetForeground(i, default_foreground); this->StyleSetForeground(i, default_foreground);
if ( ! HAS_FONT_BUG())
{
wxFont globalFont; wxFont globalFont;
wxString fontFace; wxString fontFace;
if ( ! Glob_config->Read("global_font", &globalFont)) if ( ! Glob_config->Read("global_font", &globalFont))
@ -345,11 +341,6 @@ void EditPane::_ApplyTheme(JsonValue &lexer_map)
this->StyleSetFont(i, globalFont); this->StyleSetFont(i, globalFont);
} }
} }
else
{
this->StyleSetFont(i, *defaultFont);
}
}
// Set up Code folding // Set up Code folding
if (Glob_config->ReadBool("show_code_folding", false)) if (Glob_config->ReadBool("show_code_folding", false))

View File

@ -440,15 +440,15 @@ void MainFrame::OnAbout(wxCommandEvent &WXUNUSED(event))
wxString desc = "Tyro, a text editor for all development\n\n" wxString desc = "Tyro, a text editor for all development\n\n"
"System info: \n"; "System info: \n";
desc += wxString::Format("Architecture: %s\n", desc += wxString::Format("\tArchitecture: %s\n",
wxPlatformInfo::GetArchName(plat_info.GetArchitecture())); wxPlatformInfo::GetArchName(plat_info.GetArchitecture()));
desc += wxString::Format("Operating System:\n\t%s %i.%i\n", desc += wxString::Format("\tOperating System:\n\t\t%s %i.%i\n",
wxPlatformInfo::GetOperatingSystemIdName(plat_info.GetOperatingSystemId()), wxPlatformInfo::GetOperatingSystemIdName(plat_info.GetOperatingSystemId()),
plat_info.GetOSMajorVersion(), plat_info.GetOSMajorVersion(),
plat_info.GetOSMinorVersion()); plat_info.GetOSMinorVersion());
desc += wxString::Format("wxWidgets version: %s %i.%i.%i\n", desc += wxString::Format("\nwxWidgets version: %s %i.%i.%i\n",
plat_info.GetPortIdName(), plat_info.GetPortIdName(),
wxMAJOR_VERSION, wxMAJOR_VERSION,
wxMINOR_VERSION, wxMINOR_VERSION,
@ -460,10 +460,10 @@ void MainFrame::OnAbout(wxCommandEvent &WXUNUSED(event))
wxString desk = plat_info.GetDesktopEnvironment(); wxString desk = plat_info.GetDesktopEnvironment();
if (desk != "") if (desk != "")
{ {
desc += wxString::Format("Desktop Environment:%s\n", desk); desc += wxString::Format("\tDesktop Environment:%s\n", desk);
} }
desc += "Distro: "; desc += "\tDistro: ";
desc += dist_info.Description; desc += dist_info.Description;
if (dist_info.CodeName != "") if (dist_info.CodeName != "")

View File

@ -16,22 +16,21 @@ public:
wxSizer *sizer = new wxBoxSizer(wxVERTICAL); wxSizer *sizer = new wxBoxSizer(wxVERTICAL);
// Check that version of OS X is less than 10.10 for wxWidgets < 3.0.3
// Otherwise the font control will segfault
if( ! HAS_FONT_BUG())
{
this->fontPicker = new wxFontPickerCtrl( this->fontPicker = new wxFontPickerCtrl(
this, this,
myID_PREFS_FONT, myID_PREFS_FONT,
wxNullFont, this->GetFont(),
wxDefaultPosition, wxDefaultPosition,
wxDefaultSize, wxDefaultSize,
wxFNTP_USE_TEXTCTRL ^ wxFNTP_USEFONT_FOR_LABEL wxFNTP_FONTDESC_AS_LABEL
); );
this->fontPicker->SetLabelText("Editor Font");
wxSizer *fontSizer = new wxBoxSizer(wxHORIZONTAL); wxSizer *fontSizer = new wxBoxSizer(wxHORIZONTAL);
fontSizer->AddSpacer(50);
fontSizer->Add(this->fontPicker, wxSizerFlags().Border()); fontSizer->Add(this->fontPicker, wxSizerFlags().Border());
fontSizer->AddSpacer(50);
sizer->Add(fontSizer, wxSizerFlags().Border()); sizer->Add(fontSizer, wxSizerFlags().Border());
}
sizer->Add(this->showLineNumbers, wxSizerFlags().Border()); sizer->Add(this->showLineNumbers, wxSizerFlags().Border());
sizer->Add(this->showIndentGuides, wxSizerFlags().Border()); sizer->Add(this->showIndentGuides, wxSizerFlags().Border());
@ -42,15 +41,12 @@ public:
// Change settings on selection, rather than on apply button // Change settings on selection, rather than on apply button
// On supported platforms // On supported platforms
if (wxPreferencesEditor::ShouldApplyChangesImmediately()) if (wxPreferencesEditor::ShouldApplyChangesImmediately())
{
if ( ! HAS_FONT_BUG())
{ {
this->fontPicker->Bind(wxEVT_FONTPICKER_CHANGED, [=] (wxFontPickerEvent &event) { this->fontPicker->Bind(wxEVT_FONTPICKER_CHANGED, [=] (wxFontPickerEvent &event) {
Glob_config->Write("global_font", event.GetFont()); Glob_config->Write("global_font", event.GetFont());
this->frame->OnPrefsChanged(event); this->frame->OnPrefsChanged(event);
Glob_config->Flush(); Glob_config->Flush();
}, myID_PREFS_FONT); }, myID_PREFS_FONT);
}
this->showLineNumbers->Bind(wxEVT_CHECKBOX, [=] (wxCommandEvent &event) { this->showLineNumbers->Bind(wxEVT_CHECKBOX, [=] (wxCommandEvent &event) {
Glob_config->Write("show_line_numbers", event.IsChecked()); Glob_config->Write("show_line_numbers", event.IsChecked());
@ -87,13 +83,10 @@ public:
this->showIndentGuides->SetValue(Glob_config->ReadBool("show_indent_guides", false)); this->showIndentGuides->SetValue(Glob_config->ReadBool("show_indent_guides", false));
this->showCodeFolding->SetValue(Glob_config->ReadBool("show_code_folding", false)); this->showCodeFolding->SetValue(Glob_config->ReadBool("show_code_folding", false));
if ( ! HAS_FONT_BUG())
{
wxFont globalFont; wxFont globalFont;
Glob_config->Read("global_font", &globalFont); Glob_config->Read("global_font", &globalFont);
this->fontPicker->SetSelectedFont(globalFont); this->fontPicker->SetSelectedFont(globalFont);
}
return true; return true;
} }
@ -110,10 +103,7 @@ public:
Glob_config->Write("show_indent_guides", this->showIndentGuides->IsChecked()); Glob_config->Write("show_indent_guides", this->showIndentGuides->IsChecked());
Glob_config->Write("show_code_folding", this->showCodeFolding->IsChecked()); Glob_config->Write("show_code_folding", this->showCodeFolding->IsChecked());
if ( ! HAS_FONT_BUG())
{
Glob_config->Write("global_font", this->fontPicker->GetSelectedFont()); Glob_config->Write("global_font", this->fontPicker->GetSelectedFont());
}
wxCommandEvent evt = wxCommandEvent(); wxCommandEvent evt = wxCommandEvent();
this->frame->OnPrefsChanged(evt); this->frame->OnPrefsChanged(evt);

View File

@ -24,6 +24,7 @@
#include <wx/version.h> #include <wx/version.h>
#include <wx/cmdline.h> #include <wx/cmdline.h>
#include <wx/config.h> #include <wx/config.h>
#include <wx/display.h>
#include <wx/font.h> #include <wx/font.h>
#include <wx/stdpaths.h> #include <wx/stdpaths.h>
#include <wx/platinfo.h> #include <wx/platinfo.h>
@ -34,20 +35,19 @@
#pragma clang diagnostic pop #pragma clang diagnostic pop
#endif #endif
// Define a check for font-control bug /**
// in wxWidgets < 3.0.3 and OS X >= 10.10 * Calculate original window size based on size of the current monitor
static inline bool HAS_FONT_BUG() */
wxSize static CalculateWindowSize()
{ {
#ifndef __WXMAC__ wxDisplay display;
return false; wxVideoMode mode = display.GetCurrentMode();
#endif
#if wxCHECK_VERSION(3,0,3) wxLogDebug("Current display: %ix%i", mode.w, mode.h);
return false;
#endif
wxPlatformInfo info; wxSize base((int)((float)mode.w * 0.9), (int)((float)mode.h * 0.9));
return (info.GetOSMajorVersion() == 10 && info.GetOSMinorVersion() > 9);
return base;
} }
// Tyro-specific variables // Tyro-specific variables