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/sysopt.h>
#include <wx/vidmode.h>
#include <wx/display.h>
#include "src/widgets/MainFrame.h"
// Some global stuff
wxConfigBase *Glob_config = nullptr;
TyroMenu *Glob_menu_bar = nullptr;
@ -51,7 +49,7 @@ public:
this->InitLexerMap();
Glob_config = wxConfigBase::Get();
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
Glob_pref_pane = new PrefPane();
#endif
@ -152,24 +150,9 @@ private:
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
*/
*/
void static SetSystemOptions()
{
#ifdef __WXMAC__

View File

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

View File

@ -175,9 +175,7 @@ bool EditPane::SaveFile()
{
wxString fname = this->fileName.GetFullPath();
const wxString cfname(fname);
return this->SaveFile(cfname);
return this->SaveFile(fname);
}
/**
@ -332,22 +330,15 @@ void EditPane::_ApplyTheme(JsonValue &lexer_map)
this->StyleSetBackground(i, default_background);
this->StyleSetForeground(i, default_foreground);
if ( ! HAS_FONT_BUG())
wxFont globalFont;
wxString fontFace;
if ( ! Glob_config->Read("global_font", &globalFont))
{
wxFont globalFont;
wxString fontFace;
if ( ! Glob_config->Read("global_font", &globalFont))
{
this->StyleSetFont(i, *defaultFont);
}
else
{
this->StyleSetFont(i, globalFont);
}
this->StyleSetFont(i, *defaultFont);
}
else
{
this->StyleSetFont(i, *defaultFont);
this->StyleSetFont(i, globalFont);
}
}

View File

@ -440,15 +440,15 @@ void MainFrame::OnAbout(wxCommandEvent &WXUNUSED(event))
wxString desc = "Tyro, a text editor for all development\n\n"
"System info: \n";
desc += wxString::Format("Architecture: %s\n",
desc += wxString::Format("\tArchitecture: %s\n",
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()),
plat_info.GetOSMajorVersion(),
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(),
wxMAJOR_VERSION,
wxMINOR_VERSION,
@ -460,10 +460,10 @@ void MainFrame::OnAbout(wxCommandEvent &WXUNUSED(event))
wxString desk = plat_info.GetDesktopEnvironment();
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;
if (dist_info.CodeName != "")

View File

@ -16,22 +16,21 @@ public:
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,
myID_PREFS_FONT,
wxNullFont,
wxDefaultPosition,
wxDefaultSize,
wxFNTP_USE_TEXTCTRL ^ wxFNTP_USEFONT_FOR_LABEL
);
wxSizer *fontSizer = new wxBoxSizer(wxHORIZONTAL);
fontSizer->Add(this->fontPicker, wxSizerFlags().Border());
sizer->Add(fontSizer, wxSizerFlags().Border());
}
this->fontPicker = new wxFontPickerCtrl(
this,
myID_PREFS_FONT,
this->GetFont(),
wxDefaultPosition,
wxDefaultSize,
wxFNTP_FONTDESC_AS_LABEL
);
this->fontPicker->SetLabelText("Editor Font");
wxSizer *fontSizer = new wxBoxSizer(wxHORIZONTAL);
fontSizer->AddSpacer(50);
fontSizer->Add(this->fontPicker, wxSizerFlags().Border());
fontSizer->AddSpacer(50);
sizer->Add(fontSizer, wxSizerFlags().Border());
sizer->Add(this->showLineNumbers, wxSizerFlags().Border());
sizer->Add(this->showIndentGuides, wxSizerFlags().Border());
@ -43,14 +42,11 @@ public:
// On supported platforms
if (wxPreferencesEditor::ShouldApplyChangesImmediately())
{
if ( ! HAS_FONT_BUG())
{
this->fontPicker->Bind(wxEVT_FONTPICKER_CHANGED, [=] (wxFontPickerEvent &event) {
Glob_config->Write("global_font", event.GetFont());
this->frame->OnPrefsChanged(event);
Glob_config->Flush();
}, myID_PREFS_FONT);
}
this->fontPicker->Bind(wxEVT_FONTPICKER_CHANGED, [=] (wxFontPickerEvent &event) {
Glob_config->Write("global_font", event.GetFont());
this->frame->OnPrefsChanged(event);
Glob_config->Flush();
}, myID_PREFS_FONT);
this->showLineNumbers->Bind(wxEVT_CHECKBOX, [=] (wxCommandEvent &event) {
Glob_config->Write("show_line_numbers", event.IsChecked());
@ -79,21 +75,18 @@ public:
/**
* Apply current settings to the pref window
*
* @return bool
*/
* @return bool
*/
virtual bool TransferDataToWindow()
{
this->showLineNumbers->SetValue(Glob_config->ReadBool("show_line_numbers", true));
this->showIndentGuides->SetValue(Glob_config->ReadBool("show_indent_guides", false));
this->showCodeFolding->SetValue(Glob_config->ReadBool("show_code_folding", false));
if ( ! HAS_FONT_BUG())
{
wxFont globalFont;
Glob_config->Read("global_font", &globalFont);
wxFont globalFont;
Glob_config->Read("global_font", &globalFont);
this->fontPicker->SetSelectedFont(globalFont);
}
this->fontPicker->SetSelectedFont(globalFont);
return true;
}
@ -102,18 +95,15 @@ public:
* Called on platforms with modal preferences dialog to save
* and apply the changes
*
* @return bool
*/
* @return bool
*/
virtual bool TransferDataFromWindow()
{
Glob_config->Write("show_line_numbers", this->showLineNumbers->IsChecked());
Glob_config->Write("show_indent_guides", this->showIndentGuides->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();
this->frame->OnPrefsChanged(evt);

View File

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