Refactoring to scaled enumerations

This commit is contained in:
Markus Gans 2020-12-31 20:45:10 +01:00
parent 783f58bc4b
commit b2de303cfc
124 changed files with 6823 additions and 6740 deletions

View File

@ -1,13 +1,16 @@
2019-11-18 Markus Gans <guru.mail@muenster.de>
2020-12-31 Markus Gans <guru.mail@muenster.de>
* Refactoring to scaled enumerations
2020-11-18 Markus Gans <guru.mail@muenster.de>
* The terminal update rate is now limited to 60 Hz
2019-11-14 Markus Gans <guru.mail@muenster.de>
2020-11-14 Markus Gans <guru.mail@muenster.de>
* Version 0.7.1
* Bugfix: The cursor position was not changed anymore
if there was no change to the content
* Forcing a direct update for faster terminal output
2019-11-07 Markus Gans <guru.mail@muenster.de>
2020-11-07 Markus Gans <guru.mail@muenster.de>
* Version 0.7.0
2020-11-04 Markus Gans <guru.mail@muenster.de>

View File

@ -381,7 +381,7 @@ class dialogWidget : public FDialog
setText ("Dialog");
setGeometry (FPoint{25, 5}, FSize{23, 4});
label.setGeometry (FPoint{1, 1}, FSize{10, 1});
label.setAlignment (fc::alignRight);
label.setAlignment (Align::Right);
value.setGeometry (FPoint{11, 1}, FSize{10, 1});
id = addTimer(100);
}
@ -475,7 +475,7 @@ class extendedApplication : public FApplication
|| last_avg[1] != load_avg[1]
|| last_avg[2] != load_avg[2] )
{
FUserEvent user_event(fc::User_Event, 0);
FUserEvent user_event(Event::User, 0);
user_event.setData (load_avg);
FApplication::sendEvent (getMainWidget(), &user_event);
}
@ -958,8 +958,8 @@ class dialogWidget : public FDialog
setText ("Emit signal");
const FSize size{5, 1};
label.setGeometry (FPoint{8, 1}, size);
label.setAlignment (fc::alignRight);
label.setForegroundColor (fc::Black);
label.setAlignment (Align::Right);
label.setForegroundColor (FColor::Black);
plus.setGeometry (FPoint{3, 3}, size);
minus.setGeometry (FPoint{3, 3} + FPoint{10, 0}, size);
plus.setNoUnderline();
@ -1004,17 +1004,17 @@ class dialogWidget : public FDialog
void cb_set_blue()
{
label.setForegroundColor (fc::Blue);
label.setForegroundColor (FColor::Blue);
}
void cb_set_black()
{
label.setForegroundColor (fc::Black);
label.setForegroundColor (FColor::Black);
}
void cb_set_red()
{
label.setForegroundColor (fc::Red);
label.setForegroundColor (FColor::Red);
}
void setTemperature()
@ -1291,9 +1291,9 @@ class dialogWidget : public FDialog
FDialog::draw();
print() << FPoint{3, 3}
<< FColorPair{fc::Black, fc::White}
<< FColorPair{FColor::Black, FColor::White}
<< "Text on "
<< FColorPair{fc::Blue, fc::Yellow}
<< FColorPair{FColor::Blue, FColor::Yellow}
<< "top";
}
@ -1383,9 +1383,9 @@ class dialogWidget : public FDialog
const auto& wc = getColorTheme();
setColor (wc->label_inactive_fg, wc->dialog_bg);
scrollview.clearArea();
FColorPair red (fc::LightRed, wc->dialog_bg);
FColorPair black (fc::Black, wc->dialog_bg);
FColorPair cyan (fc::Cyan, wc->dialog_bg);
FColorPair red (FColor::LightRed, wc->dialog_bg);
FColorPair black (FColor::Black, wc->dialog_bg);
FColorPair cyan (FColor::Cyan, wc->dialog_bg);
static std::vector<direction> d
{

View File

@ -75,92 +75,92 @@ class BeeColorTheme final : public finalcut::FWidgetColors
void setColorTheme() override
{
term_fg = finalcut::fc::Black;
term_bg = finalcut::fc::LightBlue;
list_fg = finalcut::fc::Black;
list_bg = finalcut::fc::LightGray;
selected_list_fg = finalcut::fc::LightRed;
selected_list_bg = finalcut::fc::LightGray;
dialog_fg = finalcut::fc::Black;
dialog_resize_fg = finalcut::fc::Red;
dialog_emphasis_fg = finalcut::fc::Blue;
dialog_bg = finalcut::fc::LightGray;
error_box_fg = finalcut::fc::Black;
error_box_emphasis_fg = finalcut::fc::Red;
error_box_bg = finalcut::fc::Yellow;
tooltip_fg = finalcut::fc::Black;
tooltip_bg = finalcut::fc::Yellow;
shadow_fg = finalcut::fc::Black;
shadow_bg = finalcut::fc::LightGray;
current_element_focus_fg = finalcut::fc::White;
current_element_focus_bg = finalcut::fc::Green;
current_element_fg = finalcut::fc::LightGray;
current_element_bg = finalcut::fc::DarkGray;
current_inc_search_element_fg = finalcut::fc::Brown;
selected_current_element_focus_fg = finalcut::fc::LightRed;
selected_current_element_focus_bg = finalcut::fc::Green;
selected_current_element_fg = finalcut::fc::LightRed;
selected_current_element_bg = finalcut::fc::DarkGray;
label_fg = finalcut::fc::Black;
label_bg = finalcut::fc::LightGray;
label_inactive_fg = finalcut::fc::LightGray;
label_inactive_bg = finalcut::fc::DarkGray;
label_hotkey_fg = finalcut::fc::Red;
label_hotkey_bg = finalcut::fc::LightGray;
label_emphasis_fg = finalcut::fc::Blue;
label_ellipsis_fg = finalcut::fc::DarkGray;
inputfield_active_focus_fg = finalcut::fc::LightGray;
inputfield_active_focus_bg = finalcut::fc::Green;
inputfield_active_fg = finalcut::fc::Black;
inputfield_active_bg = finalcut::fc::Cyan ;
inputfield_inactive_fg = finalcut::fc::Black;
inputfield_inactive_bg = finalcut::fc::LightGray;
toggle_button_active_focus_fg = finalcut::fc::White;
toggle_button_active_focus_bg = finalcut::fc::Green;
toggle_button_active_fg = finalcut::fc::Black;
toggle_button_active_bg = finalcut::fc::LightGray;
toggle_button_inactive_fg = finalcut::fc::DarkGray;
toggle_button_inactive_bg = finalcut::fc::LightGray;
button_active_focus_fg = finalcut::fc::White;
button_active_focus_bg = finalcut::fc::Green;
button_active_fg = finalcut::fc::Black;
button_active_bg = finalcut::fc::Cyan;
button_inactive_fg = finalcut::fc::Cyan;
button_inactive_bg = finalcut::fc::LightGray;
button_hotkey_fg = finalcut::fc::Red;
titlebar_active_fg = finalcut::fc::White;
titlebar_active_bg = finalcut::fc::Blue;
titlebar_inactive_fg = finalcut::fc::LightGray;
titlebar_inactive_bg = finalcut::fc::DarkGray;
titlebar_button_fg = finalcut::fc::Black;
titlebar_button_bg = finalcut::fc::LightGray;
titlebar_button_focus_fg = finalcut::fc::LightGray;
titlebar_button_focus_bg = finalcut::fc::Black;
menu_active_focus_fg = finalcut::fc::White;
menu_active_focus_bg = finalcut::fc::Blue;
menu_active_fg = finalcut::fc::Black;
menu_active_bg = finalcut::fc::Yellow;
menu_inactive_fg = finalcut::fc::Cyan;
menu_inactive_bg = finalcut::fc::Yellow;
menu_hotkey_fg = finalcut::fc::Red;
menu_hotkey_bg = finalcut::fc::Yellow;
statusbar_fg = finalcut::fc::White;
statusbar_bg = finalcut::fc::DarkGray;
statusbar_hotkey_fg = finalcut::fc::LightRed;
statusbar_hotkey_bg = finalcut::fc::DarkGray;
statusbar_separator_fg = finalcut::fc::Black;
statusbar_active_fg = finalcut::fc::White;
statusbar_active_bg = finalcut::fc::Green;
statusbar_active_hotkey_fg = finalcut::fc::LightRed;
statusbar_active_hotkey_bg = finalcut::fc::Green;
scrollbar_fg = finalcut::fc::Black;
scrollbar_bg = finalcut::fc::Green;
scrollbar_button_fg = finalcut::fc::Black;
scrollbar_button_bg = finalcut::fc::Green;
scrollbar_button_inactive_fg = finalcut::fc::Cyan;
scrollbar_button_inactive_bg = finalcut::fc::LightGray;
progressbar_fg = finalcut::fc::Green;
progressbar_bg = finalcut::fc::DarkGray;
term_fg = finalcut::FColor::Black;
term_bg = finalcut::FColor::LightBlue;
list_fg = finalcut::FColor::Black;
list_bg = finalcut::FColor::LightGray;
selected_list_fg = finalcut::FColor::LightRed;
selected_list_bg = finalcut::FColor::LightGray;
dialog_fg = finalcut::FColor::Black;
dialog_resize_fg = finalcut::FColor::Red;
dialog_emphasis_fg = finalcut::FColor::Blue;
dialog_bg = finalcut::FColor::LightGray;
error_box_fg = finalcut::FColor::Black;
error_box_emphasis_fg = finalcut::FColor::Red;
error_box_bg = finalcut::FColor::Yellow;
tooltip_fg = finalcut::FColor::Black;
tooltip_bg = finalcut::FColor::Yellow;
shadow_fg = finalcut::FColor::Black;
shadow_bg = finalcut::FColor::LightGray;
current_element_focus_fg = finalcut::FColor::White;
current_element_focus_bg = finalcut::FColor::Green;
current_element_fg = finalcut::FColor::LightGray;
current_element_bg = finalcut::FColor::DarkGray;
current_inc_search_element_fg = finalcut::FColor::Brown;
selected_current_element_focus_fg = finalcut::FColor::LightRed;
selected_current_element_focus_bg = finalcut::FColor::Green;
selected_current_element_fg = finalcut::FColor::LightRed;
selected_current_element_bg = finalcut::FColor::DarkGray;
label_fg = finalcut::FColor::Black;
label_bg = finalcut::FColor::LightGray;
label_inactive_fg = finalcut::FColor::LightGray;
label_inactive_bg = finalcut::FColor::DarkGray;
label_hotkey_fg = finalcut::FColor::Red;
label_hotkey_bg = finalcut::FColor::LightGray;
label_emphasis_fg = finalcut::FColor::Blue;
label_ellipsis_fg = finalcut::FColor::DarkGray;
inputfield_active_focus_fg = finalcut::FColor::LightGray;
inputfield_active_focus_bg = finalcut::FColor::Green;
inputfield_active_fg = finalcut::FColor::Black;
inputfield_active_bg = finalcut::FColor::Cyan ;
inputfield_inactive_fg = finalcut::FColor::Black;
inputfield_inactive_bg = finalcut::FColor::LightGray;
toggle_button_active_focus_fg = finalcut::FColor::White;
toggle_button_active_focus_bg = finalcut::FColor::Green;
toggle_button_active_fg = finalcut::FColor::Black;
toggle_button_active_bg = finalcut::FColor::LightGray;
toggle_button_inactive_fg = finalcut::FColor::DarkGray;
toggle_button_inactive_bg = finalcut::FColor::LightGray;
button_active_focus_fg = finalcut::FColor::White;
button_active_focus_bg = finalcut::FColor::Green;
button_active_fg = finalcut::FColor::Black;
button_active_bg = finalcut::FColor::Cyan;
button_inactive_fg = finalcut::FColor::Cyan;
button_inactive_bg = finalcut::FColor::LightGray;
button_hotkey_fg = finalcut::FColor::Red;
titlebar_active_fg = finalcut::FColor::White;
titlebar_active_bg = finalcut::FColor::Blue;
titlebar_inactive_fg = finalcut::FColor::LightGray;
titlebar_inactive_bg = finalcut::FColor::DarkGray;
titlebar_button_fg = finalcut::FColor::Black;
titlebar_button_bg = finalcut::FColor::LightGray;
titlebar_button_focus_fg = finalcut::FColor::LightGray;
titlebar_button_focus_bg = finalcut::FColor::Black;
menu_active_focus_fg = finalcut::FColor::White;
menu_active_focus_bg = finalcut::FColor::Blue;
menu_active_fg = finalcut::FColor::Black;
menu_active_bg = finalcut::FColor::Yellow;
menu_inactive_fg = finalcut::FColor::Cyan;
menu_inactive_bg = finalcut::FColor::Yellow;
menu_hotkey_fg = finalcut::FColor::Red;
menu_hotkey_bg = finalcut::FColor::Yellow;
statusbar_fg = finalcut::FColor::White;
statusbar_bg = finalcut::FColor::DarkGray;
statusbar_hotkey_fg = finalcut::FColor::LightRed;
statusbar_hotkey_bg = finalcut::FColor::DarkGray;
statusbar_separator_fg = finalcut::FColor::Black;
statusbar_active_fg = finalcut::FColor::White;
statusbar_active_bg = finalcut::FColor::Green;
statusbar_active_hotkey_fg = finalcut::FColor::LightRed;
statusbar_active_hotkey_bg = finalcut::FColor::Green;
scrollbar_fg = finalcut::FColor::Black;
scrollbar_bg = finalcut::FColor::Green;
scrollbar_button_fg = finalcut::FColor::Black;
scrollbar_button_bg = finalcut::FColor::Green;
scrollbar_button_inactive_fg = finalcut::FColor::Cyan;
scrollbar_button_inactive_bg = finalcut::FColor::LightGray;
progressbar_fg = finalcut::FColor::Green;
progressbar_bg = finalcut::FColor::DarkGray;
}
};
@ -175,24 +175,24 @@ FINAL CUT has four color tables for the 16 standard colors in the terminal.
These are a redefinition of the 16 ANSI colors. You can address the colors
via indexes values from 0 to 15. They correspond to the following colors:
| Index | Color name |
|:------:|:---------------------------|
| 0 | finalcut::fc::Black |
| 1 | finalcut::fc::Blue |
| 2 | finalcut::fc::Green |
| 3 | finalcut::fc::Cyan |
| 4 | finalcut::fc::Red |
| 5 | finalcut::fc::Magenta |
| 6 | finalcut::fc::Brown |
| 7 | finalcut::fc::LightGray |
| 8 | finalcut::fc::DarkGray |
| 9 | finalcut::fc::LightBlue |
| 10 | finalcut::fc::LightGreen |
| 11 | finalcut::fc::LightCyan |
| 12 | finalcut::fc::LightRed |
| 13 | finalcut::fc::LightMagenta |
| 14 | finalcut::fc::Yellow |
| 15 | finalcut::fc::White |
| Index | Color name |
|:------:|:-------------------------------|
| 0 | finalcut::FColor::Black |
| 1 | finalcut::FColor::Blue |
| 2 | finalcut::FColor::Green |
| 3 | finalcut::FColor::Cyan |
| 4 | finalcut::FColor::Red |
| 5 | finalcut::FColor::Magenta |
| 6 | finalcut::FColor::Brown |
| 7 | finalcut::FColor::LightGray |
| 8 | finalcut::FColor::DarkGray |
| 9 | finalcut::FColor::LightBlue |
| 10 | finalcut::FColor::LightGreen |
| 11 | finalcut::FColor::LightCyan |
| 12 | finalcut::FColor::LightRed |
| 13 | finalcut::FColor::LightMagenta |
| 14 | finalcut::FColor::Yellow |
| 15 | finalcut::FColor::White |
You can define your color as an 8-bit value based on its red, green, and
blue components. To create a color palette, create a derived class of
@ -306,22 +306,22 @@ class BeeColorPalette final : public finalcut::FColorPalette
void setColorPalette() override
{
setPalette (finalcut::fc::Black, 0x00, 0x00, 0x00);
setPalette (finalcut::fc::Blue, 0x23, 0x21, 0x2c);
setPalette (finalcut::fc::Green, 0x26, 0x93, 0x7c);
setPalette (finalcut::fc::Cyan, 0xcf, 0xb3, 0xa8);
setPalette (finalcut::fc::Red, 0xba, 0x1a, 0x1a);
setPalette (finalcut::fc::Magenta, 0xb2, 0x18, 0xb2);
setPalette (finalcut::fc::Brown, 0xe8, 0x87, 0x1f);
setPalette (finalcut::fc::LightGray, 0xff, 0xfb, 0xe4);
setPalette (finalcut::fc::DarkGray, 0x3a, 0x36, 0x37);
setPalette (finalcut::fc::LightBlue, 0xa5, 0xa5, 0xb1);
setPalette (finalcut::fc::LightGreen, 0x5e, 0xeb, 0x5c);
setPalette (finalcut::fc::LightCyan, 0x62, 0xbf, 0xf8);
setPalette (finalcut::fc::LightRed, 0xee, 0x44, 0x44);
setPalette (finalcut::fc::LightMagenta, 0xe9, 0xad, 0xff);
setPalette (finalcut::fc::Yellow, 0xf8, 0xef, 0xa6);
setPalette (finalcut::fc::White, 0xff, 0xff, 0xff);
setPalette (finalcut::FColor::Black, 0x00, 0x00, 0x00);
setPalette (finalcut::FColor::Blue, 0x23, 0x21, 0x2c);
setPalette (finalcut::FColor::Green, 0x26, 0x93, 0x7c);
setPalette (finalcut::FColor::Cyan, 0xcf, 0xb3, 0xa8);
setPalette (finalcut::FColor::Red, 0xba, 0x1a, 0x1a);
setPalette (finalcut::FColor::Magenta, 0xb2, 0x18, 0xb2);
setPalette (finalcut::FColor::Brown, 0xe8, 0x87, 0x1f);
setPalette (finalcut::FColor::LightGray, 0xff, 0xfb, 0xe4);
setPalette (finalcut::FColor::DarkGray, 0x3a, 0x36, 0x37);
setPalette (finalcut::FColor::LightBlue, 0xa5, 0xa5, 0xb1);
setPalette (finalcut::FColor::LightGreen, 0x5e, 0xeb, 0x5c);
setPalette (finalcut::FColor::LightCyan, 0x62, 0xbf, 0xf8);
setPalette (finalcut::FColor::LightRed, 0xee, 0x44, 0x44);
setPalette (finalcut::FColor::LightMagenta, 0xe9, 0xad, 0xff);
setPalette (finalcut::FColor::Yellow, 0xf8, 0xef, 0xa6);
setPalette (finalcut::FColor::White, 0xff, 0xff, 0xff);
}
void resetColorPalette() override
@ -364,7 +364,7 @@ class dialogWidget final : public FDialog
FDialog::setGeometry (FPoint{15, 5}, FSize{50, 9});
Input.setGeometry (FPoint{2, 2}, FSize{39, 1});
Input.setLabelText("File name:");
Input.setLabelOrientation(FLineEdit::label_above);
Input.setLabelOrientation(FLineEdit::LabelOrientation::Above);
Input.setStatusbarMessage("Enter a file name");
Browse.setGeometry (FPoint{43, 2}, FSize{4, 1});
Browse.addCallback

View File

@ -28,11 +28,11 @@
namespace fc = finalcut::fc;
using finalcut::FColorPair;
using finalcut::FColor;
using finalcut::FRect;
using finalcut::FPoint;
using finalcut::FSize;
//----------------------------------------------------------------------
// class SegmentView
//----------------------------------------------------------------------
@ -85,7 +85,7 @@ SegmentView::SegmentView (finalcut::FWidget* parent)
input.setGeometry (FPoint(2, 2), FSize{12, 1});
input.setLabelText (L"&Hex value");
input.setLabelText (L"&Hex-digits or (.) (:) (H) (L) (P) (U)");
input.setLabelOrientation(finalcut::FLineEdit::LabelOrientation::above);
input.setLabelOrientation(finalcut::FLineEdit::LabelOrientation::Above);
input.setMaxLength(9);
input.setInputFilter("[:.hHlLpPuU[:xdigit:]]");
@ -199,12 +199,12 @@ void SegmentView::draw()
finalcut::FTermBuffer left_space{};
FDialog::draw();
setColor(fc::LightGray, fc::Black);
setColor(FColor::LightGray, FColor::Black);
finalcut::drawBorder(this, FRect(FPoint{3, 6}, FPoint{40, 11}));
for (auto&& ch : input.getText().toUpper())
{
const FColorPair color{fc::LightRed, fc::Black};
const FColorPair color{FColor::LightRed, FColor::Black};
get7Segment(ch);
for (std::size_t i{0}; i < 3; i++)

View File

@ -29,6 +29,7 @@
using finalcut::FPoint;
using finalcut::FRect;
using finalcut::FSize;
using finalcut::FColor;
//----------------------------------------------------------------------
@ -99,7 +100,7 @@ Background::Background (finalcut::FWidget* parent)
// Combobox
color_choice.setGeometry (FPoint{2, 2}, FSize{18, 1});
color_choice.setLabelOrientation (finalcut::FLineEdit::LabelOrientation::above);
color_choice.setLabelOrientation (finalcut::FLineEdit::LabelOrientation::Above);
color_choice.setLabelText ("Color choice");
color_choice.unsetEditable();
@ -111,19 +112,19 @@ Background::Background (finalcut::FWidget* parent)
// Spin boxes
red.setGeometry (FPoint{2, 5}, FSize{7, 1});
red.setLabelOrientation (finalcut::FLineEdit::LabelOrientation::above);
red.setLabelOrientation (finalcut::FLineEdit::LabelOrientation::Above);
red.setLabelText ("Red");
red.setRange (0, 255);
red.setValue (0x80);
green.setGeometry (FPoint{12, 5}, FSize{7, 1});
green.setLabelOrientation (finalcut::FLineEdit::LabelOrientation::above);
green.setLabelOrientation (finalcut::FLineEdit::LabelOrientation::Above);
green.setLabelText ("Green");
green.setRange (0, 255);
green.setValue (0xa4);
blue.setGeometry (FPoint{22, 5}, FSize{7, 1});
blue.setLabelOrientation (finalcut::FLineEdit::LabelOrientation::above);
blue.setLabelOrientation (finalcut::FLineEdit::LabelOrientation::Above);
blue.setLabelText ("Blue");
blue.setRange (0, 255);
blue.setValue (0xec);
@ -131,7 +132,7 @@ Background::Background (finalcut::FWidget* parent)
// Set the initial palette values
if ( finalcut::FTerm::canChangeColorPalette() )
{
finalcut::FTerm::setPalette ( finalcut::fc::LightMagenta
finalcut::FTerm::setPalette ( FColor::LightMagenta
, int(red.getValue())
, int(green.getValue())
, int(blue.getValue()) );
@ -177,7 +178,7 @@ void Background::cb_changed()
if ( ! finalcut::FTerm::canChangeColorPalette() )
return;
finalcut::FTerm::setPalette ( finalcut::fc::LightMagenta
finalcut::FTerm::setPalette ( FColor::LightMagenta
, int(red.getValue())
, int(green.getValue())
, int(blue.getValue()) );
@ -198,7 +199,7 @@ void Background::cb_choice()
red.setValue(r);
green.setValue(g);
blue.setValue(b);
finalcut::FTerm::setPalette ( finalcut::fc::LightMagenta
finalcut::FTerm::setPalette ( FColor::LightMagenta
, int(red.getValue())
, int(green.getValue())
, int(blue.getValue()) );
@ -219,7 +220,7 @@ int main (int argc, char* argv[])
// The following lines require an initialized terminal
if ( finalcut::FTerm::canChangeColorPalette() )
app.setBackgroundColor(finalcut::fc::LightMagenta);
app.setBackgroundColor(FColor::LightMagenta);
Background dialog(&app);
finalcut::FWidget::setMainWidget(&dialog);

View File

@ -31,11 +31,12 @@
#include <final/final.h>
namespace fc = finalcut::fc;
using FKey = finalcut::FKey;
using finalcut::FColorPair;
using finalcut::FColor;
using finalcut::FPoint;
using finalcut::FRect;
using finalcut::FSize;
using finalcut::FColorPair;
constexpr lDouble pi_value{3.141592653589793238L};
@ -76,9 +77,9 @@ void Button::setChecked (bool enable)
if ( checked )
{
setBackgroundColor(fc::Cyan);
setFocusForegroundColor(fc::White);
setFocusBackgroundColor(fc::Cyan);
setBackgroundColor(FColor::Cyan);
setFocusForegroundColor(FColor::White);
setFocusBackgroundColor(FColor::Cyan);
}
else
{
@ -97,7 +98,7 @@ void Button::onKeyPress (finalcut::FKeyEvent* ev)
const FKey key = ev->key();
// catch the enter key
if ( key == fc::Fkey_return || key == fc::Fkey_enter )
if ( key == FKey::Return || key == FKey::Enter )
return;
finalcut::FButton::onKeyPress(ev);
@ -124,7 +125,7 @@ class Calc final : public finalcut::FDialog
// Typedef and Enumeration
using keyFunction = std::function<void(lDouble&)>; // Member function
enum button
enum class ButtonName
{
Sine,
Cosine,
@ -201,15 +202,15 @@ class Calc final : public finalcut::FDialog
void sine (lDouble&);
void cosine (lDouble&);
void tangent (lDouble&);
bool isDataEntryKey (int) const;
bool isOperatorKey (int) const;
bool isDataEntryKey (const ButtonName&) const;
bool isOperatorKey (const ButtonName&) const;
lDouble& getValue();
void setDisplay (lDouble);
void setInfixOperator (char);
void clearInfixOperator();
void calcInfixOperator();
void adjustSize() override;
const wchar_t* getButtonText (const std::size_t) const;
const wchar_t* getButtonText (const ButtonName&) const;
void mapKeyFunctions();
// Event handlers
@ -218,7 +219,14 @@ class Calc final : public finalcut::FDialog
void onClose (finalcut::FCloseEvent*) override;
// Callback method
void cb_buttonClicked (Calc::button);
void cb_buttonClicked (ButtonName);
// Overloaded operators
friend bool operator < (const ButtonName& c, const int n) noexcept;
friend bool operator <= (const ButtonName& c, const int n) noexcept;
friend ButtonName operator + (const ButtonName& c, const int n) noexcept;
friend ButtonName& operator ++ (ButtonName& c) noexcept; // prefix
friend ButtonName operator ++ (ButtonName& c, int) noexcept; // postfix
// Data members
bool error{false};
@ -228,11 +236,11 @@ class Calc final : public finalcut::FDialog
lDouble b{0.0L};
lDouble infinity{std::numeric_limits<lDouble>::infinity()};
uInt max_char{33};
int last_key{-1};
ButtonName last_key{ButtonName(-1)};
char infix_operator{'\0'};
char last_infix_operator{'\0'};
finalcut::FString input{""};
std::array<button, Calc::NUM_OF_BUTTONS> button_no{};
std::array<ButtonName, std::size_t(ButtonName::NUM_OF_BUTTONS)> button_no{};
struct StackData
{
@ -241,8 +249,8 @@ class Calc final : public finalcut::FDialog
};
std::stack<StackData> bracket_stack{};
std::map<Calc::button, std::shared_ptr<Button> > calculator_buttons{};
std::map<Calc::button, keyFunction> key_map{};
std::map<ButtonName, std::shared_ptr<Button> > calculator_buttons{};
std::map<ButtonName, keyFunction> key_map{};
};
//----------------------------------------------------------------------
@ -258,26 +266,27 @@ Calc::Calc (FWidget* parent)
mapKeyFunctions();
clearInfixOperator();
for (button key{Sine}; key < Calc::NUM_OF_BUTTONS; key = button(key + 1))
for (ButtonName key{ButtonName::Sine}; key < ButtonName::NUM_OF_BUTTONS; key++)
{
auto btn = std::make_shared<Button>(this);
button_no[key] = key;
auto index = std::size_t(key);
button_no[index] = key;
if ( key == Equals )
if ( key == ButtonName::Equals )
btn->setGeometry(FPoint{30, 15}, FSize{5, 3});
else
{
const std::size_t n = ( key <= Three ) ? 0 : 1;
const int x = int(key + n) % 5 * 7 + 2;
const int y = int(key + n) / 5 * 2 + 3;
const int n = ( key <= ButtonName::Three ) ? 0 : 1;
const int x = (int(key) + n) % 5 * 7 + 2;
const int y = (int(key) + n) / 5 * 2 + 3;
btn->setGeometry(FPoint{x, y}, FSize{5, 1});
}
btn->setFlat();
btn->setNoUnderline();
btn->setText(getButtonText(key));
btn->setDoubleFlatLine(fc::top);
btn->setDoubleFlatLine(fc::bottom);
btn->setDoubleFlatLine(finalcut::Side::Top);
btn->setDoubleFlatLine(finalcut::Side::Bottom);
if ( finalcut::FTerm::isNewFont() )
btn->unsetClickAnimation();
@ -286,23 +295,23 @@ Calc::Calc (FWidget* parent)
(
"clicked",
this, &Calc::cb_buttonClicked,
button_no[key]
button_no[index]
);
calculator_buttons[button(key)] = btn;
calculator_buttons[ButtonName(key)] = btn;
}
calculator_buttons[On]->addAccelerator(fc::Fkey_dc); // Del key
calculator_buttons[On]->setFocus();
calculator_buttons[Pi]->addAccelerator('p');
calculator_buttons[Power]->addAccelerator('^');
calculator_buttons[Divide]->addAccelerator('/');
calculator_buttons[Powers_of_ten]->addAccelerator('d');
calculator_buttons[Multiply]->addAccelerator('*');
calculator_buttons[Decimal_point]->addAccelerator(',');
calculator_buttons[Change_sign]->addAccelerator('#');
calculator_buttons[Equals]->addAccelerator(fc::Fkey_return);
calculator_buttons[Equals]->addAccelerator(fc::Fkey_enter);
calculator_buttons[ButtonName::On]->addAccelerator(FKey::Del_char);
calculator_buttons[ButtonName::On]->setFocus();
calculator_buttons[ButtonName::Pi]->addAccelerator(FKey('p'));
calculator_buttons[ButtonName::Power]->addAccelerator(FKey('^'));
calculator_buttons[ButtonName::Divide]->addAccelerator(FKey('/'));
calculator_buttons[ButtonName::Powers_of_ten]->addAccelerator(FKey('d'));
calculator_buttons[ButtonName::Multiply]->addAccelerator(FKey('*'));
calculator_buttons[ButtonName::Decimal_point]->addAccelerator(FKey(','));
calculator_buttons[ButtonName::Change_sign]->addAccelerator(FKey('#'));
calculator_buttons[ButtonName::Equals]->addAccelerator(FKey::Return);
calculator_buttons[ButtonName::Equals]->addAccelerator(FKey::Enter);
}
//----------------------------------------------------------------------
@ -311,46 +320,40 @@ void Calc::onKeyPress (finalcut::FKeyEvent* ev)
const std::size_t len = input.getLength();
const FKey key = ev->key();
switch ( key )
if ( key == FKey::Erase || key == FKey::Backspace )
{
case fc::Fkey_erase:
case fc::Fkey_backspace:
if ( len > 0 )
if ( len > 0 )
{
lDouble& x = getValue();
if ( len == 1 )
{
lDouble& x = getValue();
if ( len == 1 )
{
input = "";
x = 0.0L;
}
else
{
input = input.left(input.getLength() - 1);
x = std::strtold(input.c_str(), nullptr);
}
drawDispay();
input = "";
x = 0.0L;
}
else
{
input = input.left(input.getLength() - 1);
x = std::strtold(input.c_str(), nullptr);
}
ev->accept();
break;
drawDispay();
}
case fc::Fkey_escape:
case fc::Fkey_escape_mintty:
sendOnButtonAccelerator();
ev->accept();
break;
case 'q':
close();
ev->accept();
break;
default:
finalcut::FDialog::onKeyPress(ev);
break;
ev->accept();
}
else if ( key == FKey::Escape || key == FKey::Escape_mintty )
{
sendOnButtonAccelerator();
ev->accept();
}
else if ( key == FKey('q') )
{
close();
ev->accept();
}
else
finalcut::FDialog::onKeyPress(ev);
}
//----------------------------------------------------------------------
@ -367,7 +370,7 @@ void Calc::onClose (finalcut::FCloseEvent* ev)
}
//----------------------------------------------------------------------
void Calc::cb_buttonClicked (Calc::button key)
void Calc::cb_buttonClicked (ButtonName key)
{
lDouble& x = getValue();
@ -426,7 +429,7 @@ void Calc::drawDispay()
setReverse(false);
const auto& wc = getColorTheme();
print() << FColorPair{fc::Black, fc::LightGray}
print() << FColorPair{FColor::Black, FColor::LightGray}
<< FPoint{3, 3} << display << ' '
<< FColorPair{wc->dialog_fg, wc->dialog_bg};
@ -435,11 +438,11 @@ void Calc::drawDispay()
if ( finalcut::FTerm::isNewFont() )
{
const wchar_t bottom_line {fc::NF_border_line_bottom};
const wchar_t top_bottom_line {fc::NF_border_line_up_and_down};
const wchar_t top_line {fc::NF_border_line_upper};
const wchar_t right_line {fc::NF_rev_border_line_right};
const wchar_t left_line {fc::NF_border_line_left};
const auto bottom_line {finalcut::UniChar::NF_border_line_bottom};
const auto top_bottom_line {finalcut::UniChar::NF_border_line_up_and_down};
const auto top_line {finalcut::UniChar::NF_border_line_upper};
const auto right_line {finalcut::UniChar::NF_rev_border_line_right};
const auto left_line {finalcut::UniChar::NF_border_line_left};
print() << FPoint{3, 2} << finalcut::FString{33, bottom_line};
print() << FPoint{2, 3} << right_line;
print() << FPoint{36, 3} << left_line;
@ -454,9 +457,9 @@ void Calc::drawDispay()
}
else
{
const wchar_t vertical_and_right {fc::BoxDrawingsVerticalAndRight};
const wchar_t horizontal {fc::BoxDrawingsHorizontal};
const wchar_t vertical_and_left {fc::BoxDrawingsVerticalAndLeft};
const auto vertical_and_right {finalcut::UniChar::BoxDrawingsVerticalAndRight};
const auto horizontal {finalcut::UniChar::BoxDrawingsHorizontal};
const auto vertical_and_left {finalcut::UniChar::BoxDrawingsVerticalAndLeft};
finalcut::FString separator ( finalcut::FString{vertical_and_right}
+ finalcut::FString{35, horizontal}
+ finalcut::FString{vertical_and_left} );
@ -467,8 +470,8 @@ void Calc::drawDispay()
//----------------------------------------------------------------------
inline void Calc::sendOnButtonAccelerator()
{
finalcut::FAccelEvent a_ev(fc::Accelerator_Event, getFocusWidget());
calculator_buttons[On]->onAccel(&a_ev);
finalcut::FAccelEvent a_ev(finalcut::Event::Accelerator, getFocusWidget());
calculator_buttons[ButtonName::On]->onAccel(&a_ev);
}
//----------------------------------------------------------------------
@ -477,8 +480,8 @@ void Calc::clear (const lDouble&)
error = false;
arcus_mode = false;
hyperbolic_mode = false;
calculator_buttons[Arcus]->setChecked(false);
calculator_buttons[Hyperbolic]->setChecked(false);
calculator_buttons[ButtonName::Arcus]->setChecked(false);
calculator_buttons[ButtonName::Hyperbolic]->setChecked(false);
input = "";
clearInfixOperator();
last_infix_operator = '\0';
@ -797,7 +800,7 @@ void Calc::square_root (lDouble& x)
void Calc::hyperbolic (const lDouble& x)
{
hyperbolic_mode = ! hyperbolic_mode;
calculator_buttons[Hyperbolic]->setChecked(hyperbolic_mode);
calculator_buttons[ButtonName::Hyperbolic]->setChecked(hyperbolic_mode);
setDisplay(x);
}
@ -805,7 +808,7 @@ void Calc::hyperbolic (const lDouble& x)
void Calc::arcus (const lDouble& x)
{
arcus_mode = ! arcus_mode;
calculator_buttons[Arcus]->setChecked(arcus_mode);
calculator_buttons[ButtonName::Arcus]->setChecked(arcus_mode);
setDisplay(x);
}
@ -843,8 +846,8 @@ void Calc::sine (lDouble& x)
setDisplay(x);
arcus_mode = false;
hyperbolic_mode = false;
calculator_buttons[Arcus]->setChecked(false);
calculator_buttons[Hyperbolic]->setChecked(false);
calculator_buttons[ButtonName::Arcus]->setChecked(false);
calculator_buttons[ButtonName::Hyperbolic]->setChecked(false);
}
//----------------------------------------------------------------------
@ -881,8 +884,8 @@ void Calc::cosine (lDouble& x)
setDisplay(x);
arcus_mode = false;
hyperbolic_mode = false;
calculator_buttons[Arcus]->setChecked(false);
calculator_buttons[Hyperbolic]->setChecked(false);
calculator_buttons[ButtonName::Arcus]->setChecked(false);
calculator_buttons[ButtonName::Hyperbolic]->setChecked(false);
}
//----------------------------------------------------------------------
@ -926,38 +929,38 @@ void Calc::tangent (lDouble& x)
setDisplay(x);
arcus_mode = false;
hyperbolic_mode = false;
calculator_buttons[Arcus]->setChecked(false);
calculator_buttons[Hyperbolic]->setChecked(false);
calculator_buttons[ButtonName::Arcus]->setChecked(false);
calculator_buttons[ButtonName::Hyperbolic]->setChecked(false);
}
//----------------------------------------------------------------------
void Calc::draw()
{
setBold();
setColor (fc::LightBlue, fc::Cyan);
clearArea (getVirtualDesktop(), fc::MediumShade);
setColor (FColor::LightBlue, FColor::Cyan);
clearArea (getVirtualDesktop(), wchar_t(finalcut::UniChar::MediumShade));
unsetBold();
finalcut::FDialog::draw();
drawDispay();
}
//----------------------------------------------------------------------
bool Calc::isDataEntryKey (int key) const
bool Calc::isDataEntryKey (const ButtonName& key) const
{
// Test if key is in {'.', '0'..'9'}
constexpr std::array<int, 11> key_list =
constexpr std::array<ButtonName, 11> key_list =
{{
Decimal_point,
Zero,
One,
Two,
Three,
Four,
Five,
Six,
Seven,
Eight,
Nine
ButtonName::Decimal_point,
ButtonName::Zero,
ButtonName::One,
ButtonName::Two,
ButtonName::Three,
ButtonName::Four,
ButtonName::Five,
ButtonName::Six,
ButtonName::Seven,
ButtonName::Eight,
ButtonName::Nine
}};
const auto& iter = std::find (key_list.begin(), key_list.end(), key);
@ -969,17 +972,17 @@ bool Calc::isDataEntryKey (int key) const
}
//----------------------------------------------------------------------
bool Calc::isOperatorKey(int key) const
bool Calc::isOperatorKey(const ButtonName& key) const
{
// Test if key is in {'*', '/', '+', '-', '^', '='}
constexpr std::array<int, 6> operators =
constexpr std::array<ButtonName, 6> operators =
{{
Multiply,
Divide,
Add,
Subtract,
Power,
Equals
ButtonName::Multiply,
ButtonName::Divide,
ButtonName::Add,
ButtonName::Subtract,
ButtonName::Power,
ButtonName::Equals
}};
const auto& iter = std::find (operators.begin(), operators.end(), key);
@ -1092,9 +1095,10 @@ void Calc::adjustSize()
}
//----------------------------------------------------------------------
const wchar_t* Calc::getButtonText (const std::size_t key) const
const wchar_t* Calc::getButtonText (const ButtonName& key) const
{
constexpr std::array<const wchar_t*, Calc::NUM_OF_BUTTONS> button_text =
constexpr auto num_of_buttons = std::size_t(ButtonName::NUM_OF_BUTTONS);
constexpr std::array<const wchar_t*, num_of_buttons> button_text =
{{
L"&Sin",
L"&Cos",
@ -1132,47 +1136,81 @@ const wchar_t* Calc::getButtonText (const std::size_t key) const
L"&="
}};
return button_text[key];
return button_text[std::size_t(key)];
}
//----------------------------------------------------------------------
void Calc::mapKeyFunctions()
{
#define B(f) std::bind((f), this, std::placeholders::_1) // Bind macro
key_map[Sine] = B(&Calc::sine); // sin
key_map[Cosine] = B(&Calc::cosine); // cos
key_map[Tangent] = B(&Calc::tangent); // tan
key_map[Reciprocal] = B(&Calc::reciprocal); // 1/x
key_map[On] = B(&Calc::clear); // On
key_map[Natural_logarithm] = B(&Calc::log_e); // ln
key_map[Powers_of_e] = B(&Calc::power_e); // eˣ
key_map[Power] = B(&Calc::power); // yˣ
key_map[Square_root] = B(&Calc::square_root); // sqrt
key_map[Divide] = B(&Calc::divide); // ÷
key_map[Common_logarithm] = B(&Calc::log_10); // lg
key_map[Powers_of_ten] = B(&Calc::power_10); // 10ˣ
key_map[Parenthese_l] = B(&Calc::open_bracket); // (
key_map[Parenthese_r] = B(&Calc::close_bracket); // )
key_map[Multiply] = B(&Calc::multiply); // *
key_map[Hyperbolic] = B(&Calc::hyperbolic); // hyp
key_map[Seven] = B(&Calc::seven); // 7
key_map[Eight] = B(&Calc::eight); // 8
key_map[Nine] = B(&Calc::nine); // 9
key_map[Subtract] = B(&Calc::subtract); // -
key_map[Arcus] = B(&Calc::arcus); // arc
key_map[Four] = B(&Calc::four); // 4
key_map[Five] = B(&Calc::five); // 5
key_map[Six] = B(&Calc::six); // 6
key_map[Add] = B(&Calc::add); // +
key_map[Pi] = B(&Calc::pi); // π
key_map[One] = B(&Calc::one); // 1
key_map[Two] = B(&Calc::two); // 2
key_map[Three] = B(&Calc::three); // 3
key_map[Percent] = B(&Calc::percent); // %
key_map[Zero] = B(&Calc::zero); // 0
key_map[Decimal_point] = B(&Calc::radix_point); // .
key_map[Change_sign] = B(&Calc::change_sign); // ±
key_map[Equals] = B(&Calc::equals); // =
key_map[ButtonName::Sine] = B(&Calc::sine); // sin
key_map[ButtonName::Cosine] = B(&Calc::cosine); // cos
key_map[ButtonName::Tangent] = B(&Calc::tangent); // tan
key_map[ButtonName::Reciprocal] = B(&Calc::reciprocal); // 1/x
key_map[ButtonName::On] = B(&Calc::clear); // On
key_map[ButtonName::Natural_logarithm] = B(&Calc::log_e); // ln
key_map[ButtonName::Powers_of_e] = B(&Calc::power_e); // eˣ
key_map[ButtonName::Power] = B(&Calc::power); // yˣ
key_map[ButtonName::Square_root] = B(&Calc::square_root); // sqrt
key_map[ButtonName::Divide] = B(&Calc::divide); // ÷
key_map[ButtonName::Common_logarithm] = B(&Calc::log_10); // lg
key_map[ButtonName::Powers_of_ten] = B(&Calc::power_10); // 10ˣ
key_map[ButtonName::Parenthese_l] = B(&Calc::open_bracket); // (
key_map[ButtonName::Parenthese_r] = B(&Calc::close_bracket); // )
key_map[ButtonName::Multiply] = B(&Calc::multiply); // *
key_map[ButtonName::Hyperbolic] = B(&Calc::hyperbolic); // hyp
key_map[ButtonName::Seven] = B(&Calc::seven); // 7
key_map[ButtonName::Eight] = B(&Calc::eight); // 8
key_map[ButtonName::Nine] = B(&Calc::nine); // 9
key_map[ButtonName::Subtract] = B(&Calc::subtract); // -
key_map[ButtonName::Arcus] = B(&Calc::arcus); // arc
key_map[ButtonName::Four] = B(&Calc::four); // 4
key_map[ButtonName::Five] = B(&Calc::five); // 5
key_map[ButtonName::Six] = B(&Calc::six); // 6
key_map[ButtonName::Add] = B(&Calc::add); // +
key_map[ButtonName::Pi] = B(&Calc::pi); // π
key_map[ButtonName::One] = B(&Calc::one); // 1
key_map[ButtonName::Two] = B(&Calc::two); // 2
key_map[ButtonName::Three] = B(&Calc::three); // 3
key_map[ButtonName::Percent] = B(&Calc::percent); // %
key_map[ButtonName::Zero] = B(&Calc::zero); // 0
key_map[ButtonName::Decimal_point] = B(&Calc::radix_point); // .
key_map[ButtonName::Change_sign] = B(&Calc::change_sign); // ±
key_map[ButtonName::Equals] = B(&Calc::equals); // =
}
// Overloaded operators
//----------------------------------------------------------------------
inline bool operator < (const Calc::ButtonName& c, const int n) noexcept
{
return bool( int(c) < n );
}
//----------------------------------------------------------------------
inline bool operator <= (const Calc::ButtonName& c, const int n) noexcept
{
return bool( int(c) <= n );
}
//----------------------------------------------------------------------
inline Calc::ButtonName operator + (const Calc::ButtonName& c, const int n) noexcept
{
return Calc::ButtonName(int(c) + n);
}
//----------------------------------------------------------------------
inline Calc::ButtonName& operator ++ (Calc::ButtonName& c) noexcept // prefix
{
c = ( c < Calc::ButtonName::NUM_OF_BUTTONS ) ? Calc::ButtonName(int(c) + 1) : Calc::ButtonName::Equals;
return c;
}
//----------------------------------------------------------------------
inline Calc::ButtonName operator ++ (Calc::ButtonName& c, int) noexcept // postfix
{
Calc::ButtonName tmp = c;
++c;
return tmp;
}

View File

@ -93,12 +93,12 @@ CheckList::CheckList (finalcut::FWidget* parent)
listview.addColumn ("Priority", 9);
// Set the type of sorting
listview.setColumnSortType (1, fc::by_name);
listview.setColumnSortType (2, fc::by_name);
listview.setColumnSortType (1, finalcut::SortType::Name);
listview.setColumnSortType (2, finalcut::SortType::Name);
// Statusbar at the bottom
finalcut::FString separator{};
separator << ' ' << fc::BoxDrawingsVertical << ' ';
separator << ' ' << finalcut::UniChar::BoxDrawingsVertical << ' ';
listview.setStatusbarMessage ( finalcut::FString{}
<< "<Q> exit" << separator
<< "<Space> select an item" << separator
@ -154,9 +154,9 @@ void CheckList::onKeyPress (finalcut::FKeyEvent* ev)
if ( ! ev )
return;
if ( ev->key() == 'q'
|| ev->key() == fc::Fkey_escape
|| ev->key() == fc::Fkey_escape_mintty )
if ( ev->key() == finalcut::FKey('q')
|| ev->key() == finalcut::FKey::Escape
|| ev->key() == finalcut::FKey::Escape_mintty )
{
close();
ev->accept();
@ -179,7 +179,7 @@ void CheckList::cb_showList()
for (auto item : listview.getData())
{
if ( item->isChecked() )
shopping_list << fc::Bullet << ' ' << item->getText(1) << '\n';
shopping_list << finalcut::UniChar::Bullet << ' ' << item->getText(1) << '\n';
}
if ( shopping_list.isEmpty() )

View File

@ -128,7 +128,7 @@ int main (int argc, char* argv[])
preset(os);
// Scroll to the focused child element
finalcut::FFocusEvent cfi (finalcut::fc::ChildFocusIn_Event);
finalcut::FFocusEvent cfi (finalcut::Event::ChildFocusIn);
app.queueEvent(&checkButtonGroup, &cfi);
// Create a OK button

View File

@ -55,10 +55,10 @@ int main (int argc, char* argv[])
finalcut::FLabel label_1{&dgl};
finalcut::FLabel label_2{&dgl};
label_1 << finalcut::fc::BlackUpPointingTriangle
label_1 << finalcut::UniChar::BlackUpPointingTriangle
<< std::wstring{L"\n"}
<< finalcut::fc::BoxDrawingsUpAndRight
<< finalcut::FString{2, finalcut::fc::BoxDrawingsHorizontal}
<< finalcut::UniChar::BoxDrawingsUpAndRight
<< finalcut::FString{2, finalcut::UniChar::BoxDrawingsHorizontal}
<< " Double click the title bar button,";
label_2 << "press Q on the keyboard,\n"
<< "or push the button below to exit\n"

View File

@ -58,7 +58,7 @@ class EventDialog final : public finalcut::FDialog
private:
// Methods
finalcut::FString getMouseButtonName (int) const;
finalcut::FString getMouseButtonName (const finalcut::MouseButton&) const;
void logMouseEvent ( const finalcut::FString&
, const finalcut::FMouseEvent& );
@ -93,7 +93,7 @@ EventDialog::EventDialog (finalcut::FWidget* parent)
setShadow();
label.setText("\n\nUse the keyboard or mouse\n"
"in this dialog to create events");
label.setAlignment(finalcut::fc::alignCenter);
label.setAlignment(finalcut::Align::Center);
label.setGeometry (FPoint(1, 1), getClientSize(), false);
addTimer(60000); // Starts the timer every minute
}
@ -102,19 +102,25 @@ EventDialog::EventDialog (finalcut::FWidget* parent)
EventDialog::~EventDialog() noexcept = default; // destructor
//----------------------------------------------------------------------
finalcut::FString EventDialog::getMouseButtonName (int btn_state) const
finalcut::FString EventDialog::getMouseButtonName (const finalcut::MouseButton& btn_state) const
{
switch ( btn_state )
{
case finalcut::fc::LeftButton:
return "left";
const auto& empty = finalcut::fc::emptyFString::get();
auto S = bool(btn_state & finalcut::MouseButton::Shift);
auto C = bool(btn_state & finalcut::MouseButton::Control);
auto M = bool(btn_state & finalcut::MouseButton::Meta);
auto l = bool(btn_state & finalcut::MouseButton::Left);
auto r = bool(btn_state & finalcut::MouseButton::Right);
auto m = bool(btn_state & finalcut::MouseButton::Middle);
auto prefix = (S ? finalcut::FString("Shift+") : empty)
+ (C ? finalcut::FString("Control+") : empty)
+ (M ? finalcut::FString("Meta+") : empty);
case finalcut::fc::RightButton:
return "right";
case finalcut::fc::MiddleButton:
return "middle";
}
if ( l )
return prefix + "left";
else if ( r )
return prefix + "right";
else if ( m )
return prefix + "middle";
return "unknown";
}
@ -155,7 +161,7 @@ void EventDialog::onTimer (finalcut::FTimerEvent*)
//----------------------------------------------------------------------
void EventDialog::onKeyPress (finalcut::FKeyEvent* ev)
{
const FKey key_id = ev->key();
const finalcut::FKey key_id = ev->key();
finalcut::FString key_name = finalcut::FTerm::getKeyName(key_id);
if ( key_name.isEmpty() )
@ -164,7 +170,7 @@ void EventDialog::onKeyPress (finalcut::FKeyEvent* ev)
// std::clog redirects all stream data to FLogger
std::clog << finalcut::FLog::LogLevel::Info
<< "Key " << key_name
<< " (id " << key_id << ")" << std::flush;
<< " (id " << uInt32(key_id) << ")" << std::flush;
finalcut::FDialog::onKeyPress(ev);
}

View File

@ -85,7 +85,7 @@ int main (int argc, char* argv[])
// Create the status bar
finalcut::FStatusBar sbar {&dgl};
finalcut::FStatusKey key_F1 (finalcut::fc::Fkey_f1, "Info", &sbar);
finalcut::FStatusKey key_F1 (finalcut::FKey::F1, "Info", &sbar);
// Create the menu bar
finalcut::FMenuBar Menubar {&dgl};
@ -101,7 +101,7 @@ int main (int argc, char* argv[])
finalcut::FMenuItem Line{&File};
Line.setSeparator();
finalcut::FMenuItem Quit{"&", &File};
Quit.addAccelerator (finalcut::fc::Fckey_q); // Ctrl + Q
Quit.addAccelerator (finalcut::FKey::Ctrl_q); // Ctrl + Q
// Callback lambda expressions
auto cb_exit = \

View File

@ -76,7 +76,7 @@ int main (int argc, char* argv[])
finalcut::FLineEdit c_field {&dgl};
// Set input type to password
pw_field.setInputType (finalcut::FLineEdit::InputType::password);
pw_field.setInputType (finalcut::FLineEdit::InputType::Password);
name_field.setLabelText (L"&Name");
pw_field.setLabelText (L"&Password");

View File

@ -46,14 +46,14 @@ class Keyboard final : public finalcut::FWidget
Keyboard::Keyboard (finalcut::FWidget* parent)
: finalcut::FWidget{parent}
{
getColorTheme()->term_fg = finalcut::fc::Default;
getColorTheme()->term_bg = finalcut::fc::Default;
getColorTheme()->term_fg = finalcut::FColor::Default;
getColorTheme()->term_bg = finalcut::FColor::Default;
}
//----------------------------------------------------------------------
void Keyboard::onKeyPress (finalcut::FKeyEvent* ev)
{
const FKey key_id = ev->key();
const finalcut::FKey key_id = ev->key();
finalcut::FString key_name = finalcut::FTerm::getKeyName(key_id);
bool is_last_line{false};
@ -63,7 +63,7 @@ void Keyboard::onKeyPress (finalcut::FKeyEvent* ev)
if ( getPrintPos().getY() == int(getDesktopHeight()) )
is_last_line = true;
print() << "Key " << key_name << " (id " << key_id << ")\n";
print() << "Key " << key_name << " (id " << uInt32(key_id) << ")\n";
if ( is_last_line )
scrollAreaForward (getVirtualDesktop());
@ -98,12 +98,12 @@ int main (int argc, char* argv[])
// Force terminal initialization without calling show()
app.initTerminal();
app.setForegroundColor(finalcut::fc::Default);
app.setBackgroundColor(finalcut::fc::Default);
app.setForegroundColor(finalcut::FColor::Default);
app.setBackgroundColor(finalcut::FColor::Default);
// Create a keyboard object
Keyboard key{&app};
key.addAccelerator('q');
key.addAccelerator(finalcut::FKey('q'));
// Set the keyboard object as main widget
finalcut::FWidget::setMainWidget(&key);

View File

@ -82,19 +82,19 @@ Listview::Listview (finalcut::FWidget* parent)
listview.addColumn ("Pressure", 10);
// Set right alignment for the third, fourth, and fifth column
listview.setColumnAlignment (3, fc::alignRight);
listview.setColumnAlignment (4, fc::alignRight);
listview.setColumnAlignment (5, fc::alignRight);
listview.setColumnAlignment (3, finalcut::Align::Right);
listview.setColumnAlignment (4, finalcut::Align::Right);
listview.setColumnAlignment (5, finalcut::Align::Right);
// Set the type of sorting
listview.setColumnSortType (1, fc::by_name);
listview.setColumnSortType (2, fc::by_name);
listview.setColumnSortType (3, fc::by_number);
listview.setColumnSortType (4, fc::by_number);
listview.setColumnSortType (5, fc::by_number);
listview.setColumnSortType (1, finalcut::SortType::Name);
listview.setColumnSortType (2, finalcut::SortType::Name);
listview.setColumnSortType (3, finalcut::SortType::Number);
listview.setColumnSortType (4, finalcut::SortType::Number);
listview.setColumnSortType (5, finalcut::SortType::Number);
// Sort in ascending order by the 1st column
listview.setColumnSort (1, fc::ascending);
listview.setColumnSort (1, finalcut::SortOrder::Ascending);
// Sorting follows later automatically on insert().
// Otherwise you could start the sorting directly with sort()

View File

@ -23,6 +23,7 @@
#include <final/final.h>
namespace fc = finalcut::fc;
using finalcut::FColor;
using finalcut::FPoint;
using finalcut::FSize;
@ -103,9 +104,9 @@ void Mandelbrot::draw()
}
if ( iter < max_iter )
setColor(fc::Black, iter % 16);
setColor(FColor::Black, FColor(iter % 16));
else
setColor(fc::Black, 0);
setColor(FColor::Black, FColor::Black);
print(' ');
x0 += dX;
@ -121,7 +122,7 @@ void Mandelbrot::onKeyPress (finalcut::FKeyEvent* ev)
if ( ! ev )
return;
if ( ev->key() == 'q' )
if ( ev->key() == finalcut::FKey('q') )
{
close();
ev->accept();

View File

@ -22,7 +22,7 @@
#include <final/final.h>
namespace fc = finalcut::fc;
using FKey = finalcut::FKey;
using finalcut::FPoint;
using finalcut::FSize;
@ -64,7 +64,7 @@ class Menu final : public finalcut::FDialog
void cb_message (const finalcut::FMenuItem*);
// Data members
finalcut::FString line{13, fc::BoxDrawingsHorizontal};
finalcut::FString line{13, finalcut::UniChar::BoxDrawingsHorizontal};
finalcut::FMenuBar Menubar{this};
finalcut::FMenu File{"&File", &Menubar};
finalcut::FMenu Edit{"&Edit", &Menubar};
@ -80,17 +80,17 @@ class Menu final : public finalcut::FDialog
finalcut::FMenuItem Print{"&Print", &File};
finalcut::FMenuItem Line2{&File};
finalcut::FMenuItem Quit{"&Quit", &File};
finalcut::FMenuItem Undo{fc::Fckey_z, "&Undo", &Edit};
finalcut::FMenuItem Redo{fc::Fckey_y, "&Redo", &Edit};
finalcut::FMenuItem Undo{FKey::Ctrl_z, "&Undo", &Edit};
finalcut::FMenuItem Redo{FKey::Ctrl_y, "&Redo", &Edit};
finalcut::FMenuItem Line3{&Edit};
finalcut::FMenuItem Cut{fc::Fckey_x, "Cu&t", &Edit};
finalcut::FMenuItem Copy{fc::Fckey_c, "&Copy", &Edit};
finalcut::FMenuItem Paste{fc::Fckey_v, "&Paste", &Edit};
finalcut::FMenuItem Cut{FKey::Ctrl_x, "Cu&t", &Edit};
finalcut::FMenuItem Copy{FKey::Ctrl_c, "&Copy", &Edit};
finalcut::FMenuItem Paste{FKey::Ctrl_v, "&Paste", &Edit};
finalcut::FMenuItem Line4{&Edit};
finalcut::FMenuItem Search{fc::Fckey_f, "&Search", &Edit};
finalcut::FMenuItem Next{fc::Fkey_f3, "Search &next", &Edit};
finalcut::FMenuItem Search{FKey::Ctrl_f, "&Search", &Edit};
finalcut::FMenuItem Next{FKey::F3, "Search &next", &Edit};
finalcut::FMenuItem Line5{&Edit};
finalcut::FMenuItem SelectAll{fc::Fckey_a, "Select &all", &Edit};
finalcut::FMenuItem SelectAll{FKey::Ctrl_a, "Select &all", &Edit};
finalcut::FMenu Color{"&Color", &Choice};
finalcut::FMenu Style{"&Style", &Choice};
finalcut::FMenu Border{"&Border", &Choice};
@ -161,20 +161,20 @@ Menu::Menu (finalcut::FWidget* parent)
void Menu::configureFileMenuItems()
{
// "File" menu items
New.addAccelerator (fc::Fckey_n); // Ctrl + N
New.addAccelerator (FKey::Ctrl_n); // Ctrl + N
New.setStatusbarMessage ("Create a new file");
Open.addAccelerator (fc::Fckey_o); // Ctrl + O
Open.addAccelerator (FKey::Ctrl_o); // Ctrl + O
Open.setStatusbarMessage ("Locate and open a text file");
Save.addAccelerator (fc::Fckey_s); // Ctrl + S
Save.addAccelerator (FKey::Ctrl_s); // Ctrl + S
Save.setStatusbarMessage ("Save the file");
SaveAs.setStatusbarMessage ("Save the current file under a different name");
Close.addAccelerator (fc::Fckey_w); // Ctrl + W
Close.addAccelerator (FKey::Ctrl_w); // Ctrl + W
Close.setStatusbarMessage ("Close the current file");
Line1.setSeparator();
Print.addAccelerator (fc::Fckey_p); // Ctrl + P
Print.addAccelerator (FKey::Ctrl_p); // Ctrl + P
Print.setStatusbarMessage ("Print the current file");
Line2.setSeparator();
Quit.addAccelerator (fc::Fmkey_x); // Meta/Alt + X
Quit.addAccelerator (FKey::Meta_x); // Meta/Alt + X
Quit.setStatusbarMessage ("Exit the program");
// Add quit menu item callback

View File

@ -24,6 +24,7 @@
namespace fc = finalcut::fc;
using finalcut::FColorPair;
using finalcut::FColor;
using finalcut::FRect;
using finalcut::FPoint;
using finalcut::FSize;
@ -64,8 +65,8 @@ class ColorChooser final : public finalcut::FWidget
void onMouseDown (finalcut::FMouseEvent*) override;
// Data members
FColor fg_color{fc::White};
FColor bg_color{fc::Black};
FColor fg_color{FColor::White};
FColor bg_color{FColor::Black};
finalcut::FLabel headline{this};
};
@ -81,7 +82,7 @@ ColorChooser::ColorChooser (finalcut::FWidget* parent)
// Text label
headline.setGeometry (FPoint{1, 1}, FSize{8, 1});
headline.setEmphasis();
headline.setAlignment (fc::alignCenter);
headline.setAlignment (finalcut::Align::Center);
headline << "Color";
}
@ -113,20 +114,20 @@ void ColorChooser::draw()
setColor();
drawBorder();
for (FColor c{0}; c < 16; c++)
for (FColor c{FColor::Black}; c < 16; c++)
{
print() << FPoint{2 + (c / 8) * 3, 3 + c % 8};
print() << FPoint{2 + (int(c) / 8) * 3, 3 + int(c) % 8};
if ( c < 6 )
setColor (fc::LightGray, c);
setColor (FColor::LightGray, c);
else if ( c > 8 )
setColor (fc::DarkGray, c);
setColor (FColor::DarkGray, c);
else
setColor (fc::White, c);
setColor (FColor::White, c);
if ( c == bg_color )
{
print() << L' ' << wchar_t(fc::Times) << L' ';
print() << L' ' << wchar_t(finalcut::UniChar::Times) << L' ';
}
else
print (" ");
@ -145,7 +146,7 @@ void ColorChooser::onMouseDown (finalcut::FMouseEvent* ev)
const int mouse_x = ev->getX();
const int mouse_y = ev->getY();
if ( ev->getButton() == fc::MiddleButton )
if ( ev->getButton() == finalcut::MouseButton::Middle )
return;
for (auto c{0}; c < 16; c++)
@ -156,9 +157,9 @@ void ColorChooser::onMouseDown (finalcut::FMouseEvent* ev)
if ( mouse_x >= xmin && mouse_x <= xmax && mouse_y == y )
{
if ( ev->getButton() == fc::LeftButton )
if ( ev->getButton() == finalcut::MouseButton::Left )
bg_color = FColor(c);
else if ( ev->getButton() == fc::RightButton )
else if ( ev->getButton() == finalcut::MouseButton::Right )
fg_color = FColor(c);
redraw();
@ -207,8 +208,8 @@ class Brushes final : public finalcut::FWidget
// Data members
wchar_t brush{L' '};
FColor fg_color{fc::White};
FColor bg_color{fc::Black};
FColor fg_color{FColor::White};
FColor bg_color{FColor::Black};
finalcut::FLabel headline{this};
};
@ -223,7 +224,7 @@ Brushes::Brushes (finalcut::FWidget* parent)
// Text label
headline.setGeometry(FPoint{1, 1}, FSize{8, 1});
headline.setEmphasis();
headline.setAlignment (fc::alignCenter);
headline.setAlignment (finalcut::Align::Center);
headline << "Brush";
}
@ -245,16 +246,16 @@ void Brushes::draw()
drawBorder();
print() << FPoint{2, 3}
<< FColorPair{fg_color, bg_color} << " "
<< finalcut::FString{3, fc::MediumShade};
<< finalcut::FString{3, finalcut::UniChar::MediumShade};
if ( brush != L' ' )
pos = 3;
setColor();
print() << FPoint{3 + pos, 2}
<< fc::BlackDownPointingTriangle
<< finalcut::UniChar::BlackDownPointingTriangle
<< FPoint{3 + pos, 4}
<< fc::BlackUpPointingTriangle;
<< finalcut::UniChar::BlackUpPointingTriangle;
}
//----------------------------------------------------------------------
@ -269,7 +270,7 @@ void Brushes::onMouseDown (finalcut::FMouseEvent* ev)
const int mouse_x = ev->getX();
const int mouse_y = ev->getY();
if ( ev->getButton() != fc::LeftButton )
if ( ev->getButton() != finalcut::MouseButton::Left )
return;
if ( mouse_x >= 2 && mouse_x <= 4 && mouse_y == 3 )
@ -279,7 +280,7 @@ void Brushes::onMouseDown (finalcut::FMouseEvent* ev)
}
else if ( mouse_x >= 5 && mouse_x <= 7 && mouse_y == 3 )
{
brush = fc::MediumShade;
brush = wchar_t(finalcut::UniChar::MediumShade);
redraw();
}
}
@ -398,7 +399,7 @@ void MouseDraw::onKeyPress (finalcut::FKeyEvent* ev)
if ( ! ev )
return;
if ( ev->key() == 'q' )
if ( ev->key() == finalcut::FKey('q') )
{
close();
ev->accept();
@ -425,24 +426,24 @@ void MouseDraw::draw()
for (auto y{2}; y < y_max; y++)
{
print() << FPoint{10, y}
<< fc::NF_rev_border_line_right;
<< finalcut::UniChar::NF_rev_border_line_right;
}
print() << FPoint{10, y_max}
<< fc::NF_rev_border_corner_lower_right;
<< finalcut::UniChar::NF_rev_border_corner_lower_right;
}
else
{
print() << FPoint{10, 2}
<< fc::BoxDrawingsDownAndHorizontal;
<< finalcut::UniChar::BoxDrawingsDownAndHorizontal;
for (auto y{3}; y < y_max; y++)
{
print() << FPoint{10, y} << fc::BoxDrawingsVertical;
print() << FPoint{10, y} << finalcut::UniChar::BoxDrawingsVertical;
}
print() << FPoint{10, y_max}
<< fc::BoxDrawingsUpAndHorizontal;
<< finalcut::UniChar::BoxDrawingsUpAndHorizontal;
}
drawCanvas();
@ -539,13 +540,13 @@ void MouseDraw::onMouseDown (finalcut::FMouseEvent* ev)
{
finalcut::FDialog::onMouseDown(ev);
if ( ev->getButton() != fc::LeftButton
&& ev->getButton() != fc::RightButton )
if ( ev->getButton() != finalcut::MouseButton::Left
&& ev->getButton() != finalcut::MouseButton::Right )
return;
drawBrush ( ev->getX()
, ev->getY()
, ev->getButton() == fc::RightButton );
, ev->getButton() == finalcut::MouseButton::Right );
}
//----------------------------------------------------------------------
@ -553,13 +554,13 @@ void MouseDraw::onMouseMove (finalcut::FMouseEvent* ev)
{
FDialog::onMouseMove(ev);
if ( ev->getButton() != fc::LeftButton
&& ev->getButton() != fc::RightButton )
if ( ev->getButton() != finalcut::MouseButton::Left
&& ev->getButton() != finalcut::MouseButton::Right )
return;
drawBrush ( ev->getX()
, ev->getY()
, ev->getButton() == fc::RightButton);
, ev->getButton() == finalcut::MouseButton::Right );
}
//----------------------------------------------------------------------

View File

@ -35,6 +35,7 @@ using std::chrono::system_clock;
using std::chrono::time_point;
using finalcut::FPoint;
using finalcut::FSize;
using finalcut::FColor;
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// This rotozoomer demo is based on the code of Robert Dörfler
@ -164,11 +165,11 @@ void RotoZoomer::rotozoomer (double cx, double cy, double r, double a)
auto ch = data[((Cy >> 14) & 0xf) + ((Cx >> 10) & 0xf0)];
if ( ch == '+' )
print() << finalcut::FColorPair{fc::Black, fc::Red};
print() << finalcut::FColorPair{FColor::Black, FColor::Red};
else if ( ch == 'x' )
print() << finalcut::FColorPair{fc::Black, fc::Cyan};
print() << finalcut::FColorPair{FColor::Black, FColor::Cyan};
else
print() << finalcut::FColorPair{fc::Black, fc::White};
print() << finalcut::FColorPair{FColor::Black, FColor::White};
print() << ch;
Cx += dxdx;
@ -249,7 +250,7 @@ void RotoZoomer::onKeyPress (finalcut::FKeyEvent* ev)
if ( ! ev )
return;
if ( ev->key() == 'q' )
if ( ev->key() == finalcut::FKey('q') )
{
close();
ev->accept();

View File

@ -60,10 +60,10 @@ class Scrollview final : public finalcut::FScrollView
void cb_goNorth();
// Data members
wchar_t pointer_right{fc::BlackRightPointingPointer};
wchar_t pointer_down{fc::BlackDownPointingTriangle};
wchar_t pointer_left{fc::BlackLeftPointingPointer};
wchar_t pointer_up{fc::BlackUpPointingTriangle};
finalcut::UniChar pointer_right{finalcut::UniChar::BlackRightPointingPointer};
finalcut::UniChar pointer_down{finalcut::UniChar::BlackDownPointingTriangle};
finalcut::UniChar pointer_left{finalcut::UniChar::BlackLeftPointingPointer};
finalcut::UniChar pointer_up{finalcut::UniChar::BlackUpPointingTriangle};
finalcut::FButton go_east{pointer_right, this};
finalcut::FButton go_south{pointer_down, this};
finalcut::FButton go_west{pointer_left, this};

View File

@ -28,6 +28,7 @@ namespace fc = finalcut::fc;
using finalcut::FPoint;
using finalcut::FSize;
using finalcut::FColorPair;
using finalcut::FColor;
//----------------------------------------------------------------------
@ -62,15 +63,12 @@ class AttribDlg final : public finalcut::FDialog
void cb_back();
private:
// Constants
static constexpr auto UNDEFINED = static_cast<FColor>(-2);
// Method
void adjustSize() override;
void draw() override;
// Data members
FColor bgcolor{UNDEFINED};
FColor bgcolor{FColor::Undefined};
finalcut::FButton next_button{"&Next >", this};
finalcut::FButton back_button{"< &Back", this};
};
@ -81,10 +79,10 @@ AttribDlg::AttribDlg (finalcut::FWidget* parent)
{
next_button.setGeometry ( FPoint{int(getWidth()) - 13, int(getHeight()) - 4}
, FSize{10, 1} );
next_button.addAccelerator (fc::Fkey_right);
next_button.addAccelerator (finalcut::FKey::Right);
back_button.setGeometry ( FPoint{int(getWidth()) - 25, int(getHeight()) - 4}
, FSize{10, 1} );
back_button.addAccelerator (fc::Fkey_left);
back_button.addAccelerator (finalcut::FKey::Left);
// Add function callbacks
next_button.addCallback
@ -112,7 +110,7 @@ void AttribDlg::onKeyPress (finalcut::FKeyEvent* ev)
if ( ! ev )
return;
if ( ev->key() == 'q' )
if ( ev->key() == finalcut::FKey('q') )
{
close();
ev->accept();
@ -124,11 +122,11 @@ void AttribDlg::onKeyPress (finalcut::FKeyEvent* ev)
//----------------------------------------------------------------------
void AttribDlg::onWheel (finalcut::FWheelEvent* ev)
{
const int wheel = ev->getWheel();
const finalcut::MouseWheel wheel = ev->getWheel();
if ( wheel == fc::WheelUp )
if ( wheel == finalcut::MouseWheel::Up )
cb_next();
else if ( wheel == fc::WheelDown )
else if ( wheel == finalcut::MouseWheel::Down )
cb_back();
}
@ -145,9 +143,9 @@ void AttribDlg::cb_next()
return;
if ( bgcolor == FColor(finalcut::FTerm::getMaxColor() - 1) )
bgcolor = fc::Default;
else if ( bgcolor == fc::Default )
bgcolor = 0;
bgcolor = FColor::Default;
else if ( bgcolor == FColor::Default )
bgcolor = FColor::Black;
else
bgcolor++;
@ -161,8 +159,8 @@ void AttribDlg::cb_back()
return;
if ( bgcolor == 0 )
bgcolor = fc::Default;
else if ( bgcolor == fc::Default )
bgcolor = FColor::Default;
else if ( bgcolor == FColor::Default )
bgcolor = FColor(finalcut::FTerm::getMaxColor() - 1);
else
bgcolor--;
@ -193,11 +191,11 @@ void AttribDlg::adjustSize()
//----------------------------------------------------------------------
void AttribDlg::draw()
{
if ( bgcolor == UNDEFINED )
if ( bgcolor == FColor::Undefined )
{
// Get the color after initializing the color theme in show()
if ( finalcut::FTerm::isMonochron() )
bgcolor = fc::Default;
bgcolor = FColor::Default;
else
bgcolor = getColorTheme()->label_bg;
@ -253,7 +251,7 @@ class AttribDemo final : public finalcut::FWidget
void draw() override;
// Data member
FColor last_color{1};
FColor last_color{FColor::Blue};
};
//----------------------------------------------------------------------
@ -268,7 +266,7 @@ void AttribDemo::printColorLine()
{
const auto& parent = static_cast<AttribDlg*>(getParent());
for (FColor color{0}; color < last_color; color++)
for (FColor color{FColor::Black}; color < last_color; color++)
{
print() << FColorPair{color, parent->getBGColor()} << " # ";
}
@ -285,9 +283,9 @@ void AttribDemo::printAltCharset()
print() << FPoint{1, 1} << "alternate charset: ";
if ( parent->getBGColor() == fc::Default )
if ( parent->getBGColor() == FColor::Default )
{
setColor (fc::Default, fc::Default);
setColor (FColor::Default, FColor::Default);
}
else
{
@ -295,9 +293,9 @@ void AttribDemo::printAltCharset()
|| (parent->getBGColor() >= 16 && parent->getBGColor() <= 231
&& (parent->getBGColor() - 16) % 36 <= 17)
|| (parent->getBGColor() >= 232 && parent->getBGColor() <= 243) )
setColor (fc::White, parent->getBGColor());
setColor (FColor::White, parent->getBGColor());
else
setColor (fc::Black, parent->getBGColor());
setColor (FColor::Black, parent->getBGColor());
}
setAltCharset();
@ -431,9 +429,9 @@ void AttribDemo::draw()
last_color = FColor(finalcut::FTerm::getMaxColor());
if ( finalcut::FTerm::isMonochron() )
last_color = 1;
last_color = FColor(1);
else if ( last_color > 16 )
last_color = 16;
last_color = FColor(16);
// test alternate character set
printAltCharset();
@ -472,7 +470,7 @@ void AttribDemo::draw()
const FColor bg = static_cast<AttribDlg*>(getParent())->getBGColor();
print (" Background color:");
if ( bg == fc::Default )
if ( bg == FColor::Default )
print (" default");
else
printf ( " %d", bg);

View File

@ -28,6 +28,7 @@
#include <final/final.h>
namespace fc = finalcut::fc;
using finalcut::Termcap;
// Function prototype
void tcapBoolean (const std::string&, bool);
@ -48,7 +49,7 @@ struct Data
struct alignas(alignof(std::string)) TermcapString
{
const std::string name;
const fc::termcaps cap;
const Termcap cap;
};
static std::array<TermcapString, 83> strings;
@ -59,89 +60,89 @@ struct Data
//----------------------------------------------------------------------
std::array<Data::TermcapString, 83> Data::strings =
{{
{ "t_bell", fc::t_bell },
{ "t_erase_chars", fc::t_erase_chars },
{ "t_clear_screen", fc::t_clear_screen },
{ "t_clr_eos", fc::t_clr_eos },
{ "t_clr_eol", fc::t_clr_eol },
{ "t_clr_bol", fc::t_clr_bol },
{ "t_cursor_home", fc::t_cursor_home },
{ "t_cursor_to_ll", fc::t_cursor_to_ll },
{ "t_carriage_return", fc::t_carriage_return },
{ "t_tab", fc::t_tab },
{ "t_back_tab", fc::t_back_tab },
{ "t_insert_padding", fc::t_insert_padding },
{ "t_insert_character", fc::t_insert_character },
{ "t_parm_ich", fc::t_parm_ich },
{ "t_repeat_char", fc::t_repeat_char },
{ "t_initialize_color", fc::t_initialize_color },
{ "t_initialize_pair", fc::t_initialize_pair },
{ "t_set_a_foreground", fc::t_set_a_foreground },
{ "t_set_a_background", fc::t_set_a_background },
{ "t_set_foreground", fc::t_set_foreground },
{ "t_set_background", fc::t_set_background },
{ "t_set_color_pair", fc::t_set_color_pair },
{ "t_orig_pair", fc::t_orig_pair },
{ "t_orig_colors", fc::t_orig_colors },
{ "t_no_color_video", fc::t_no_color_video },
{ "t_cursor_address", fc::t_cursor_address },
{ "t_column_address", fc::t_column_address },
{ "t_row_address", fc::t_row_address },
{ "t_cursor_visible", fc::t_cursor_visible },
{ "t_cursor_invisible", fc::t_cursor_invisible },
{ "t_cursor_normal", fc::t_cursor_normal },
{ "t_cursor_up", fc::t_cursor_up },
{ "t_cursor_down", fc::t_cursor_down },
{ "t_cursor_left", fc::t_cursor_left },
{ "t_cursor_right", fc::t_cursor_right },
{ "t_parm_up_cursor", fc::t_parm_up_cursor },
{ "t_parm_down_cursor", fc::t_parm_down_cursor },
{ "t_parm_left_cursor", fc::t_parm_left_cursor },
{ "t_parm_right_cursor", fc::t_parm_right_cursor },
{ "t_save_cursor", fc::t_save_cursor },
{ "t_restore_cursor", fc::t_restore_cursor },
{ "t_cursor_style", fc::t_cursor_style },
{ "t_scroll_forward", fc::t_scroll_forward },
{ "t_scroll_reverse", fc::t_scroll_reverse },
{ "t_enter_ca_mode", fc::t_enter_ca_mode },
{ "t_exit_ca_mode", fc::t_exit_ca_mode },
{ "t_enable_acs", fc::t_enable_acs },
{ "t_enter_bold_mode", fc::t_enter_bold_mode },
{ "t_exit_bold_mode", fc::t_exit_bold_mode },
{ "t_enter_dim_mode", fc::t_enter_dim_mode },
{ "t_exit_dim_mode", fc::t_exit_dim_mode },
{ "t_enter_italics_mode", fc::t_enter_italics_mode },
{ "t_exit_italics_mode", fc::t_exit_italics_mode },
{ "t_enter_underline_mode", fc::t_enter_underline_mode },
{ "t_exit_underline_mode", fc::t_exit_underline_mode },
{ "t_enter_blink_mode", fc::t_enter_blink_mode },
{ "t_exit_blink_mode", fc::t_exit_blink_mode },
{ "t_enter_reverse_mode", fc::t_enter_reverse_mode },
{ "t_exit_reverse_mode", fc::t_exit_reverse_mode },
{ "t_enter_standout_mode", fc::t_enter_standout_mode },
{ "t_exit_standout_mode", fc::t_exit_standout_mode },
{ "t_enter_secure_mode", fc::t_enter_secure_mode },
{ "t_exit_secure_mode", fc::t_exit_secure_mode },
{ "t_enter_protected_mode", fc::t_enter_protected_mode },
{ "t_exit_protected_mode", fc::t_exit_protected_mode },
{ "t_enter_crossed_out_mode", fc::t_enter_crossed_out_mode },
{ "t_exit_crossed_out_mode", fc::t_exit_crossed_out_mode },
{ "t_enter_dbl_underline_mode", fc::t_enter_dbl_underline_mode },
{ "t_exit_dbl_underline_mode", fc::t_exit_dbl_underline_mode },
{ "t_set_attributes", fc::t_set_attributes },
{ "t_exit_attribute_mode", fc::t_exit_attribute_mode },
{ "t_enter_alt_charset_mode", fc::t_enter_alt_charset_mode },
{ "t_exit_alt_charset_mode", fc::t_exit_alt_charset_mode },
{ "t_enter_pc_charset_mode", fc::t_enter_pc_charset_mode },
{ "t_exit_pc_charset_mode", fc::t_exit_pc_charset_mode },
{ "t_enter_insert_mode", fc::t_enter_insert_mode },
{ "t_exit_insert_mode", fc::t_exit_insert_mode },
{ "t_enter_am_mode", fc::t_enter_am_mode },
{ "t_exit_am_mode", fc::t_exit_am_mode },
{ "t_acs_chars", fc::t_acs_chars },
{ "t_keypad_xmit", fc::t_keypad_xmit },
{ "t_keypad_local", fc::t_keypad_local },
{ "t_key_mouse", fc::t_key_mouse }
{ "t_bell", Termcap::t_bell },
{ "t_erase_chars", Termcap::t_erase_chars },
{ "t_clear_screen", Termcap::t_clear_screen },
{ "t_clr_eos", Termcap::t_clr_eos },
{ "t_clr_eol", Termcap::t_clr_eol },
{ "t_clr_bol", Termcap::t_clr_bol },
{ "t_cursor_home", Termcap::t_cursor_home },
{ "t_cursor_to_ll", Termcap::t_cursor_to_ll },
{ "t_carriage_return", Termcap::t_carriage_return },
{ "t_tab", Termcap::t_tab },
{ "t_back_tab", Termcap::t_back_tab },
{ "t_insert_padding", Termcap::t_insert_padding },
{ "t_insert_character", Termcap::t_insert_character },
{ "t_parm_ich", Termcap::t_parm_ich },
{ "t_repeat_char", Termcap::t_repeat_char },
{ "t_initialize_color", Termcap::t_initialize_color },
{ "t_initialize_pair", Termcap::t_initialize_pair },
{ "t_set_a_foreground", Termcap::t_set_a_foreground },
{ "t_set_a_background", Termcap::t_set_a_background },
{ "t_set_foreground", Termcap::t_set_foreground },
{ "t_set_background", Termcap::t_set_background },
{ "t_set_color_pair", Termcap::t_set_color_pair },
{ "t_orig_pair", Termcap::t_orig_pair },
{ "t_orig_colors", Termcap::t_orig_colors },
{ "t_no_color_video", Termcap::t_no_color_video },
{ "t_cursor_address", Termcap::t_cursor_address },
{ "t_column_address", Termcap::t_column_address },
{ "t_row_address", Termcap::t_row_address },
{ "t_cursor_visible", Termcap::t_cursor_visible },
{ "t_cursor_invisible", Termcap::t_cursor_invisible },
{ "t_cursor_normal", Termcap::t_cursor_normal },
{ "t_cursor_up", Termcap::t_cursor_up },
{ "t_cursor_down", Termcap::t_cursor_down },
{ "t_cursor_left", Termcap::t_cursor_left },
{ "t_cursor_right", Termcap::t_cursor_right },
{ "t_parm_up_cursor", Termcap::t_parm_up_cursor },
{ "t_parm_down_cursor", Termcap::t_parm_down_cursor },
{ "t_parm_left_cursor", Termcap::t_parm_left_cursor },
{ "t_parm_right_cursor", Termcap::t_parm_right_cursor },
{ "t_save_cursor", Termcap::t_save_cursor },
{ "t_restore_cursor", Termcap::t_restore_cursor },
{ "t_cursor_style", Termcap::t_cursor_style },
{ "t_scroll_forward", Termcap::t_scroll_forward },
{ "t_scroll_reverse", Termcap::t_scroll_reverse },
{ "t_enter_ca_mode", Termcap::t_enter_ca_mode },
{ "t_exit_ca_mode", Termcap::t_exit_ca_mode },
{ "t_enable_acs", Termcap::t_enable_acs },
{ "t_enter_bold_mode", Termcap::t_enter_bold_mode },
{ "t_exit_bold_mode", Termcap::t_exit_bold_mode },
{ "t_enter_dim_mode", Termcap::t_enter_dim_mode },
{ "t_exit_dim_mode", Termcap::t_exit_dim_mode },
{ "t_enter_italics_mode", Termcap::t_enter_italics_mode },
{ "t_exit_italics_mode", Termcap::t_exit_italics_mode },
{ "t_enter_underline_mode", Termcap::t_enter_underline_mode },
{ "t_exit_underline_mode", Termcap::t_exit_underline_mode },
{ "t_enter_blink_mode", Termcap::t_enter_blink_mode },
{ "t_exit_blink_mode", Termcap::t_exit_blink_mode },
{ "t_enter_reverse_mode", Termcap::t_enter_reverse_mode },
{ "t_exit_reverse_mode", Termcap::t_exit_reverse_mode },
{ "t_enter_standout_mode", Termcap::t_enter_standout_mode },
{ "t_exit_standout_mode", Termcap::t_exit_standout_mode },
{ "t_enter_secure_mode", Termcap::t_enter_secure_mode },
{ "t_exit_secure_mode", Termcap::t_exit_secure_mode },
{ "t_enter_protected_mode", Termcap::t_enter_protected_mode },
{ "t_exit_protected_mode", Termcap::t_exit_protected_mode },
{ "t_enter_crossed_out_mode", Termcap::t_enter_crossed_out_mode },
{ "t_exit_crossed_out_mode", Termcap::t_exit_crossed_out_mode },
{ "t_enter_dbl_underline_mode", Termcap::t_enter_dbl_underline_mode },
{ "t_exit_dbl_underline_mode", Termcap::t_exit_dbl_underline_mode },
{ "t_set_attributes", Termcap::t_set_attributes },
{ "t_exit_attribute_mode", Termcap::t_exit_attribute_mode },
{ "t_enter_alt_charset_mode", Termcap::t_enter_alt_charset_mode },
{ "t_exit_alt_charset_mode", Termcap::t_exit_alt_charset_mode },
{ "t_enter_pc_charset_mode", Termcap::t_enter_pc_charset_mode },
{ "t_exit_pc_charset_mode", Termcap::t_exit_pc_charset_mode },
{ "t_enter_insert_mode", Termcap::t_enter_insert_mode },
{ "t_exit_insert_mode", Termcap::t_exit_insert_mode },
{ "t_enter_am_mode", Termcap::t_enter_am_mode },
{ "t_exit_am_mode", Termcap::t_exit_am_mode },
{ "t_acs_chars", Termcap::t_acs_chars },
{ "t_keypad_xmit", Termcap::t_keypad_xmit },
{ "t_keypad_local", Termcap::t_keypad_local },
{ "t_key_mouse", Termcap::t_key_mouse }
}};
@ -289,7 +290,7 @@ void string()
for (const auto& entry : Data::strings)
{
const std::string name = entry.name;
const fc::termcaps cap = entry.cap;
const auto cap = std::size_t(entry.cap);
tcapString (name, tcap_strings[cap].string);
}
}

View File

@ -54,8 +54,8 @@ Timer::Timer (finalcut::FWidget* parent)
delTimer (id);
addTimer (250); // 250-millisecond timer
getColorTheme()->term_fg = fc::Default;
getColorTheme()->term_bg = fc::Default;
getColorTheme()->term_fg = finalcut::FColor::Default;
getColorTheme()->term_bg = finalcut::FColor::Default;
}
//----------------------------------------------------------------------
@ -77,7 +77,7 @@ void Timer::onTimer (finalcut::FTimerEvent* ev)
if ( getPrintPos().getY() == int(getDesktopHeight()) )
is_last_line = true;
print() << finalcut::FColorPair {FColor(1 + timer_id)}
print() << finalcut::FColorPair {finalcut::FColor(1 + timer_id)}
<< "Timer event, id " << timer_id << '\n';
if ( is_last_line )
@ -104,12 +104,12 @@ int main (int argc, char* argv[])
// Force terminal initialization without calling show()
app.initTerminal();
app.setForegroundColor(fc::Default);
app.setBackgroundColor(fc::Default);
app.setForegroundColor(finalcut::FColor::Default);
app.setBackgroundColor(finalcut::FColor::Default);
// Create a timer object t
Timer t{&app};
t.addAccelerator('q');
t.addAccelerator(finalcut::FKey('q'));
// Set the timer object t as main widget
finalcut::FWidget::setMainWidget(&t);

View File

@ -24,6 +24,7 @@
namespace fc = finalcut::fc;
using finalcut::FColorPair;
using finalcut::FColor;
using finalcut::FPoint;
using finalcut::FSize;
using finalcut::FStyle;
@ -39,14 +40,14 @@ class Transparent final : public finalcut::FDialog
// Enumeration
enum class Type
{
transparent = 0,
shadow = 1,
inherit_background = 2
Transparent = 0,
Shadow = 1,
InheritBackground = 2
};
// Constructor
explicit Transparent ( finalcut::FWidget* = nullptr
, Type = Type::transparent );
, Type = Type::Transparent );
// Disable copy constructor
Transparent (const Transparent&) = delete;
@ -88,23 +89,23 @@ void Transparent::draw()
if ( finalcut::FTerm::isMonochron() )
setReverse(true);
if ( type == Type::shadow )
if ( type == Type::Shadow )
{
const auto& wc = getColorTheme();
print() << FColorPair {wc->shadow_bg, wc->shadow_fg}
<< FStyle {fc::ColorOverlay};
<< FStyle {finalcut::Style::ColorOverlay};
}
else if ( type == Type::inherit_background )
else if ( type == Type::InheritBackground )
{
if ( finalcut::FTerm::getMaxColor() > 8 )
print() << FColorPair {fc::Blue, fc::Black};
print() << FColorPair {FColor::Blue, FColor::Black};
else
print() << FColorPair {fc::Green, fc::Black};
print() << FColorPair {FColor::Green, FColor::Black};
print() << FStyle {fc::InheritBackground};
print() << FStyle {finalcut::Style::InheritBackground};
}
else
print() << FStyle {fc::Transparent};
print() << FStyle {finalcut::Style::Transparent};
const finalcut::FString line{getClientWidth(), '.'};
@ -115,7 +116,7 @@ void Transparent::draw()
<< line;
}
print() << FStyle{fc::Reset};
print() << FStyle{finalcut::Style::None};
}
//----------------------------------------------------------------------
@ -124,7 +125,7 @@ void Transparent::onKeyPress (finalcut::FKeyEvent* ev)
if ( ! ev )
return;
if ( ev->key() == 'q' && getParentWidget() )
if ( ev->key() == finalcut::FKey('q') && getParentWidget() )
{
getParentWidget()->close();
ev->accept();
@ -166,7 +167,7 @@ class MainWindow final : public finalcut::FDialog
if ( ! ev )
return;
if ( ev->key() == 'q' )
if ( ev->key() == finalcut::FKey('q') )
{
close();
ev->accept();
@ -198,12 +199,12 @@ MainWindow::MainWindow (finalcut::FWidget* parent)
transpwin->setGeometry (FPoint{6, 3}, FSize{29, 12});
transpwin->unsetTransparentShadow();
shadowwin = new Transparent(this, Transparent::Type::shadow);
shadowwin = new Transparent(this, Transparent::Type::Shadow);
shadowwin->setText("shadow");
shadowwin->setGeometry (FPoint{46, 11}, FSize{29, 12});
shadowwin->unsetTransparentShadow();
ibg = new Transparent(this, Transparent::Type::inherit_background);
ibg = new Transparent(this, Transparent::Type::InheritBackground);
ibg->setText("inherit background");
ibg->setGeometry (FPoint{42, 3}, FSize{29, 7});
ibg->unsetTransparentShadow();

View File

@ -219,13 +219,13 @@ Treeview::Treeview (finalcut::FWidget* parent)
listview.addColumn ("Density/km²");
// Set right alignment for the second and third column
listview.setColumnAlignment (2, fc::alignRight);
listview.setColumnAlignment (3, fc::alignRight);
listview.setColumnAlignment (2, finalcut::Align::Right);
listview.setColumnAlignment (3, finalcut::Align::Right);
// Set the type of sorting
listview.setColumnSortType (1, fc::by_name);
listview.setColumnSortType (2, fc::user_defined);
listview.setColumnSortType (3, fc::user_defined);
listview.setColumnSortType (1, finalcut::SortType::Name);
listview.setColumnSortType (2, finalcut::SortType::UserDefined);
listview.setColumnSortType (3, finalcut::SortType::UserDefined);
listview.setUserAscendingCompare(sortAscending);
listview.setUserDescendingCompare(sortDescending);

View File

@ -29,7 +29,8 @@
#include <final/final.h>
namespace fc = finalcut::fc;
using FKey = finalcut::FKey;
using finalcut::FColor;
using finalcut::FPoint;
using finalcut::FRect;
using finalcut::FSize;
@ -324,13 +325,13 @@ class MyDialog final : public finalcut::FDialog
finalcut::FMenuItem File2{"/etc/fstab", &Recent};
finalcut::FMenuItem File3{"/etc/passwd", &Recent};
// "Edit" menu items
finalcut::FMenuItem Undo{fc::Fckey_z, "Undo", &Edit};
finalcut::FMenuItem Redo{fc::Fckey_y, "Redo", &Edit};
finalcut::FMenuItem Undo{FKey::Ctrl_z, "Undo", &Edit};
finalcut::FMenuItem Redo{FKey::Ctrl_y, "Redo", &Edit};
finalcut::FMenuItem Line2{&Edit};
finalcut::FMenuItem Cut{fc::Fckey_x, "Cu&t", &Edit};
finalcut::FMenuItem Copy{fc::Fckey_c, "&Copy", &Edit};
finalcut::FMenuItem Paste{fc::Fckey_v, "&Paste", &Edit};
finalcut::FMenuItem Clear{fc::Fkey_dc, "C&lear", &Edit};
finalcut::FMenuItem Cut{FKey::Ctrl_x, "Cu&t", &Edit};
finalcut::FMenuItem Copy{FKey::Ctrl_c, "&Copy", &Edit};
finalcut::FMenuItem Paste{FKey::Ctrl_v, "&Paste", &Edit};
finalcut::FMenuItem Clear{FKey::Del_char, "C&lear", &Edit};
// "View" menu items
finalcut::FMenuItem Env{"&Terminal...", &View};
finalcut::FMenuItem Drive{"&Drive symbols...", &View};
@ -338,9 +339,9 @@ class MyDialog final : public finalcut::FDialog
finalcut::FCheckMenuItem Theme{"Dark &mode", &View};
// Statusbar
finalcut::FStatusBar Statusbar{this};
finalcut::FStatusKey key_F1{fc::Fkey_f1, "About", &Statusbar};
finalcut::FStatusKey key_F2{fc::Fkey_f2, "View", &Statusbar};
finalcut::FStatusKey key_F3{fc::Fkey_f3, "Quit", &Statusbar};
finalcut::FStatusKey key_F1{FKey::F1, "About", &Statusbar};
finalcut::FStatusKey key_F2{FKey::F2, "View", &Statusbar};
finalcut::FStatusKey key_F3{FKey::F3, "Quit", &Statusbar};
// Dialog widgets
finalcut::FButton MyButton1{this};
finalcut::FButton MyButton2{this};
@ -395,11 +396,11 @@ void MyDialog::initMenu()
Help.setStatusbarMessage ("Show version and copyright information");
// "File" menu items
Open.addAccelerator (fc::Fckey_o); // Ctrl + O
Open.addAccelerator (FKey::Ctrl_o); // Ctrl + O
Open.setStatusbarMessage ("Locate and open a text file");
Recent.setStatusbarMessage ("View text file");
Line1.setSeparator();
Quit.addAccelerator (fc::Fmkey_x); // Meta/Alt + X
Quit.addAccelerator (FKey::Meta_x); // Meta/Alt + X
Quit.setStatusbarMessage ("Exit the program");
// "Edit" menu items
@ -605,14 +606,14 @@ void MyDialog::initFlatButtons()
MyButton1.setStatusbarMessage ("Sine function");
MyButton1.setNoUnderline();
MyButton1.setFlat();
MyButton1.setDoubleFlatLine (fc::bottom);
MyButton1.setDoubleFlatLine (finalcut::Side::Bottom);
MyButton2.setGeometry(FPoint{3, 5}, FSize{5, 1});
MyButton2.setText (L"&COS");
MyButton2.setStatusbarMessage ("Cosine function");
MyButton2.setNoUnderline();
MyButton2.setFlat();
MyButton2.setDoubleFlatLine (fc::top);
MyButton2.setDoubleFlatLine (finalcut::Side::Top);
MyButton3.setGeometry(FPoint{10, 3}, FSize{5, 3});
MyButton3.setText (L"&=");
@ -687,7 +688,7 @@ void MyDialog::initButtons()
MyButton6.setGeometry(FPoint{20, 14}, FSize{12, 1});
MyButton6.setText (L"&Quit");
MyButton6.setStatusbarMessage ("Exit the program");
MyButton6.addAccelerator('x');
MyButton6.addAccelerator(FKey('x'));
// Add button callback functions
MyButton4.addCallback
@ -718,7 +719,7 @@ void MyDialog::initLabels()
// Text labels
headline.setGeometry(FPoint{21, 3}, FSize{10, 1});
headline.setEmphasis();
headline.setAlignment (fc::alignCenter);
headline.setAlignment (finalcut::Align::Center);
headline = L"List items";
tagged.setGeometry(FPoint{21, 4}, FSize{7, 1});
@ -727,7 +728,7 @@ void MyDialog::initLabels()
tagged_count << 0;
sum.setGeometry(FPoint{21, 5}, FSize{7, 3});
sum.setAlignment (fc::alignRight);
sum.setAlignment (finalcut::Align::Right);
sum_count.setGeometry(FPoint{29, 5}, FSize{5, 3});
sum_count << myList.getCount();
@ -769,7 +770,11 @@ void MyDialog::initWidgetsCallbacks()
//----------------------------------------------------------------------
void MyDialog::adjustSize()
{
const auto h = getDesktopHeight() - 4;
auto h = getDesktopHeight();
if ( h > 4 )
h -= 4;
setHeight (h, false);
finalcut::FDialog::adjustSize(); // with new client area size
auto x = int((getDesktopWidth() - getWidth()) / 2);
@ -779,7 +784,7 @@ void MyDialog::adjustSize()
setPos (FPoint{x, 2}, false);
if ( initialized )
if ( initialized && h > 3 )
myList.setHeight (h - 3, true);
}
@ -803,7 +808,7 @@ void MyDialog::cb_noFunctionMsg (const finalcut::FButton& button)
void MyDialog::cb_about()
{
constexpr char libver[] = F_VERSION;
const finalcut::FString line(2, fc::BoxDrawingsHorizontal);
const finalcut::FString line(2, finalcut::UniChar::BoxDrawingsHorizontal);
finalcut::FMessageBox info ( "About"
, line + L" FINAL CUT " + line + L"\n\n"
@ -829,7 +834,7 @@ void MyDialog::cb_terminfo()
<< " Type: " << finalcut::FTerm::getTermType() << "\n"
<< " Name: " << finalcut::FTerm::getTermFileName() << "\n"
<< " Mode: " << finalcut::FTerm::getEncodingString() << "\n"
<< " Size: " << x << fc::Times
<< " Size: " << x << finalcut::UniChar::Times
<< y << "\n"
<< "Colors: " << finalcut::FTerm::getMaxColor()
, finalcut::FMessageBox::ButtonType::Ok
@ -883,12 +888,12 @@ void MyDialog::cb_drives()
}
else
{
net.setForegroundColor (fc::White);
net.setBackgroundColor (fc::DarkGray);
drive.setForegroundColor (fc::White);
drive.setBackgroundColor (fc::DarkGray);
cd.setForegroundColor (fc::White);
cd.setBackgroundColor (fc::DarkGray);
net.setForegroundColor (FColor::White);
net.setBackgroundColor (FColor::DarkGray);
drive.setForegroundColor (FColor::White);
drive.setBackgroundColor (FColor::DarkGray);
cd.setForegroundColor (FColor::White);
cd.setBackgroundColor (FColor::DarkGray);
}
info2.exec();

View File

@ -71,8 +71,8 @@ SmallWindow::SmallWindow (finalcut::FWidget* parent)
: finalcut::FDialog{parent}
{
const auto& wc = getColorTheme();
const wchar_t arrow_up = fc::BlackUpPointingTriangle;
const wchar_t arrow_down = fc::BlackDownPointingTriangle;
const auto arrow_up = finalcut::UniChar::BlackUpPointingTriangle;
const auto arrow_down = finalcut::UniChar::BlackDownPointingTriangle;
left_arrow = arrow_up;
left_arrow.setForegroundColor (wc->label_inactive_fg);
@ -92,7 +92,7 @@ SmallWindow::SmallWindow (finalcut::FWidget* parent)
top_left_label.setGeometry (FPoint{1, 1}, FSize{6, 1});
top_right_label.setText("zoom");
top_right_label.setAlignment (fc::alignRight);
top_right_label.setAlignment (finalcut::Align::Right);
top_right_label.setForegroundColor (wc->label_inactive_fg);
top_right_label.setEmphasis();
top_right_label.setGeometry (FPoint{int(getClientWidth()) - 5, 1}, FSize{6, 1});
@ -101,7 +101,7 @@ SmallWindow::SmallWindow (finalcut::FWidget* parent)
"corner\n" };
bottom_label_text += arrow_down;
bottom_label = bottom_label_text;
bottom_label.setAlignment (fc::alignRight);
bottom_label.setAlignment (finalcut::Align::Right);
bottom_label.setForegroundColor (wc->label_inactive_fg);
bottom_label.setEmphasis();
bottom_label.setGeometry (FPoint{13, 3}, FSize{6, 3});
@ -223,7 +223,7 @@ class Window final : public finalcut::FDialog
// Data members
std::vector<WinData> windows{};
finalcut::FString drop_down_symbol{fc::BlackDownPointingTriangle};
finalcut::FString drop_down_symbol{finalcut::UniChar::BlackDownPointingTriangle};
finalcut::FMenuBar Menubar{this};
finalcut::FMenu File{"&File", &Menubar};
finalcut::FDialogListMenu DglList{drop_down_symbol, &Menubar};
@ -295,12 +295,12 @@ void Window::configureFileMenuItems()
New.setStatusbarMessage ("Create the windows");
Close.setStatusbarMessage ("Close the windows");
Line1.setSeparator();
Next.addAccelerator (fc::Fmkey_npage); // Meta/Alt + PgDn
Next.addAccelerator (finalcut::FKey::Meta_page_down); // Meta/Alt + PgDn
Next.setStatusbarMessage ("Switch to the next window");
Previous.addAccelerator (fc::Fmkey_ppage); // Meta/Alt + PgUp
Previous.addAccelerator (finalcut::FKey::Meta_page_up); // Meta/Alt + PgUp
Previous.setStatusbarMessage ("Switch to the previous window");
Line2.setSeparator();
Quit.addAccelerator (fc::Fmkey_x); // Meta/Alt + X
Quit.addAccelerator (finalcut::FKey::Meta_x); // Meta/Alt + X
Quit.setStatusbarMessage ("Exit the program");
// Add menu item callback

View File

@ -443,13 +443,13 @@ void FApplication::setTerminalEncoding (const FString& enc_str)
const FString& enc = enc_str.toLower();
if ( enc.includes("utf8") )
getStartOptions().encoding = fc::UTF8;
getStartOptions().encoding = Encoding::UTF8;
else if ( enc.includes("vt100") )
getStartOptions().encoding = fc::VT100;
getStartOptions().encoding = Encoding::VT100;
else if ( enc.includes("pc") )
getStartOptions().encoding = fc::PC;
getStartOptions().encoding = Encoding::PC;
else if ( enc.includes("ascii") )
getStartOptions().encoding = fc::ASCII;
getStartOptions().encoding = Encoding::ASCII;
else if ( enc.includes("help") )
showParameterUsage();
else
@ -694,7 +694,7 @@ inline void FApplication::performKeyboardAction()
{
const auto& keyboard = FTerm::getFKeyboard();
if ( keyboard->getKey() == fc::Fckey_l ) // Ctrl-L (redraw the screen)
if ( keyboard->getKey() == FKey::Ctrl_l ) // Ctrl-L (redraw the screen)
{
redraw();
}
@ -713,24 +713,20 @@ inline void FApplication::performMouseAction() const
{
const auto& mouse = FTerm::getFMouseControl();
const auto& keyboard = FTerm::getFKeyboard();
const auto key = keyboard->getKey();
auto& buffer = keyboard->getKeyBuffer();
switch ( keyboard->getKey() )
if ( key == FKey::X11mouse )
{
case fc::Fkey_mouse:
mouse->setRawData (FMouse::MouseType::x11, buffer);
break;
case fc::Fkey_extended_mouse:
mouse->setRawData (FMouse::MouseType::sgr, buffer);
break;
case fc::Fkey_urxvt_mouse:
mouse->setRawData (FMouse::MouseType::urxvt, buffer);
break;
default:
return;
mouse->setRawData (FMouse::MouseType::X11, buffer);
}
else if ( key == FKey::Extended_mouse )
{
mouse->setRawData (FMouse::MouseType::Sgr, buffer);
}
else if ( key == FKey::Urxvt_mouse )
{
mouse->setRawData (FMouse::MouseType::Urxvt, buffer);
}
keyboard->hasUnprocessedInput() = mouse->hasUnprocessedInput();
@ -755,7 +751,7 @@ void FApplication::mouseEvent (const FMouseData& md)
inline void FApplication::sendEscapeKeyPressEvent() const
{
// Send an escape key press event
FKeyEvent k_press_ev (fc::KeyPress_Event, fc::Fkey_escape);
FKeyEvent k_press_ev (Event::KeyPress, FKey::Escape);
sendEvent (keyboard_widget, &k_press_ev);
}
@ -764,7 +760,7 @@ inline bool FApplication::sendKeyDownEvent (FWidget* widget) const
{
// Send key down event
const auto& keyboard = FTerm::getFKeyboard();
FKeyEvent k_down_ev (fc::KeyDown_Event, keyboard->getKey());
FKeyEvent k_down_ev (Event::KeyDown, keyboard->getKey());
sendEvent (widget, &k_down_ev);
return k_down_ev.isAccepted();
}
@ -774,7 +770,7 @@ inline bool FApplication::sendKeyPressEvent (FWidget* widget) const
{
// Send key press event
const auto& keyboard = FTerm::getFKeyboard();
FKeyEvent k_press_ev (fc::KeyPress_Event, keyboard->getKey());
FKeyEvent k_press_ev (Event::KeyPress, keyboard->getKey());
sendEvent (widget, &k_press_ev);
return k_press_ev.isAccepted();
}
@ -784,7 +780,7 @@ inline bool FApplication::sendKeyUpEvent (FWidget* widget) const
{
// Send key up event
const auto& keyboard = FTerm::getFKeyboard();
FKeyEvent k_up_ev (fc::KeyUp_Event, keyboard->getKey());
FKeyEvent k_up_ev (Event::KeyUp, keyboard->getKey());
sendEvent (widget, &k_up_ev);
return k_up_ev.isAccepted();
}
@ -885,11 +881,11 @@ bool FApplication::processDialogSwitchAccelerator() const
{
const auto& keyboard = FTerm::getFKeyboard();
if ( keyboard->getKey() >= fc::Fmkey_1
&& keyboard->getKey() <= fc::Fmkey_9 )
if ( keyboard->getKey() >= FKey::Meta_1
&& keyboard->getKey() <= FKey::Meta_9 )
{
const FKey key = keyboard->getKey();
const std::size_t n = key - fc::Fmkey_0;
const auto n = std::size_t(key - FKey::Meta_0);
const std::size_t s = getDialogList()->size();
if ( s > 0 && s >= n )
@ -904,7 +900,7 @@ bool FApplication::processDialogSwitchAccelerator() const
w->redraw();
}
FAccelEvent a_ev (fc::Accelerator_Event, getFocusWidget());
FAccelEvent a_ev (Event::Accelerator, getFocusWidget());
sendEvent (getDialogList()->at(n - 1), &a_ev);
return true;
}
@ -932,7 +928,7 @@ bool FApplication::processAccelerator (const FWidget& widget) const
move_size->redraw();
}
FAccelEvent a_ev (fc::Accelerator_Event, getFocusWidget());
FAccelEvent a_ev (Event::Accelerator, getFocusWidget());
sendEvent (item.object, &a_ev);
return a_ev.isAccepted();
}
@ -1038,16 +1034,16 @@ void FApplication::unselectMenubarItems (const FMouseData& md) const
void FApplication::sendMouseEvent (const FMouseData& md) const
{
const auto& mouse_position = md.getPos();
int key_state{0};
MouseButton key_state{MouseButton::None};
if ( md.isShiftKeyPressed() )
key_state |= fc::ShiftButton;
key_state |= MouseButton::Shift;
if ( md.isControlKeyPressed() )
key_state |= fc::ControlButton;
key_state |= MouseButton::Control;
if ( md.isMetaKeyPressed() )
key_state |= fc::MetaButton;
key_state |= MouseButton::Meta;
const auto& widgetMousePos = clicked_widget->termToWidgetPos(mouse_position);
@ -1069,32 +1065,32 @@ void FApplication::sendMouseEvent (const FMouseData& md) const
void FApplication::sendMouseMoveEvent ( const FMouseData& md
, const FPoint& widgetMousePos
, const FPoint& mouse_position
, int key_state ) const
, MouseButton key_state ) const
{
if ( md.isLeftButtonPressed() )
{
FMouseEvent m_down_ev ( fc::MouseMove_Event
FMouseEvent m_down_ev ( Event::MouseMove
, widgetMousePos
, mouse_position
, fc::LeftButton | key_state );
, MouseButton::Left | key_state );
sendEvent (clicked_widget, &m_down_ev);
}
if ( md.isRightButtonPressed() )
{
FMouseEvent m_down_ev ( fc::MouseMove_Event
FMouseEvent m_down_ev ( Event::MouseMove
, widgetMousePos
, mouse_position
, fc::RightButton | key_state );
, MouseButton::Right | key_state );
sendEvent (clicked_widget, &m_down_ev);
}
if ( md.isMiddleButtonPressed() )
{
FMouseEvent m_down_ev ( fc::MouseMove_Event
FMouseEvent m_down_ev ( Event::MouseMove
, widgetMousePos
, mouse_position
, fc::MiddleButton | key_state );
, MouseButton::Middle | key_state );
sendEvent (clicked_widget, &m_down_ev);
}
}
@ -1103,30 +1099,30 @@ void FApplication::sendMouseMoveEvent ( const FMouseData& md
void FApplication::sendMouseLeftClickEvent ( const FMouseData& md
, const FPoint& widgetMousePos
, const FPoint& mouse_position
, int key_state ) const
, MouseButton key_state ) const
{
if ( md.isLeftButtonDoubleClick() )
{
FMouseEvent m_dblclick_ev ( fc::MouseDoubleClick_Event
FMouseEvent m_dblclick_ev ( Event::MouseDoubleClick
, widgetMousePos
, mouse_position
, fc::LeftButton | key_state );
, MouseButton::Left | key_state );
sendEvent (clicked_widget, &m_dblclick_ev);
}
else if ( md.isLeftButtonPressed() )
{
FMouseEvent m_down_ev ( fc::MouseDown_Event
FMouseEvent m_down_ev ( Event::MouseDown
, widgetMousePos
, mouse_position
, fc::LeftButton | key_state );
, MouseButton::Left | key_state );
sendEvent (clicked_widget, &m_down_ev);
}
else if ( md.isLeftButtonReleased() )
{
FMouseEvent m_up_ev ( fc::MouseUp_Event
FMouseEvent m_up_ev ( Event::MouseUp
, widgetMousePos
, mouse_position
, fc::LeftButton | key_state );
, MouseButton::Left | key_state );
auto released_widget = clicked_widget;
if ( ! md.isRightButtonPressed()
@ -1141,22 +1137,22 @@ void FApplication::sendMouseLeftClickEvent ( const FMouseData& md
void FApplication::sendMouseRightClickEvent ( const FMouseData& md
, const FPoint& widgetMousePos
, const FPoint& mouse_position
, int key_state ) const
, MouseButton key_state ) const
{
if ( md.isRightButtonPressed() )
{
FMouseEvent m_down_ev ( fc::MouseDown_Event
FMouseEvent m_down_ev ( Event::MouseDown
, widgetMousePos
, mouse_position
, fc::RightButton | key_state );
, MouseButton::Right | key_state );
sendEvent (clicked_widget, &m_down_ev);
}
else if ( md.isRightButtonReleased() )
{
FMouseEvent m_up_ev ( fc::MouseUp_Event
FMouseEvent m_up_ev ( Event::MouseUp
, widgetMousePos
, mouse_position
, fc::RightButton | key_state );
, MouseButton::Right | key_state );
auto released_widget = clicked_widget;
if ( ! md.isLeftButtonPressed()
@ -1171,14 +1167,14 @@ void FApplication::sendMouseRightClickEvent ( const FMouseData& md
void FApplication::sendMouseMiddleClickEvent ( const FMouseData& md
, const FPoint& widgetMousePos
, const FPoint& mouse_position
, int key_state ) const
, MouseButton key_state ) const
{
if ( md.isMiddleButtonPressed() )
{
FMouseEvent m_down_ev ( fc::MouseDown_Event
FMouseEvent m_down_ev ( Event::MouseDown
, widgetMousePos
, mouse_position
, fc::MiddleButton | key_state );
, MouseButton::Middle | key_state );
sendEvent (clicked_widget, &m_down_ev);
// gnome-terminal sends no released on middle click
@ -1187,10 +1183,10 @@ void FApplication::sendMouseMiddleClickEvent ( const FMouseData& md
}
else if ( md.isMiddleButtonReleased() )
{
FMouseEvent m_up_ev ( fc::MouseUp_Event
FMouseEvent m_up_ev ( Event::MouseUp
, widgetMousePos
, mouse_position
, fc::MiddleButton | key_state );
, MouseButton::Middle | key_state );
auto released_widget = clicked_widget;
if ( ! md.isLeftButtonPressed()
@ -1210,10 +1206,10 @@ void FApplication::sendWheelEvent ( const FMouseData& md
{
if ( md.isWheelUp() )
{
FWheelEvent wheel_ev ( fc::MouseWheel_Event
FWheelEvent wheel_ev ( Event::MouseWheel
, widgetMousePos
, mouse_position
, fc::WheelUp );
, MouseWheel::Up );
auto scroll_over_widget = clicked_widget;
setClickedWidget(nullptr);
sendEvent(scroll_over_widget, &wheel_ev);
@ -1221,10 +1217,10 @@ void FApplication::sendWheelEvent ( const FMouseData& md
if ( md.isWheelDown() )
{
FWheelEvent wheel_ev ( fc::MouseWheel_Event
FWheelEvent wheel_ev ( Event::MouseWheel
, widgetMousePos
, mouse_position
, fc::WheelDown );
, MouseWheel::Down );
auto scroll_over_widget = clicked_widget;
setClickedWidget(nullptr);
sendEvent (scroll_over_widget, &wheel_ev);
@ -1254,7 +1250,7 @@ void FApplication::processResizeEvent() const
const auto& mouse = FTerm::getFMouseControl();
mouse->setMaxWidth (uInt16(getDesktopWidth()));
mouse->setMaxHeight (uInt16(getDesktopHeight()));
FResizeEvent r_ev(fc::Resize_Event);
FResizeEvent r_ev(Event::Resize);
sendEvent(internal::var::app_object, &r_ev);
if ( r_ev.isAccepted() )
@ -1353,32 +1349,38 @@ bool FApplication::isEventProcessable ( FObject* receiver
&& ! window->getFlags().modal
&& ! window->isMenuWidget() )
{
switch ( uInt(event->getType()) )
{
case fc::KeyPress_Event:
case fc::KeyUp_Event:
case fc::KeyDown_Event:
case fc::MouseDown_Event:
case fc::MouseUp_Event:
case fc::MouseDoubleClick_Event:
case fc::MouseWheel_Event:
case fc::MouseMove_Event:
case fc::FocusIn_Event:
case fc::FocusOut_Event:
case fc::ChildFocusIn_Event:
case fc::ChildFocusOut_Event:
case fc::Accelerator_Event:
return false;
constexpr std::array<const Event, 13> blocked_events
{{
Event::KeyPress,
Event::KeyUp,
Event::KeyDown,
Event::MouseDown,
Event::MouseUp,
Event::MouseDoubleClick,
Event::MouseWheel,
Event::MouseMove,
Event::FocusIn,
Event::FocusOut,
Event::ChildFocusIn,
Event::ChildFocusOut,
Event::Accelerator
}};
default:
break;
if ( std::any_of( blocked_events.cbegin()
, blocked_events.cend()
, [&event](const Event& ev)
{
return ev == event->getType();
} ) )
{
return false;
}
}
}
// Throw away mouse events for disabled widgets
if ( event->getType() >= fc::MouseDown_Event
&& event->getType() <= fc::MouseMove_Event
if ( event->getType() >= Event::MouseDown
&& event->getType() <= Event::MouseMove
&& ! widget->isEnabled() )
return false;

View File

@ -73,7 +73,7 @@ void FBusyIndicator::createIndicatorText()
{
std::array<FString, 4> line{};
if ( FTerm::getEncoding() == fc::UTF8 )
if ( FTerm::getEncoding() == Encoding::UTF8 )
{
const auto& p = uni_pattern;
line[0] << " " << p[7] << " " << p[0] << " \n";
@ -98,7 +98,7 @@ void FBusyIndicator::createIndicatorText()
void FBusyIndicator::onTimer (finalcut::FTimerEvent*)
{
// Rotate pattern
if ( FTerm::getEncoding() == fc::UTF8 )
if ( FTerm::getEncoding() == Encoding::UTF8 )
{
const wchar_t last = uni_pattern[7];
std::memmove(uni_pattern + 1, uni_pattern , sizeof(wchar_t) * 7);

View File

@ -83,7 +83,7 @@ void FButton::setBackgroundColor (FColor color)
void FButton::setHotkeyForegroundColor (FColor color)
{
// valid colors -1..254
if ( color == fc::Default || color >> 8 == 0 )
if ( color == FColor::Default || (color >> 8) == FColor::Black )
button_hotkey_fg = color;
}
@ -91,7 +91,7 @@ void FButton::setHotkeyForegroundColor (FColor color)
void FButton::setFocusForegroundColor (FColor color)
{
// valid colors -1..254
if ( color == fc::Default || color >> 8 == 0 )
if ( color == FColor::Default || (color >> 8) == FColor::Black )
button_focus_fg = color;
updateButtonColor();
@ -101,7 +101,7 @@ void FButton::setFocusForegroundColor (FColor color)
void FButton::setFocusBackgroundColor (FColor color)
{
// valid colors -1..254
if ( color == fc::Default || color >> 8 == 0 )
if ( color == FColor::Default || (color >> 8) == FColor::Black )
button_focus_bg = color;
updateButtonColor();
@ -111,7 +111,7 @@ void FButton::setFocusBackgroundColor (FColor color)
void FButton::setInactiveForegroundColor (FColor color)
{
// valid colors -1..254
if ( color == fc::Default || color >> 8 == 0 )
if ( color == FColor::Default || (color >> 8) == FColor::Black )
button_inactive_fg = color;
updateButtonColor();
@ -121,7 +121,7 @@ void FButton::setInactiveForegroundColor (FColor color)
void FButton::setInactiveBackgroundColor (FColor color)
{
// valid colors -1..254
if ( color == fc::Default || color >> 8 == 0 )
if ( color == FColor::Default || (color >> 8) == FColor::Black )
button_inactive_bg = color;
updateButtonColor();
@ -179,8 +179,8 @@ bool FButton::setFlat (bool enable)
bool FButton::setShadow (bool enable)
{
if ( enable
&& FTerm::getEncoding() != fc::VT100
&& FTerm::getEncoding() != fc::ASCII )
&& FTerm::getEncoding() != Encoding::VT100
&& FTerm::getEncoding() != Encoding::ASCII )
{
setFlags().shadow = true;
setShadowSize(FSize{1, 1});
@ -260,29 +260,25 @@ void FButton::onKeyPress (FKeyEvent* ev)
const FKey key = ev->key();
switch ( key )
if ( key == FKey::Return
|| key == FKey::Enter
|| key == FKey::Space )
{
case fc::Fkey_return:
case fc::Fkey_enter:
case fc::Fkey_space:
if ( click_animation )
{
setDown();
addTimer(click_time);
}
processClick();
ev->accept();
break;
if ( click_animation )
{
setDown();
addTimer(click_time);
}
default:
break;
processClick();
ev->accept();
}
}
//----------------------------------------------------------------------
void FButton::onMouseDown (FMouseEvent* ev)
{
if ( ev->getButton() != fc::LeftButton )
if ( ev->getButton() != MouseButton::Left )
{
setUp();
return;
@ -309,7 +305,7 @@ void FButton::onMouseDown (FMouseEvent* ev)
//----------------------------------------------------------------------
void FButton::onMouseUp (FMouseEvent* ev)
{
if ( ev->getButton() != fc::LeftButton )
if ( ev->getButton() != MouseButton::Left )
return;
if ( button_down )
@ -324,7 +320,7 @@ void FButton::onMouseUp (FMouseEvent* ev)
//----------------------------------------------------------------------
void FButton::onMouseMove (FMouseEvent* ev)
{
if ( ev->getButton() != fc::LeftButton )
if ( ev->getButton() != MouseButton::Left )
return;
const FPoint tPos{ev->getTermPos()};
@ -486,7 +482,7 @@ inline void FButton::drawMarginLeft()
print() << FPoint{1 + int(indent), 1 + int(y)};
if ( FTerm::isMonochron() && active_focus && y == vcenter_offset )
print (fc::BlackRightPointingPointer); // ►
print (UniChar::BlackRightPointingPointer); // ►
else
print (space_char); // full block █
}
@ -502,7 +498,7 @@ inline void FButton::drawMarginRight()
print() << FPoint{int(getWidth() + indent), 1 + int(y)};
if ( FTerm::isMonochron() && active_focus && y == vcenter_offset )
print (fc::BlackLeftPointingPointer); // ◄
print (UniChar::BlackLeftPointingPointer); // ◄
else
print (space_char); // full block █
}
@ -616,7 +612,7 @@ void FButton::draw()
FString button_text{};
const auto& parent_widget = getParentWidget();
column_width = getColumnWidth(text);
space_char = int(' ');
space_char = L' ';
active_focus = getFlags().active && getFlags().focus;
if ( FTerm::isMonochron() )
@ -629,7 +625,7 @@ void FButton::draw()
clearRightMargin (parent_widget);
if ( ! getFlags().active && FTerm::isMonochron() )
space_char = fc::MediumShade; // ▒ simulates greyed out at Monochron
space_char = wchar_t(UniChar::MediumShade); // ▒ simulates greyed out at Monochron
if ( FTerm::isMonochron() && (getFlags().active || getFlags().focus) )
setReverse(false); // Dark background

View File

@ -293,7 +293,7 @@ void FButtonGroup::checkScrollSize (const FRect& r)
//----------------------------------------------------------------------
void FButtonGroup::onMouseDown (FMouseEvent* ev)
{
if ( ev->getButton() != fc::LeftButton )
if ( ev->getButton() != MouseButton::Left )
return;
directFocus();
@ -316,9 +316,9 @@ void FButtonGroup::onFocusIn (FFocusEvent* in_ev)
in_ev->accept();
auto prev_element = getFocusWidget();
if ( in_ev->getFocusType() == fc::FocusNextWidget )
if ( in_ev->getFocusType() == FocusTypes::NextWidget )
focusFirstChild();
else if ( in_ev->getFocusType() == fc::FocusPreviousWidget )
else if ( in_ev->getFocusType() == FocusTypes::PreviousWidget )
focusLastChild();
if ( prev_element )
@ -516,10 +516,10 @@ void FButtonGroup::focusCheckedRadioButton ( FToggleButton* toggle_button
toggle_button->setFocus();
FFocusEvent cfi (fc::ChildFocusIn_Event);
FFocusEvent cfi (Event::ChildFocusIn);
FApplication::sendEvent(this, &cfi);
FFocusEvent in (fc::FocusIn_Event);
FFocusEvent in (Event::FocusIn);
FApplication::sendEvent(toggle_button, &in);
if ( in.isAccepted() )

View File

@ -32,128 +32,128 @@ namespace finalcut
namespace fc
{
std::array<std::array<uInt, fc::NUM_OF_ENCODINGS>, 115> character =
std::array<CharEncodeMap, 115> character =
{{
// .--------------------- Unicode (UTF-8)
// | .--------------- VT100
// | | .--------- PC (IBM-437)
// | | | .---- ASCII (7-Bit)
// | | | |
{{0x20ac, 0, 0xee, 'E'}}, // € - Euro
{{0x00a3, '}', 0x9c, 'P'}}, // £ - Pound
{{0x00a7, '$', 0x15, '$'}}, // § - Section
{{0x25d8, '*', 0x08, '*'}}, // ◘ - InverseBullet
{{0x25d9, '*', 0x0a, '*'}}, // ◙ - InverseWhiteCircle
{{0x203c, '!', 0x13, '!'}}, // ‼ - DoubleExclamationMark
{{0x2195, 'I', 0x12, 'I'}}, // ↕ - UpDownArrow
{{0x2194, '-', 0x1d, '-'}}, // ↔ - LeftRightArrow
{{0x25ac, '_', 0x16, '_'}}, // ▬ - BlackRectangle
{{0x2191, '^', 0x18, '^'}}, // ↑ - UpwardsArrow
{{0x2193, 'v', 0x19, 'v'}}, // ↓ - DownwardsArrow
{{0x2192, '>', 0x1a, '>'}}, // → - RightwardsArrow
{{0x2190, '<', 0x1b, '<'}}, // ← - LeftwardsArrow
{{0x203a, '>', 0xaf, '>'}}, // - SingleRightAngleQuotationMark
{{0x2039, '<', 0xae, '<'}}, // - SingleLeftAngleQuotationMark
{{0x2026, '.', '.', '.'}}, // … - HorizontalEllipsis
{{0x03c0, '{', 0xe3, 'n'}}, // π - Pi
{{0x207F, 'I', 0xfc, ' '}}, // ⁿ - SuperscriptLatinSmallLetterN
{{0x2265, 'z', 0xf2, '>'}}, // ≥ - GreaterThanOrEqualTo
{{0x2264, 'y', 0xf3, '<'}}, // ≤ - LessThanOrEqualTo
{{0x2260, 0, 0xd8, '#'}}, // ≠ - NotEqualTo
{{0x00b1, 'g', 0xf1, '#'}}, // ± - PlusMinus
{{0x00f7, '/', 0xf6, '/'}}, // ÷ - Division sign
{{0x00d7, 0, 'x', 'x'}}, // × - Multiplication sign
{{0x02e3, '~', 0xfc, '`'}}, // ˣ - Modifier letter small x
{{0x00b0, 'f', 0xb0, 'o'}}, // ° - Degree
{{0x2022, '`', 0x04, '*'}}, // • - Bullet
{{0x00b7, '`', 0xfa, '.'}}, // · - small Bullet
{{0x25cf, '`', 0x04, '*'}}, // ● - BlackCircle
{{0x2666, '`', 0x04, '*'}}, // ◆ - BlackDiamondSuit
{{0x2424, 'h', ' ', ' '}}, // ␤ - SymbolForNewline (1)
{{0x240b, 'i', ' ', ' '}}, // ␋ - SymbolForVerticalTab (1)
{{0x2409, 'b', ' ', ' '}}, // ␉ - SymbolForHorizontalTab (1)
{{0x240c, 'c', ' ', ' '}}, // ␌ - SymbolForFormFeed (1)
{{0x240d, 'd', ' ', ' '}}, // ␍ - SymbolForCarriageReturn (1)
{{0x240a, 'e', ' ', ' '}}, // ␊ - SymbolForLineFeed (1)
{{0x2592, 'a', 0xb0, '#'}}, // ▒ - MediumShade
{{0x2588, '0', 0xdb, '#'}}, // █ - FullBlock
{{0x25ae, '_', 0xfe, '#'}}, // ▮ - BlackVerticalRectangle (1)
{{0x258c, 0, 0xdd, ' '}}, // ▌ - LeftHalfBlock
{{0x2590, 0, 0xde, ' '}}, // ▐ - RightHalfBlock
{{0x2584, 0, 0xdc, ' '}}, // ▄ - LowerHalfBlock
{{0x2580, 0, 0xdf, ' '}}, // ▀ - UpperHalfBlock
{{0x2500, 'q', 0xc4, '-'}}, // ─ - BoxDrawingsHorizontal
{{0x2502, 'x', 0xb3, '|'}}, // │ - BoxDrawingsVertical
{{0x250c, 'l', 0xda, '.'}}, // ┌ - BoxDrawingsDownAndRight
{{0x2510, 'k', 0xbf, '.'}}, // ┐ - BoxDrawingsDownAndLeft
{{0x2514, 'm', 0xc0, '`'}}, // └ - BoxDrawingsUpAndRight
{{0x2518, 'j', 0xd9, '\''}}, // ┘ - BoxDrawingsUpAndLeft
{{0x253c, 'n', 0xc5, '+'}}, // ┼ - BoxDrawingsCross
{{0x252c, 'w', 0xc2, '+'}}, // ┬ - BoxDrawingsDownAndHorizontal
{{0x2524, 'u', 0xb4, '+'}}, // ┤ - BoxDrawingsVerticalAndLeft
{{0x251c, 't', 0xc3, '+'}}, // ├ - BoxDrawingsVerticalAndRight
{{0x2534, 'v', 0xc1, '+'}}, // ┴ - BoxDrawingsUpAndHorizontal
{{0x23ba, 'o', '~', '~'}}, // ⎺ - HorizontalScanLine1 (1)
{{0x23bb, 'p', 0xc4, '-'}}, // ⎻ - HorizontalScanLine3 (1)
{{0x23bc, 'r', 0xc4, '-'}}, // ⎼ - HorizontalScanLine7 (1)
{{0x23bd, 's', '_', '_'}}, // ⎽ - HorizontalScanLine9 (1)
{{0x25b2, '-', 0x1e, '^'}}, // ▲ - BlackUpPointingTriangle
{{0x25bc, '.', 0x1f, 'v'}}, // ▼ - BlackDownPointingTriangle
{{0x25b6, '+', 0x10, '>'}}, // ▶ - BlackRightPointingTriangle
{{0x25c0, ',', 0x11, '<'}}, // ◀ - BlackLeftPointingTriangle (1)
{{0x25ba, '+', 0x10, '>'}}, // ► - BlackRightPointingPointer (1)
{{0x25c4, ',', 0x11, '<'}}, // ◄ - BlackLeftPointingPointer
{{0xe1b3, 'x', 0xb3, '|'}}, // │ - NF_border_line_vertical (2)
{{0xe1b4, 0, 0xb4, 0}}, // ⊐ - NF_rev_left_arrow2 (2)
{{0xe1b5, 0, 0xb5, 0}}, // ► - NF_rev_right_arrow2 (2)
{{0xe1b6, 0, 0xb6, 0}}, // ╵ - NF_border_line_left_up (2)
{{0xe1b7, 0, 0xb7, 0}}, // ) - NF_radio_button3 (2)
{{0xe1b8, 0, 0xb8, 0}}, // ⎤ - NF_rev_border_corner_upper_right (2)
{{0xe1b9, 0, 0xb9, 0}}, // ⎹ - NF_rev_border_line_right (2)
{{0xe1ba, 0, 0xba, 0}}, // ┤ - NF_rev_border_line_vertical_left (2)
{{0xe1bb, 0, 0xbb, 0}}, // ⎦ - NF_rev_border_corner_lower_right (2)
{{0xe1bc, 0, 0xbc, 0}}, // ⎸ - NF_border_line_left (2)
{{0xe1bd, 0, 0xbd, 0}}, //⎹◣ - NF_rev_up_arrow2 (2)
{{0xe1be, 0, 0xbe, 0}}, //⎹◤ - NF_rev_down_arrow2 (2)
{{0xe1bf, 0, 0xbf, 0}}, // ╷ - NF_border_line_left_down (2)
{{0xe1c0, 0, 0xc0, 0}}, // └ - NF_border_corner_middle_lower_left (2)
{{0xe1c1, 0, 0xc1, 0}}, // ◢⎸ - NF_rev_up_arrow1 (2)
{{0xe1c2, 0, 0xc2, 0}}, // ◥⎸ - NF_rev_down_arrow1 (2)
{{0xe1c3, 0, 0xc3, 0}}, // ├ - NF_border_line_vertical_right (2)
{{0xe1c4, 'q', 0xc4, '-'}}, // ─ - NF_border_line_horizontal (2)
{{0xe1c5, 0, 0xc5, 0}}, // = - NF_border_line_up_and_down (2)
{{0xe1c6, 0, 0xc6, 0}}, // = - NF_shadow_box_middle (2)
{{0xe1c7, 0, 0xc7, 0}}, // = - NF_shadow_box_hdd (2)
{{0xe1c8, 0, 0xc8, 0}}, // ◄ - NF_rev_left_arrow1 (2)
{{0xe1c9, 0, 0xc9, 0}}, // ⊏ - NF_rev_right_arrow1 (2)
{{0xe1ca, 0, 0xca, 0}}, // [ - NF_rev_menu_button1 (2)
{{0xe1cb, 0, 0xcb, 0}}, // - - NF_rev_menu_button2 (2)
{{0xe1cc, 0, 0xcc, 0}}, // ┌ - NF_border_corner_middle_upper_left (2)
{{0xe1cd, 0, 0xcd, 0}}, // = - NF_shadow_box_cd (2)
{{0xe1ce, 0, 0xce, 0}}, // [ - NF_shadow_box_left (2)
{{0xe1cf, 0, 0xcf, 0}}, // ┌ - NF_border_line_middle_left_down (2)
{{0xe1d0, 0, 0xd0, 0}}, // └ - NF_border_line_middle_right_up (2)
{{0xe1d1, 0, 0xd1, 0}}, // = - NF_shadow_box_net (2)
{{0xe1d2, 0, 0xd2, 0}}, // ◢ - NF_rev_up_pointing_triangle1 (2)
{{0xe1d3, 0, 0xd3, 0}}, // ⎣ - NF_border_corner_lower_left (2)
{{0xe1d4, 0, 0xd4, 0}}, // _ - NF_border_line_bottom (2)
{{0xe1d5, 0, 0xd5, 0}}, // O - NF_radio_button2 (2)
{{0xe1d6, 0, 0xd6, 0}}, // ● - NF_radio_button2_checked (2)
{{0xe1d7, 0, 0xd7, 0}}, // ◥ - NF_rev_down_pointing_triangle1 (2)
{{0xe1d8, 0, 0xd8, 0}}, // ¯ - NF_border_line_upper (2)
{{0xe1d9, 0, 0xd9, 0}}, // ( - NF_radio_button1 (2)
{{0xe1da, 0, 0xda, 0}}, // ⎡ - NF_border_corner_upper_left (2)
{{0xe1dc, 0, 0xdc, 0}}, // ✓ - NF_shadow_box_checked (2)
{{0xe1e7, 0, 0xe7, 0}}, // ║ - NF_rev_border_line_right_and_left (2)
{{0xe1e8, 0, 0xe8, 0}}, // ◣ - NF_rev_up_pointing_triangle2 (2)
{{0xe1e9, 0, 0xe9, 0}}, // ◤ - NF_rev_down_pointing_triangle2 (2)
{{0xe1ea, 0, 0xea, 0}}, // ┘ - NF_border_corner_middle_lower_right (2)
{{0xe1eb, 0, 0xeb, 0}}, // ┐ - NF_border_corner_middle_upper_right (2)
{{0xe1f4, 0, 0xf4, 0}}, // ] - NF_rev_menu_button3 (2)
{{0xe1f5, 0, 0xf5, 0}}, // ] - NF_shadow_box_right (2)
{{0xe1fb, 0, 0xfb, 0}}, // ✓ - NF_check_mark (2)
{{0xe1fc, '~', 0xfc, '`'}}, // ˣ - NF_xsuperior (2)
{{0x221a, 0, 0xfb, 'x'}} // √ - square root
{0x20ac, 0, 0xee, 'E'}, // € - Euro
{0x00a3, '}', 0x9c, 'P'}, // £ - Pound
{0x00a7, '$', 0x15, '$'}, // § - Section
{0x25d8, '*', 0x08, '*'}, // ◘ - InverseBullet
{0x25d9, '*', 0x0a, '*'}, // ◙ - InverseWhiteCircle
{0x203c, '!', 0x13, '!'}, // ‼ - DoubleExclamationMark
{0x2195, 'I', 0x12, 'I'}, // ↕ - UpDownArrow
{0x2194, '-', 0x1d, '-'}, // ↔ - LeftRightArrow
{0x25ac, '_', 0x16, '_'}, // ▬ - BlackRectangle
{0x2191, '^', 0x18, '^'}, // ↑ - UpwardsArrow
{0x2193, 'v', 0x19, 'v'}, // ↓ - DownwardsArrow
{0x2192, '>', 0x1a, '>'}, // → - RightwardsArrow
{0x2190, '<', 0x1b, '<'}, // ← - LeftwardsArrow
{0x203a, '>', 0xaf, '>'}, // - SingleRightAngleQuotationMark
{0x2039, '<', 0xae, '<'}, // - SingleLeftAngleQuotationMark
{0x2026, '.', '.', '.'}, // … - HorizontalEllipsis
{0x03c0, '{', 0xe3, 'n'}, // π - Pi
{0x207F, 'I', 0xfc, ' '}, // ⁿ - SuperscriptLatinSmallLetterN
{0x2265, 'z', 0xf2, '>'}, // ≥ - GreaterThanOrEqualTo
{0x2264, 'y', 0xf3, '<'}, // ≤ - LessThanOrEqualTo
{0x2260, 0, 0xd8, '#'}, // ≠ - NotEqualTo
{0x00b1, 'g', 0xf1, '#'}, // ± - PlusMinus
{0x00f7, '/', 0xf6, '/'}, // ÷ - Division sign
{0x00d7, 0, 'x', 'x'}, // × - Multiplication sign
{0x02e3, '~', 0xfc, '`'}, // ˣ - Modifier letter small x
{0x00b0, 'f', 0xb0, 'o'}, // ° - Degree
{0x2022, '`', 0x04, '*'}, // • - Bullet
{0x00b7, '`', 0xfa, '.'}, // · - small Bullet
{0x25cf, '`', 0x04, '*'}, // ● - BlackCircle
{0x2666, '`', 0x04, '*'}, // ◆ - BlackDiamondSuit
{0x2424, 'h', ' ', ' '}, // ␤ - SymbolForNewline (1)
{0x240b, 'i', ' ', ' '}, // ␋ - SymbolForVerticalTab (1)
{0x2409, 'b', ' ', ' '}, // ␉ - SymbolForHorizontalTab (1)
{0x240c, 'c', ' ', ' '}, // ␌ - SymbolForFormFeed (1)
{0x240d, 'd', ' ', ' '}, // ␍ - SymbolForCarriageReturn (1)
{0x240a, 'e', ' ', ' '}, // ␊ - SymbolForLineFeed (1)
{0x2592, 'a', 0xb0, '#'}, // ▒ - MediumShade
{0x2588, '0', 0xdb, '#'}, // █ - FullBlock
{0x25ae, '_', 0xfe, '#'}, // ▮ - BlackVerticalRectangle (1)
{0x258c, 0, 0xdd, ' '}, // ▌ - LeftHalfBlock
{0x2590, 0, 0xde, ' '}, // ▐ - RightHalfBlock
{0x2584, 0, 0xdc, ' '}, // ▄ - LowerHalfBlock
{0x2580, 0, 0xdf, ' '}, // ▀ - UpperHalfBlock
{0x2500, 'q', 0xc4, '-'}, // ─ - BoxDrawingsHorizontal
{0x2502, 'x', 0xb3, '|'}, // │ - BoxDrawingsVertical
{0x250c, 'l', 0xda, '.'}, // ┌ - BoxDrawingsDownAndRight
{0x2510, 'k', 0xbf, '.'}, // ┐ - BoxDrawingsDownAndLeft
{0x2514, 'm', 0xc0, '`'}, // └ - BoxDrawingsUpAndRight
{0x2518, 'j', 0xd9, '\''}, // ┘ - BoxDrawingsUpAndLeft
{0x253c, 'n', 0xc5, '+'}, // ┼ - BoxDrawingsCross
{0x252c, 'w', 0xc2, '+'}, // ┬ - BoxDrawingsDownAndHorizontal
{0x2524, 'u', 0xb4, '+'}, // ┤ - BoxDrawingsVerticalAndLeft
{0x251c, 't', 0xc3, '+'}, // ├ - BoxDrawingsVerticalAndRight
{0x2534, 'v', 0xc1, '+'}, // ┴ - BoxDrawingsUpAndHorizontal
{0x23ba, 'o', '~', '~'}, // ⎺ - HorizontalScanLine1 (1)
{0x23bb, 'p', 0xc4, '-'}, // ⎻ - HorizontalScanLine3 (1)
{0x23bc, 'r', 0xc4, '-'}, // ⎼ - HorizontalScanLine7 (1)
{0x23bd, 's', '_', '_'}, // ⎽ - HorizontalScanLine9 (1)
{0x25b2, '-', 0x1e, '^'}, // ▲ - BlackUpPointingTriangle
{0x25bc, '.', 0x1f, 'v'}, // ▼ - BlackDownPointingTriangle
{0x25b6, '+', 0x10, '>'}, // ▶ - BlackRightPointingTriangle
{0x25c0, ',', 0x11, '<'}, // ◀ - BlackLeftPointingTriangle (1)
{0x25ba, '+', 0x10, '>'}, // ► - BlackRightPointingPointer (1)
{0x25c4, ',', 0x11, '<'}, // ◄ - BlackLeftPointingPointer
{0xe1b3, 'x', 0xb3, '|'}, // │ - NF_border_line_vertical (2)
{0xe1b4, 0, 0xb4, 0}, // ⊐ - NF_rev_left_arrow2 (2)
{0xe1b5, 0, 0xb5, 0}, // ► - NF_rev_right_arrow2 (2)
{0xe1b6, 0, 0xb6, 0}, // ╵ - NF_border_line_left_up (2)
{0xe1b7, 0, 0xb7, 0}, // ) - NF_radio_button3 (2)
{0xe1b8, 0, 0xb8, 0}, // ⎤ - NF_rev_border_corner_upper_right (2)
{0xe1b9, 0, 0xb9, 0}, // ⎹ - NF_rev_border_line_right (2)
{0xe1ba, 0, 0xba, 0}, // ┤ - NF_rev_border_line_vertical_left (2)
{0xe1bb, 0, 0xbb, 0}, // ⎦ - NF_rev_border_corner_lower_right (2)
{0xe1bc, 0, 0xbc, 0}, // ⎸ - NF_border_line_left (2)
{0xe1bd, 0, 0xbd, 0}, //⎹◣ - NF_rev_up_arrow2 (2)
{0xe1be, 0, 0xbe, 0}, //⎹◤ - NF_rev_down_arrow2 (2)
{0xe1bf, 0, 0xbf, 0}, // ╷ - NF_border_line_left_down (2)
{0xe1c0, 0, 0xc0, 0}, // └ - NF_border_corner_middle_lower_left (2)
{0xe1c1, 0, 0xc1, 0}, // ◢⎸ - NF_rev_up_arrow1 (2)
{0xe1c2, 0, 0xc2, 0}, // ◥⎸ - NF_rev_down_arrow1 (2)
{0xe1c3, 0, 0xc3, 0}, // ├ - NF_border_line_vertical_right (2)
{0xe1c4, 'q', 0xc4, '-'}, // ─ - NF_border_line_horizontal (2)
{0xe1c5, 0, 0xc5, 0}, // = - NF_border_line_up_and_down (2)
{0xe1c6, 0, 0xc6, 0}, // = - NF_shadow_box_middle (2)
{0xe1c7, 0, 0xc7, 0}, // = - NF_shadow_box_hdd (2)
{0xe1c8, 0, 0xc8, 0}, // ◄ - NF_rev_left_arrow1 (2)
{0xe1c9, 0, 0xc9, 0}, // ⊏ - NF_rev_right_arrow1 (2)
{0xe1ca, 0, 0xca, 0}, // [ - NF_rev_menu_button1 (2)
{0xe1cb, 0, 0xcb, 0}, // - - NF_rev_menu_button2 (2)
{0xe1cc, 0, 0xcc, 0}, // ┌ - NF_border_corner_middle_upper_left (2)
{0xe1cd, 0, 0xcd, 0}, // = - NF_shadow_box_cd (2)
{0xe1ce, 0, 0xce, 0}, // [ - NF_shadow_box_left (2)
{0xe1cf, 0, 0xcf, 0}, // ┌ - NF_border_line_middle_left_down (2)
{0xe1d0, 0, 0xd0, 0}, // └ - NF_border_line_middle_right_up (2)
{0xe1d1, 0, 0xd1, 0}, // = - NF_shadow_box_net (2)
{0xe1d2, 0, 0xd2, 0}, // ◢ - NF_rev_up_pointing_triangle1 (2)
{0xe1d3, 0, 0xd3, 0}, // ⎣ - NF_border_corner_lower_left (2)
{0xe1d4, 0, 0xd4, 0}, // _ - NF_border_line_bottom (2)
{0xe1d5, 0, 0xd5, 0}, // O - NF_radio_button2 (2)
{0xe1d6, 0, 0xd6, 0}, // ● - NF_radio_button2_checked (2)
{0xe1d7, 0, 0xd7, 0}, // ◥ - NF_rev_down_pointing_triangle1 (2)
{0xe1d8, 0, 0xd8, 0}, // ¯ - NF_border_line_upper (2)
{0xe1d9, 0, 0xd9, 0}, // ( - NF_radio_button1 (2)
{0xe1da, 0, 0xda, 0}, // ⎡ - NF_border_corner_upper_left (2)
{0xe1dc, 0, 0xdc, 0}, // ✓ - NF_shadow_box_checked (2)
{0xe1e7, 0, 0xe7, 0}, // ║ - NF_rev_border_line_right_and_left (2)
{0xe1e8, 0, 0xe8, 0}, // ◣ - NF_rev_up_pointing_triangle2 (2)
{0xe1e9, 0, 0xe9, 0}, // ◤ - NF_rev_down_pointing_triangle2 (2)
{0xe1ea, 0, 0xea, 0}, // ┘ - NF_border_corner_middle_lower_right (2)
{0xe1eb, 0, 0xeb, 0}, // ┐ - NF_border_corner_middle_upper_right (2)
{0xe1f4, 0, 0xf4, 0}, // ] - NF_rev_menu_button3 (2)
{0xe1f5, 0, 0xf5, 0}, // ] - NF_shadow_box_right (2)
{0xe1fb, 0, 0xfb, 0}, // ✓ - NF_check_mark (2)
{0xe1fc, '~', 0xfc, '`'}, // ˣ - NF_xsuperior (2)
{0x221a, 0, 0xfb, 'x'} // √ - square root
}};
/*
@ -161,47 +161,48 @@ std::array<std::array<uInt, fc::NUM_OF_ENCODINGS>, 115> character =
* (2) Only supported in use with newfont
*/
constexpr std::array<std::array<int, 2>, 39> dec_special_graphics =
constexpr std::array<DECSpecialGraphics, 39> dec_special_graphics =
{{
{{fc::vt100_key_rarrow , fc::BlackRightPointingPointer}}, // ►
{{fc::vt100_key_larrow , fc::BlackLeftPointingPointer}}, // ◄
{{fc::vt100_key_uarrow , fc::BlackUpPointingTriangle}}, // ▲
{{fc::vt100_key_darrow , fc::BlackDownPointingTriangle}}, // ▼
{{fc::vt100_key_block , fc::FullBlock}}, // █
{{fc::vt100_key_nsup , fc::SuperscriptLatinSmallLetterN}}, // ⁿ
{{fc::vt100_key_blackrect, fc::BlackVerticalRectangle}}, // ▮
{{fc::vt100_key_diamond , fc::BlackDiamondSuit}}, // ◆
{{fc::vt100_key_ckboard , fc::MediumShade}}, // ▒
{{fc::vt100_key_htab , fc::SymbolForHorizontalTab}}, // ␉
{{fc::vt100_key_ff , fc::SymbolForFormFeed}}, // ␌
{{fc::vt100_key_cr , fc::SymbolForCarriageReturn}}, // ␍
{{fc::vt100_key_lf , fc::SymbolForLineFeed}}, // ␊
{{fc::vt100_key_degree , fc::Degree}}, // °
{{fc::vt100_key_plminus , fc::PlusMinus}}, // ±
{{fc::vt100_key_board , fc::SymbolForNewline}}, // ␤
{{fc::vt100_key_lantern , fc::SymbolForVerticalTab}}, // ␋
{{fc::vt100_key_lrcorner , fc::BoxDrawingsUpAndLeft}}, // ┘
{{fc::vt100_key_urcorner , fc::BoxDrawingsDownAndLeft}}, // ┐
{{fc::vt100_key_ulcorner , fc::BoxDrawingsDownAndRight}}, // ┌
{{fc::vt100_key_llcorner , fc::BoxDrawingsUpAndRight}}, // └
{{fc::vt100_key_plus , fc::BoxDrawingsCross}}, // ┼
{{fc::vt100_key_s1 , fc::HorizontalScanLine1}}, // ⎺
{{fc::vt100_key_s3 , fc::HorizontalScanLine3}}, // ⎻
{{fc::vt100_key_hline , fc::BoxDrawingsHorizontal}}, // ─
{{fc::vt100_key_s7 , fc::HorizontalScanLine7}}, // ⎼
{{fc::vt100_key_s9 , fc::HorizontalScanLine9}}, // ⎽
{{fc::vt100_key_ltee , fc::BoxDrawingsVerticalAndRight}}, // ├
{{fc::vt100_key_rtee , fc::BoxDrawingsVerticalAndLeft}}, // ┤
{{fc::vt100_key_btee , fc::BoxDrawingsUpAndHorizontal}}, // ┴
{{fc::vt100_key_ttee , fc::BoxDrawingsDownAndHorizontal}}, // ┬
{{fc::vt100_key_vline , fc::BoxDrawingsVertical}}, // │
{{fc::vt100_key_lequal , fc::LessThanOrEqualTo}}, // ≤
{{fc::vt100_key_gequal , fc::GreaterThanOrEqualTo}}, // ≥
{{fc::vt100_key_pi , fc::Pi}}, // π
{{fc::vt100_key_nequal , fc::NotEqualTo}}, // ≠
{{fc::vt100_key_sterling , fc::Pound}}, // £
{{fc::vt100_key_bullet , fc::SmallBullet}}, // ·
{{fc::vt100_key_diamond , fc::Bullet}} // ◆
{VT100Key::rarrow , UniChar::BlackRightPointingPointer}, // ►
{VT100Key::larrow , UniChar::BlackLeftPointingPointer}, // ◄
{VT100Key::uarrow , UniChar::BlackUpPointingTriangle}, // ▲
{VT100Key::darrow , UniChar::BlackDownPointingTriangle}, // ▼
{VT100Key::block , UniChar::FullBlock}, // █
{VT100Key::nsup , UniChar::SuperscriptLatinSmallLetterN}, // ⁿ
{VT100Key::blackrect, UniChar::BlackVerticalRectangle}, // ▮
{VT100Key::diamond , UniChar::BlackDiamondSuit}, // ◆
{VT100Key::ckboard , UniChar::MediumShade}, // ▒
{VT100Key::htab , UniChar::SymbolForHorizontalTab}, // ␉
{VT100Key::ff , UniChar::SymbolForFormFeed}, // ␌
{VT100Key::cr , UniChar::SymbolForCarriageReturn}, // ␍
{VT100Key::lf , UniChar::SymbolForLineFeed}, // ␊
{VT100Key::degree , UniChar::Degree}, // °
{VT100Key::plminus , UniChar::PlusMinus}, // ±
{VT100Key::board , UniChar::SymbolForNewline}, // ␤
{VT100Key::lantern , UniChar::SymbolForVerticalTab}, // ␋
{VT100Key::lrcorner , UniChar::BoxDrawingsUpAndLeft}, // ┘
{VT100Key::urcorner , UniChar::BoxDrawingsDownAndLeft}, // ┐
{VT100Key::ulcorner , UniChar::BoxDrawingsDownAndRight}, // ┌
{VT100Key::llcorner , UniChar::BoxDrawingsUpAndRight}, // └
{VT100Key::plus , UniChar::BoxDrawingsCross}, // ┼
{VT100Key::s1 , UniChar::HorizontalScanLine1}, // ⎺
{VT100Key::s3 , UniChar::HorizontalScanLine3}, // ⎻
{VT100Key::hline , UniChar::BoxDrawingsHorizontal}, // ─
{VT100Key::s7 , UniChar::HorizontalScanLine7}, // ⎼
{VT100Key::s9 , UniChar::HorizontalScanLine9}, // ⎽
{VT100Key::ltee , UniChar::BoxDrawingsVerticalAndRight}, // ├
{VT100Key::rtee , UniChar::BoxDrawingsVerticalAndLeft}, // ┤
{VT100Key::btee , UniChar::BoxDrawingsUpAndHorizontal}, // ┴
{VT100Key::ttee , UniChar::BoxDrawingsDownAndHorizontal}, // ┬
{VT100Key::vline , UniChar::BoxDrawingsVertical}, // │
{VT100Key::lequal , UniChar::LessThanOrEqualTo}, // ≤
{VT100Key::gequal , UniChar::GreaterThanOrEqualTo}, // ≥
{VT100Key::pi , UniChar::Pi}, // π
{VT100Key::nequal , UniChar::NotEqualTo}, // ≠
{VT100Key::sterling , UniChar::Pound}, // £
{VT100Key::bullet , UniChar::SmallBullet}, // ·
{VT100Key::diamond , UniChar::Bullet} // ◆
}};
constexpr std::array<std::array<wchar_t, 2>, 256> cp437_ucs =

View File

@ -99,7 +99,7 @@ inline void FCheckBox::drawChecked()
else
{
print ('[');
print (fc::Times); // Times ×
print (UniChar::Times); // Times ×
print (']');
}
}

View File

@ -49,22 +49,22 @@ void FColorPalette::setPalette (FColor index, int r, int g, int b) const
//----------------------------------------------------------------------
void FColorPalette::setVGAdefaultPalette() const
{
setPalette (fc::Black, 0x00, 0x00, 0x00);
setPalette (fc::Blue, 0x00, 0x00, 0xaa);
setPalette (fc::Green, 0x00, 0xaa, 0x00);
setPalette (fc::Cyan, 0x00, 0xaa, 0xaa);
setPalette (fc::Red, 0xaa, 0x00, 0x00);
setPalette (fc::Magenta, 0xaa, 0x00, 0xaa);
setPalette (fc::Brown, 0xaa, 0x55, 0x00);
setPalette (fc::LightGray, 0xaa, 0xaa, 0xaa);
setPalette (fc::DarkGray, 0x55, 0x55, 0x55);
setPalette (fc::LightBlue, 0x55, 0x55, 0xff);
setPalette (fc::LightGreen, 0x55, 0xff, 0x55);
setPalette (fc::LightCyan, 0x55, 0xff, 0xff);
setPalette (fc::LightRed, 0xff, 0x55, 0x55);
setPalette (fc::LightMagenta, 0xff, 0x55, 0xff);
setPalette (fc::Yellow, 0xff, 0xff, 0x55);
setPalette (fc::White, 0xff, 0xff, 0xff);
setPalette (FColor::Black, 0x00, 0x00, 0x00);
setPalette (FColor::Blue, 0x00, 0x00, 0xaa);
setPalette (FColor::Green, 0x00, 0xaa, 0x00);
setPalette (FColor::Cyan, 0x00, 0xaa, 0xaa);
setPalette (FColor::Red, 0xaa, 0x00, 0x00);
setPalette (FColor::Magenta, 0xaa, 0x00, 0xaa);
setPalette (FColor::Brown, 0xaa, 0x55, 0x00);
setPalette (FColor::LightGray, 0xaa, 0xaa, 0xaa);
setPalette (FColor::DarkGray, 0x55, 0x55, 0x55);
setPalette (FColor::LightBlue, 0x55, 0x55, 0xff);
setPalette (FColor::LightGreen, 0x55, 0xff, 0x55);
setPalette (FColor::LightCyan, 0x55, 0xff, 0xff);
setPalette (FColor::LightRed, 0xff, 0x55, 0x55);
setPalette (FColor::LightMagenta, 0xff, 0x55, 0xff);
setPalette (FColor::Yellow, 0xff, 0xff, 0x55);
setPalette (FColor::White, 0xff, 0xff, 0xff);
}
//----------------------------------------------------------------------
@ -85,23 +85,23 @@ default8ColorPalette::~default8ColorPalette() noexcept = default; // destructor
//----------------------------------------------------------------------
void default8ColorPalette::setColorPalette()
{
setPalette (fc::Black, 0x00, 0x00, 0x00);
setPalette (fc::Blue, 0x10, 0x3b, 0x9e);
setPalette (fc::Green, 0x18, 0x78, 0x18);
setPalette (fc::Cyan, 0xa0, 0xb2, 0xb2);
setPalette (fc::Red, 0xb2, 0x18, 0x18);
setPalette (fc::Magenta, 0xb2, 0x18, 0xb2);
setPalette (fc::Brown, 0xe8, 0x87, 0x1f);
setPalette (fc::LightGray, 0xe0, 0xe0, 0xe0);
setPalette (FColor::Black, 0x00, 0x00, 0x00);
setPalette (FColor::Blue, 0x10, 0x3b, 0x9e);
setPalette (FColor::Green, 0x18, 0x78, 0x18);
setPalette (FColor::Cyan, 0xa0, 0xb2, 0xb2);
setPalette (FColor::Red, 0xb2, 0x18, 0x18);
setPalette (FColor::Magenta, 0xb2, 0x18, 0xb2);
setPalette (FColor::Brown, 0xe8, 0x87, 0x1f);
setPalette (FColor::LightGray, 0xe0, 0xe0, 0xe0);
// The same colors again...
setPalette (fc::DarkGray, 0x00, 0x00, 0x00);
setPalette (fc::LightBlue, 0x10, 0x3b, 0x9e);
setPalette (fc::LightGreen, 0x18, 0x78, 0x18);
setPalette (fc::Cyan, 0xa0, 0xb2, 0xb2);
setPalette (fc::LightRed, 0xb2, 0x18, 0x18);
setPalette (fc::LightMagenta, 0xb2, 0x18, 0xb2);
setPalette (fc::Yellow, 0xe8, 0x87, 0x1f);
setPalette (fc::White, 0xe0, 0xe0, 0xe0);
setPalette (FColor::DarkGray, 0x00, 0x00, 0x00);
setPalette (FColor::LightBlue, 0x10, 0x3b, 0x9e);
setPalette (FColor::LightGreen, 0x18, 0x78, 0x18);
setPalette (FColor::Cyan, 0xa0, 0xb2, 0xb2);
setPalette (FColor::LightRed, 0xb2, 0x18, 0x18);
setPalette (FColor::LightMagenta, 0xb2, 0x18, 0xb2);
setPalette (FColor::Yellow, 0xe8, 0x87, 0x1f);
setPalette (FColor::White, 0xe0, 0xe0, 0xe0);
}
//----------------------------------------------------------------------
@ -129,22 +129,22 @@ default16ColorPalette::~default16ColorPalette() noexcept = default; // destruct
//----------------------------------------------------------------------
void default16ColorPalette::setColorPalette()
{
setPalette (fc::Black, 0x00, 0x00, 0x00);
setPalette (fc::Blue, 0x10, 0x3b, 0x9e);
setPalette (fc::Green, 0x18, 0x78, 0x18);
setPalette (fc::Cyan, 0x55, 0x6a, 0xcf);
setPalette (fc::Red, 0xba, 0x1a, 0x1a);
setPalette (fc::Magenta, 0xb2, 0x18, 0xb2);
setPalette (fc::Brown, 0xe8, 0x87, 0x1f);
setPalette (fc::LightGray, 0xbc, 0xbc, 0xbc);
setPalette (fc::DarkGray, 0x50, 0x50, 0x50);
setPalette (fc::LightBlue, 0x80, 0xa4, 0xec);
setPalette (fc::LightGreen, 0x5e, 0xeb, 0x5c);
setPalette (fc::LightCyan, 0x62, 0xbf, 0xf8);
setPalette (fc::LightRed, 0xee, 0x44, 0x44);
setPalette (fc::LightMagenta, 0xe9, 0xad, 0xff);
setPalette (fc::Yellow, 0xfb, 0xe8, 0x67);
setPalette (fc::White, 0xff, 0xff, 0xff);
setPalette (FColor::Black, 0x00, 0x00, 0x00);
setPalette (FColor::Blue, 0x10, 0x3b, 0x9e);
setPalette (FColor::Green, 0x18, 0x78, 0x18);
setPalette (FColor::Cyan, 0x55, 0x6a, 0xcf);
setPalette (FColor::Red, 0xba, 0x1a, 0x1a);
setPalette (FColor::Magenta, 0xb2, 0x18, 0xb2);
setPalette (FColor::Brown, 0xe8, 0x87, 0x1f);
setPalette (FColor::LightGray, 0xbc, 0xbc, 0xbc);
setPalette (FColor::DarkGray, 0x50, 0x50, 0x50);
setPalette (FColor::LightBlue, 0x80, 0xa4, 0xec);
setPalette (FColor::LightGreen, 0x5e, 0xeb, 0x5c);
setPalette (FColor::LightCyan, 0x62, 0xbf, 0xf8);
setPalette (FColor::LightRed, 0xee, 0x44, 0x44);
setPalette (FColor::LightMagenta, 0xe9, 0xad, 0xff);
setPalette (FColor::Yellow, 0xfb, 0xe8, 0x67);
setPalette (FColor::White, 0xff, 0xff, 0xff);
}
//----------------------------------------------------------------------
@ -172,22 +172,22 @@ default16DarkColorPalette::~default16DarkColorPalette() noexcept = default; //
//----------------------------------------------------------------------
void default16DarkColorPalette::setColorPalette()
{
setPalette (fc::Black, 0x00, 0x00, 0x00);
setPalette (fc::Blue, 0x41, 0x58, 0xb3);
setPalette (fc::Green, 0x18, 0x78, 0x18);
setPalette (fc::Cyan, 0x4e, 0x66, 0x72);
setPalette (fc::Red, 0xa5, 0x40, 0x40);
setPalette (fc::Magenta, 0xb2, 0x18, 0xb2);
setPalette (fc::Brown, 0xe8, 0x87, 0x1f);
setPalette (fc::LightGray, 0xdc, 0xdc, 0xdc);
setPalette (fc::DarkGray, 0x27, 0x33, 0x39);
setPalette (fc::LightBlue, 0xb0, 0xb0, 0xb8);
setPalette (fc::LightGreen, 0x5e, 0xeb, 0x5c);
setPalette (fc::LightCyan, 0x62, 0xbf, 0xf8);
setPalette (fc::LightRed, 0xdd, 0x51, 0x45);
setPalette (fc::LightMagenta, 0xe9, 0xad, 0xff);
setPalette (fc::Yellow, 0xfb, 0xe8, 0x67);
setPalette (fc::White, 0xff, 0xff, 0xff);
setPalette (FColor::Black, 0x00, 0x00, 0x00);
setPalette (FColor::Blue, 0x41, 0x58, 0xb3);
setPalette (FColor::Green, 0x18, 0x78, 0x18);
setPalette (FColor::Cyan, 0x4e, 0x66, 0x72);
setPalette (FColor::Red, 0xa5, 0x40, 0x40);
setPalette (FColor::Magenta, 0xb2, 0x18, 0xb2);
setPalette (FColor::Brown, 0xe8, 0x87, 0x1f);
setPalette (FColor::LightGray, 0xdc, 0xdc, 0xdc);
setPalette (FColor::DarkGray, 0x27, 0x33, 0x39);
setPalette (FColor::LightBlue, 0xb0, 0xb0, 0xb8);
setPalette (FColor::LightGreen, 0x5e, 0xeb, 0x5c);
setPalette (FColor::LightCyan, 0x62, 0xbf, 0xf8);
setPalette (FColor::LightRed, 0xdd, 0x51, 0x45);
setPalette (FColor::LightMagenta, 0xe9, 0xad, 0xff);
setPalette (FColor::Yellow, 0xfb, 0xe8, 0x67);
setPalette (FColor::White, 0xff, 0xff, 0xff);
}
//----------------------------------------------------------------------

View File

@ -145,7 +145,7 @@ void FDropDownListBox::drawShadow()
const auto& wc = getColorTheme();
finalcut::drawShadow(this);
setColor (wc->shadow_fg, wc->shadow_bg);
print() << FPoint{int(getWidth()) + 1, 1} << fc::FullBlock; // █
print() << FPoint{int(getWidth()) + 1, 1} << UniChar::FullBlock; // █
}
//----------------------------------------------------------------------
@ -219,8 +219,8 @@ bool FComboBox::setFocus (bool enable)
bool FComboBox::setShadow (bool enable)
{
if ( enable
&& FTerm::getEncoding() != fc::VT100
&& FTerm::getEncoding() != fc::ASCII )
&& FTerm::getEncoding() != Encoding::VT100
&& FTerm::getEncoding() != Encoding::ASCII )
{
setFlags().shadow = true;
setShadowSize(FSize{1, 1});
@ -353,50 +353,47 @@ void FComboBox::onKeyPress (FKeyEvent* ev)
if ( ! isEnabled() )
return;
switch ( ev->key() )
const auto key = ev->key();
if ( key == FKey::Tab )
{
case fc::Fkey_tab:
focusNextChild();
break;
case fc::Fkey_btab:
focusPrevChild();
break;
case fc::Fkey_up:
onePosUp();
ev->accept();
break;
case fc::Fkey_down:
onePosDown();
ev->accept();
break;
case fc::Fmkey_up:
case fc::Fckey_up:
case fc::Fkey_escape:
case fc::Fkey_escape_mintty:
hideDropDown();
ev->accept();
break;
case fc::Fkey_f4:
case fc::Fmkey_down:
case fc::Fckey_down:
showDropDown();
ev->accept();
break;
default:
break;
focusNextChild();
}
else if ( key == FKey::Back_tab )
{
focusPrevChild();
}
else if ( key == FKey::Up )
{
onePosUp();
ev->accept();
}
else if ( key == FKey::Down )
{
onePosDown();
ev->accept();
}
else if ( key == FKey::Meta_up
|| key == FKey::Ctrl_up
|| key == FKey::Escape
|| key == FKey::Escape_mintty )
{
hideDropDown();
ev->accept();
}
else if ( key == FKey::F4
|| key == FKey::Meta_down
|| key == FKey::Ctrl_down )
{
showDropDown();
ev->accept();
}
}
//----------------------------------------------------------------------
void FComboBox::onMouseDown (FMouseEvent* ev)
{
if ( ev->getButton() != fc::LeftButton )
if ( ev->getButton() != MouseButton::Left )
return;
if ( ! hasFocus() )
@ -429,7 +426,7 @@ void FComboBox::onMouseDown (FMouseEvent* ev)
//----------------------------------------------------------------------
void FComboBox::onMouseMove (FMouseEvent* ev)
{
if ( ev->getButton() != fc::LeftButton )
if ( ev->getButton() != MouseButton::Left )
return;
if ( isMouseOverListWindow(ev->getTermPos()) )
@ -442,19 +439,10 @@ void FComboBox::onMouseMove (FMouseEvent* ev)
//----------------------------------------------------------------------
void FComboBox::onWheel (FWheelEvent* ev)
{
switch ( ev->getWheel() )
{
case fc::WheelUp:
onePosUp();
break;
case fc::WheelDown:
onePosDown();
break;
default:
break;
}
if ( ev->getWheel() == MouseWheel::Up )
onePosUp();
else if ( ev->getWheel() == MouseWheel::Down )
onePosDown();
}
//----------------------------------------------------------------------
@ -549,7 +537,7 @@ void FComboBox::draw()
if ( FTerm::isNewFont() )
print() << NF_button_arrow_down;
else
print() << fc::BlackDownPointingTriangle; // ▼
print() << UniChar::BlackDownPointingTriangle; // ▼
if ( getFlags().shadow )
drawShadow(this);
@ -594,20 +582,12 @@ void FComboBox::passEventToListWindow (const FMouseEvent& ev)
const auto& t = ev.getTermPos();
const auto& p = list_window.list.termToWidgetPos(t);
const int b = ev.getButton();
try
{
const auto& _ev = \
std::make_shared<FMouseEvent>(fc::MouseMove_Event, p, t, b);
setClickedWidget(&list_window.list);
list_window.list.setFocus();
list_window.list.onMouseMove(_ev.get());
}
catch (const std::bad_alloc&)
{
badAllocOutput ("FMouseEvent");
}
const auto b = ev.getButton();
const auto& _ev = \
std::make_shared<FMouseEvent>(Event::MouseMove, p, t, b);
setClickedWidget(&list_window.list);
list_window.list.setFocus();
list_window.list.onMouseMove(_ev.get());
}
//----------------------------------------------------------------------
@ -681,20 +661,12 @@ void FComboBox::cb_inputFieldHandOver()
const auto& t = mouse->getPos();
const auto& p = list_window.list.termToWidgetPos(t);
const int b = ( mouse->isLeftButtonPressed() ) ? fc::LeftButton : 0;
try
{
const auto& _ev = \
std::make_shared<FMouseEvent>(fc::MouseMove_Event, p, t, b);
setClickedWidget(&list_window.list);
list_window.list.setFocus();
list_window.list.onMouseMove(_ev.get());
}
catch (const std::bad_alloc&)
{
badAllocOutput ("FMouseEvent");
}
const auto b = ( mouse->isLeftButtonPressed() ) ? MouseButton::Left : MouseButton::None;
const auto& _ev = \
std::make_shared<FMouseEvent>(Event::MouseMove, p, t, b);
setClickedWidget(&list_window.list);
list_window.list.setFocus();
list_window.list.onMouseMove(_ev.get());
}
// non-member functions

View File

@ -27,6 +27,7 @@
#include "final/fdialog.h"
#include "final/fevent.h"
#include "final/fkeyboard.h"
#include "final/fmenubar.h"
#include "final/fmenuitem.h"
#include "final/fstatusbar.h"
#include "final/ftooltip.h"
@ -459,9 +460,9 @@ void FDialog::onKeyPress (FKeyEvent* ev)
cancelMouseResize();
if ( ev->key() == fc::Fckey_caret // Ctrl+^ (Ctrl+6)
|| ev->key() == fc::Fkey_f22 // Shift+F10
|| ev->key() == fc::Fkey_smenu ) // Shift+Menu
if ( ev->key() == FKey::Ctrl_caret // Ctrl+^ (Ctrl+6)
|| ev->key() == FKey::F22 // Shift+F10
|| ev->key() == FKey::Shift_menu ) // Shift+Menu
{
ev->accept();
// open the titlebar menu
@ -478,8 +479,8 @@ void FDialog::onKeyPress (FKeyEvent* ev)
return;
if ( ! ev->isAccepted()
&& ( ev->key() == fc::Fkey_escape
|| ev->key() == fc::Fkey_escape_mintty) )
&& ( ev->key() == FKey::Escape
|| ev->key() == FKey::Escape_mintty) )
{
ev->accept();
@ -506,7 +507,7 @@ void FDialog::onMouseDown (FMouseEvent* ev)
deactivateZoomButton();
if ( ev->getButton() == fc::LeftButton )
if ( ev->getButton() == MouseButton::Left )
{
// Click on titlebar or window: raise + activate
raiseActivateDialog();
@ -527,7 +528,7 @@ void FDialog::onMouseDown (FMouseEvent* ev)
// Click on the lower right resize corner
resizeMouseDown(ms);
}
else // ev->getButton() != fc::LeftButton
else // ev->getButton() != MouseButton::Left
{
// Click on titlebar menu button
if ( ms.mouse_x < 4 && ms.mouse_y == 1 && dialog_menu->isShown() )
@ -537,14 +538,14 @@ void FDialog::onMouseDown (FMouseEvent* ev)
}
// Click on titlebar: just activate
if ( ev->getButton() == fc::RightButton
if ( ev->getButton() == MouseButton::Right
&& ms.mouse_x >= 4
&& ms.mouse_x <= width
&& ms.mouse_y == 1 )
activateDialog();
// Click on titlebar: lower + activate
if ( ev->getButton() == fc::MiddleButton
if ( ev->getButton() == MouseButton::Middle
&& ms.mouse_x >= 4 && ms.mouse_x <= width
&& ms.mouse_y == 1 )
lowerActivateDialog();
@ -562,7 +563,7 @@ void FDialog::onMouseUp (FMouseEvent* ev)
false // mouse_over_menu
};
if ( ev->getButton() == fc::LeftButton )
if ( ev->getButton() == MouseButton::Left )
{
const int titlebar_x = titlebar_click_pos.getX();
const int titlebar_y = titlebar_click_pos.getY();
@ -611,7 +612,7 @@ void FDialog::onMouseMove (FMouseEvent* ev)
isMouseOverMenu(ev->getTermPos())
};
if ( ev->getButton() != fc::LeftButton )
if ( ev->getButton() != MouseButton::Left )
return;
if ( ! titlebar_click_pos.isOrigin() )
@ -641,7 +642,7 @@ void FDialog::onMouseDoubleClick (FMouseEvent* ev)
false // mouse_over_menu
};
if ( ev->getButton() != fc::LeftButton )
if ( ev->getButton() != MouseButton::Left )
return;
const int x = getTermX();
@ -684,6 +685,14 @@ void FDialog::onAccel (FAccelEvent*)
{
if ( ! (isWindowHidden() || isWindowActive()) )
{
const auto menu_bar = getMenuBar();
if ( menu_bar )
{
menu_bar->resetMenu();
menu_bar->redraw();
}
const bool has_raised = raiseWindow();
activateDialog();
@ -824,6 +833,7 @@ void FDialog::init()
// Initialize geometry values
setGeometry (FPoint{1, 1}, FSize{10, 10}, false);
setMinimumSize (FSize{15, 4});
mapKeyFunctions();
addDialog(this);
setActiveWindow(this);
setTransparentShadow();
@ -943,6 +953,27 @@ void FDialog::initCloseMenuItem (FMenu* menu)
);
}
//----------------------------------------------------------------------
inline void FDialog::mapKeyFunctions()
{
key_map[FKey::Up] = [this] () { moveUp(1); };
key_map[FKey::Down] = [this] () { moveDown(1); };
key_map[FKey::Left] = [this] () { moveLeft(1); };
key_map[FKey::Right] = [this] () { moveRight(1); };
key_map[FKey::Meta_up] = [this] () { reduceHeight(1); };
key_map[FKey::Shift_up] = [this] () { reduceHeight(1); };
key_map[FKey::Meta_down] = [this] () { expandHeight(1); };
key_map[FKey::Shift_down] = [this] () { expandHeight(1); };
key_map[FKey::Meta_left] = [this] () { reduceWidth(1); };
key_map[FKey::Shift_left] = [this] () { reduceWidth(1); };
key_map[FKey::Meta_right] = [this] () { expandWidth(1); };
key_map[FKey::Shift_right] = [this] () { expandWidth(1); };
key_map[FKey::Return] = [this] () { acceptMoveSize(); };
key_map[FKey::Enter] = [this] () { acceptMoveSize(); };
key_map[FKey::Escape] = [this] () { cancelMoveSize(); };
key_map[FKey::Escape_mintty] = [this] () { cancelMoveSize(); };
}
//----------------------------------------------------------------------
void FDialog::drawBorder()
{
@ -965,15 +996,15 @@ void FDialog::drawBorder()
for (auto y = r.getY1() + 1; y < r.getY2(); y++)
{
print() << FPoint{r.getX1(), y}
<< fc::NF_border_line_left // border left ⎸
<< UniChar::NF_border_line_left // border left ⎸
<< FPoint{r.getX2(), y}
<< fc::NF_rev_border_line_right; // border right⎹
<< UniChar::NF_rev_border_line_right; // border right⎹
}
print() << r.getLowerLeftPos()
<< fc::NF_border_corner_lower_left // ⎣
<< FString{r.getWidth() - 2, fc::NF_border_line_bottom} // _
<< fc::NF_rev_border_corner_lower_right; // ⎦
<< UniChar::NF_border_corner_lower_left // ⎣
<< FString{r.getWidth() - 2, UniChar::NF_border_line_bottom} // _
<< UniChar::NF_rev_border_corner_lower_right; // ⎦
}
else
{
@ -1087,13 +1118,13 @@ inline void FDialog::drawRestoreSizeButton()
if ( FTerm::isMonochron() )
{
print ('[');
print (fc::BlackDiamondSuit); // ◆
print (UniChar::BlackDiamondSuit); // ◆
print (']');
}
else
{
print (' ');
print (fc::BlackDiamondSuit); // ◆
print (UniChar::BlackDiamondSuit); // ◆
print (' ');
}
}
@ -1111,13 +1142,13 @@ inline void FDialog::drawZoomedButton()
if ( FTerm::isMonochron() )
{
print ('[');
print (fc::BlackUpPointingTriangle); // ▲
print (UniChar::BlackUpPointingTriangle); // ▲
print (']');
}
else
{
print (' ');
print (fc::BlackUpPointingTriangle); // ▲
print (UniChar::BlackUpPointingTriangle); // ▲
print (' ');
}
}
@ -1370,87 +1401,21 @@ inline void FDialog::passEventToSubMenu ( const MouseStates& ms
const auto& g = ms.termPos;
const auto& p = dialog_menu->termToWidgetPos(g);
const int b = ev.getButton();
try
{
const auto& _ev = \
std::make_shared<FMouseEvent>(fc::MouseMove_Event, p, g, b);
dialog_menu->mouse_down = true;
setClickedWidget(dialog_menu);
dialog_menu->onMouseMove(_ev.get());
}
catch (const std::bad_alloc&)
{
badAllocOutput ("FMouseEvent");
return;
}
const auto b = ev.getButton();
const auto& _ev = \
std::make_shared<FMouseEvent>(Event::MouseMove, p, g, b);
dialog_menu->mouse_down = true;
setClickedWidget(dialog_menu);
dialog_menu->onMouseMove(_ev.get());
}
//----------------------------------------------------------------------
inline void FDialog::moveSizeKey (FKeyEvent* ev)
{
switch ( ev->key() )
{
case fc::Fkey_up:
moveUp(1);
ev->accept();
break;
const auto key = ev->key();
case fc::Fkey_down:
moveDown(1);
ev->accept();
break;
case fc::Fkey_left:
moveLeft(1);
ev->accept();
break;
case fc::Fkey_right:
moveRight(1);
ev->accept();
break;
case fc::Fmkey_up:
case fc::Fkey_sr:
reduceHeight(1);
ev->accept();
break;
case fc::Fmkey_down:
case fc::Fkey_sf:
expandHeight(1);
ev->accept();
break;
case fc::Fmkey_left:
case fc::Fkey_sleft:
reduceWidth(1);
ev->accept();
break;
case fc::Fmkey_right:
case fc::Fkey_sright:
expandWidth(1);
ev->accept();
break;
case fc::Fkey_return:
case fc::Fkey_enter:
acceptMoveSize();
ev->accept();
break;
case fc::Fkey_escape:
case fc::Fkey_escape_mintty:
cancelMoveSize();
ev->accept();
return;
default:
break;
}
if ( key_map.find(key) != key_map.end() )
key_map[key]();
// Accept for all, so that parent widgets will not receive keystrokes
ev->accept();

View File

@ -30,12 +30,12 @@ namespace finalcut
// class FEvent
//----------------------------------------------------------------------
FEvent::FEvent (fc::events ev_type) // constructor
FEvent::FEvent (Event ev_type) // constructor
: t{ev_type}
{ }
//----------------------------------------------------------------------
fc::events FEvent::getType() const
Event FEvent::getType() const
{ return t; }
//----------------------------------------------------------------------
@ -51,7 +51,7 @@ bool FEvent::wasSent() const
// class FKeyEvent
//----------------------------------------------------------------------
FKeyEvent::FKeyEvent (fc::events ev_type, FKey key_num) // constructor
FKeyEvent::FKeyEvent (Event ev_type, FKey key_num) // constructor
: FEvent{ev_type}
, k{key_num}
{ }
@ -77,10 +77,10 @@ void FKeyEvent::ignore()
// class FMouseEvent
//----------------------------------------------------------------------
FMouseEvent::FMouseEvent ( fc::events ev_type // constructor
FMouseEvent::FMouseEvent ( Event ev_type // constructor
, const FPoint& pos
, const FPoint& termPos
, int button )
, MouseButton button )
: FEvent{ev_type}
, p{pos}
, tp{termPos}
@ -88,9 +88,9 @@ FMouseEvent::FMouseEvent ( fc::events ev_type // constructor
{ }
//----------------------------------------------------------------------
FMouseEvent::FMouseEvent ( fc::events ev_type // constructor
FMouseEvent::FMouseEvent ( Event ev_type // constructor
, const FPoint& pos
, int button )
, MouseButton button )
: FMouseEvent{ev_type, pos, FPoint{}, button}
{ }
@ -119,7 +119,7 @@ int FMouseEvent::getTermY() const
{ return tp.getY(); }
//----------------------------------------------------------------------
int FMouseEvent::getButton() const
MouseButton FMouseEvent::getButton() const
{ return b; }
@ -127,10 +127,10 @@ int FMouseEvent::getButton() const
// class FWheelEvent
//----------------------------------------------------------------------
FWheelEvent::FWheelEvent ( fc::events ev_type // constructor
FWheelEvent::FWheelEvent ( Event ev_type // constructor
, const FPoint& pos
, const FPoint& termPos
, int wheel )
, MouseWheel wheel )
: FEvent{ev_type}
, p{pos}
, tp{termPos}
@ -138,9 +138,9 @@ FWheelEvent::FWheelEvent ( fc::events ev_type // constructor
{ }
//----------------------------------------------------------------------
FWheelEvent::FWheelEvent ( fc::events ev_type // constructor
FWheelEvent::FWheelEvent ( Event ev_type // constructor
, const FPoint& pos
, int wheel )
, MouseWheel wheel )
: FWheelEvent{ev_type, pos, FPoint{}, wheel}
{ }
@ -169,7 +169,7 @@ int FWheelEvent::getTermY() const
{ return tp.getY(); }
//----------------------------------------------------------------------
int FWheelEvent::getWheel() const
MouseWheel FWheelEvent::getWheel() const
{ return w; }
@ -177,28 +177,28 @@ int FWheelEvent::getWheel() const
// class FFocusEvent
//----------------------------------------------------------------------
FFocusEvent::FFocusEvent (fc::events ev_type) // constructor
FFocusEvent::FFocusEvent (Event ev_type) // constructor
: FEvent{ev_type}
{ }
//----------------------------------------------------------------------
bool FFocusEvent::gotFocus() const
{
return ( getType() == fc::FocusIn_Event );
return ( getType() == Event::FocusIn );
}
//----------------------------------------------------------------------
bool FFocusEvent::lostFocus() const
{
return ( getType() == fc::FocusOut_Event );
return ( getType() == Event::FocusOut );
}
//----------------------------------------------------------------------
fc::FocusTypes FFocusEvent::getFocusType() const
FocusTypes FFocusEvent::getFocusType() const
{ return focus_type; }
//----------------------------------------------------------------------
void FFocusEvent::setFocusType(fc::FocusTypes ft)
void FFocusEvent::setFocusType (FocusTypes ft)
{ focus_type = ft; }
//----------------------------------------------------------------------
@ -218,7 +218,7 @@ void FFocusEvent::ignore()
// class FAccelEvent
//----------------------------------------------------------------------
FAccelEvent::FAccelEvent (fc::events ev_type, FWidget* focused) // constructor
FAccelEvent::FAccelEvent (Event ev_type, FWidget* focused) // constructor
: FEvent{ev_type}
, focus_widget{focused}
{ }
@ -244,7 +244,7 @@ void FAccelEvent::ignore()
// class FResizeEvent
//----------------------------------------------------------------------
FResizeEvent::FResizeEvent (fc::events ev_type) // constructor
FResizeEvent::FResizeEvent (Event ev_type) // constructor
: FEvent{ev_type}
{ }
@ -265,7 +265,7 @@ void FResizeEvent::ignore()
// class FShowEvent
//----------------------------------------------------------------------
FShowEvent::FShowEvent (fc::events ev_type) // constructor
FShowEvent::FShowEvent (Event ev_type) // constructor
: FEvent{ev_type}
{ }
@ -274,7 +274,7 @@ FShowEvent::FShowEvent (fc::events ev_type) // constructor
// class FHideEvent
//----------------------------------------------------------------------
FHideEvent::FHideEvent (fc::events ev_type) // constructor
FHideEvent::FHideEvent (Event ev_type) // constructor
: FEvent{ev_type}
{ }
@ -283,7 +283,7 @@ FHideEvent::FHideEvent (fc::events ev_type) // constructor
// class FCloseEvent
//----------------------------------------------------------------------
FCloseEvent::FCloseEvent (fc::events ev_type) // constructor
FCloseEvent::FCloseEvent (Event ev_type) // constructor
: FEvent{ev_type}
{ }
@ -304,7 +304,7 @@ void FCloseEvent::ignore()
// class FTimerEvent
//----------------------------------------------------------------------
FTimerEvent::FTimerEvent (fc::events ev_type, int timer_id) // constructor
FTimerEvent::FTimerEvent (Event ev_type, int timer_id) // constructor
: FEvent{ev_type}
, id{timer_id}
{ }
@ -318,7 +318,7 @@ int FTimerEvent::getTimerId() const
// class FUserEvent
//----------------------------------------------------------------------
FUserEvent::FUserEvent (fc::events ev_type, int user_event_id) // constructor
FUserEvent::FUserEvent (Event ev_type, int user_event_id) // constructor
: FEvent{ev_type}
, uid{user_event_id}
{ }

View File

@ -206,16 +206,10 @@ void FFileDialog::onKeyPress (FKeyEvent* ev)
const FKey key = ev->key();
switch ( key )
if ( key == FKey::Erase || key == FKey::Backspace )
{
case fc::Fkey_erase:
case fc::Fkey_backspace:
changeDir("..");
ev->accept();
break;
default:
break;
changeDir("..");
ev->accept();
}
}
@ -590,7 +584,7 @@ void FFileDialog::dirEntriesToList()
for (auto&& entry : dir_entries)
{
if ( entry.directory )
filebrowser.insert(FString{entry.name}, fc::SquareBrackets);
filebrowser.insert(FString{entry.name}, BracketType::Brackets);
else
filebrowser.insert(FString{entry.name});
}

File diff suppressed because it is too large Load Diff

View File

@ -87,11 +87,11 @@ FString FKeyboard::getKeyName (const FKey keynum) const
{
const auto& found_key = std::find_if
(
fc::fkeyname.begin(),
fc::fkeyname.end(),
fc::fkeyname.cbegin(),
fc::fkeyname.cend(),
[&keynum] (const fc::FKeyName& kn)
{
return (kn.num > 0 && kn.num == keynum);
return (kn.num != FKey::None && kn.num == keynum);
}
);
@ -179,8 +179,8 @@ void FKeyboard::clearKeyBuffer()
// Empty the buffer
fifo_offset = 0;
fkey = 0;
key = 0;
fkey = FKey::None;
key = FKey::None;
std::fill_n (fifo_buf, FIFO_BUF_SIZE, '\0');
fifo_in_use = false;
}
@ -225,7 +225,7 @@ void FKeyboard::processQueuedInput()
key = fkey_queue.front();
fkey_queue.pop();
if ( key > 0 )
if ( key > FKey::None )
{
keyPressed();
@ -237,7 +237,7 @@ void FKeyboard::processQueuedInput()
if ( FApplication::isQuit() )
return;
key = 0;
key = FKey::None;
}
}
}
@ -255,18 +255,18 @@ inline FKey FKeyboard::getMouseProtocolKey() const
// x11 mouse tracking
if ( buf_len >= 6 && fifo_buf[1] == '[' && fifo_buf[2] == 'M' )
return fc::Fkey_mouse;
return FKey::X11mouse;
// SGR mouse tracking
if ( fifo_buf[1] == '[' && fifo_buf[2] == '<' && buf_len >= 9
&& (fifo_buf[buf_len - 1] == 'M' || fifo_buf[buf_len - 1] == 'm') )
return fc::Fkey_extended_mouse;
return FKey::Extended_mouse;
// urxvt mouse tracking
if ( fifo_buf[1] == '[' && fifo_buf[2] >= '1' && fifo_buf[2] <= '9'
&& fifo_buf[3] >= '0' && fifo_buf[3] <= '9' && buf_len >= 9
&& fifo_buf[buf_len - 1] == 'M' )
return fc::Fkey_urxvt_mouse;
return FKey::Urxvt_mouse;
return NOT_SET;
}
@ -283,10 +283,10 @@ inline FKey FKeyboard::getTermcapKey()
for (auto&& entry : *key_map)
{
const char* k = entry.string;
const std::size_t len = ( k ) ? std::strlen(k) : 0;
const char* kstr = entry.string;
const std::size_t len = ( kstr ) ? std::strlen(kstr) : 0;
if ( k && std::strncmp(k, fifo_buf, len) == 0 ) // found
if ( kstr && std::strncmp(kstr, fifo_buf, len) == 0 ) // found
{
std::size_t n{};
@ -305,18 +305,18 @@ inline FKey FKeyboard::getTermcapKey()
}
//----------------------------------------------------------------------
inline FKey FKeyboard::getMetaKey()
inline FKey FKeyboard::getKnownKey()
{
// Looking for meta key strings in the buffer
// Looking for a known key strings in the buffer
assert ( FIFO_BUF_SIZE > 0 );
for (auto&& entry : fc::fmetakey)
for (auto&& entry : fc::fkey_table)
{
const char* kmeta = entry.string; // The string is never null
const std::size_t len = std::strlen(kmeta);
const char* kstr = entry.string; // The string is never null
const std::size_t len = std::strlen(kstr);
if ( std::strncmp(kmeta, fifo_buf, len) == 0 ) // found
if ( std::strncmp(kstr, fifo_buf, len) == 0 ) // found
{
std::size_t n{};
@ -326,7 +326,7 @@ inline FKey FKeyboard::getMetaKey()
|| fifo_buf[1] == ']' )
&& ! isKeypressTimeout() )
{
return fc::Fkey_incomplete;
return FKey::Incomplete;
}
for (n = len; n < FIFO_BUF_SIZE; n++) // Remove founded entry
@ -367,7 +367,7 @@ inline FKey FKeyboard::getSingleKey()
len = 4;
if ( buf_len < len && ! isKeypressTimeout() )
return fc::Fkey_incomplete;
return FKey::Incomplete;
for (std::size_t i{0}; i < len ; i++)
utf8char[i] = char(fifo_buf[i] & 0xff);
@ -375,7 +375,7 @@ inline FKey FKeyboard::getSingleKey()
keycode = UTF8decode(utf8char.data());
}
else
keycode = uChar(fifo_buf[0] & 0xff);
keycode = FKey(fifo_buf[0] & 0xff);
for (n = len; n < FIFO_BUF_SIZE; n++) // Remove the key from the buffer front
fifo_buf[n - len] = fifo_buf[n];
@ -385,10 +385,10 @@ inline FKey FKeyboard::getSingleKey()
unprocessed_buffer_data = bool(fifo_buf[0] != '\0');
if ( keycode == 0 ) // Ctrl+Space or Ctrl+@
keycode = fc::Fckey_space;
if ( keycode == FKey(0) ) // Ctrl+Space or Ctrl+@
keycode = FKey::Ctrl_space;
return FKey(keycode == 127 ? fc::Fkey_backspace : keycode);
return FKey(keycode == FKey(127) ? FKey::Backspace : keycode);
}
//----------------------------------------------------------------------
@ -400,7 +400,7 @@ inline bool FKeyboard::isKeypressTimeout()
//----------------------------------------------------------------------
FKey FKeyboard::UTF8decode (const char utf8[]) const
{
FKey ucs{0}; // Universal coded character
FKey ucs{FKey::None}; // Universal coded character
constexpr std::size_t max = 4;
std::size_t len = std::strlen(utf8);
@ -414,27 +414,27 @@ FKey FKeyboard::UTF8decode (const char utf8[]) const
if ( (ch & 0xc0) == 0x80 )
{
// byte 2..4 = 10xxxxxx
ucs = (ucs << 6) | (ch & 0x3f);
ucs = (ucs << 6) | FKey(ch & 0x3f);
}
else if ( ch < 128 )
{
// byte 1 = 0xxxxxxx (1 byte mapping)
ucs = ch & 0xff;
ucs = FKey(ch & 0xff);
}
else if ( (ch & 0xe0) == 0xc0 )
{
// byte 1 = 110xxxxx (2 byte mapping)
ucs = ch & 0x1f;
ucs = FKey(ch & 0x1f);
}
else if ( (ch & 0xf0) == 0xe0 )
{
// byte 1 = 1110xxxx (3 byte mapping)
ucs = ch & 0x0f;
ucs = FKey(ch & 0x0f);
}
else if ( (ch & 0xf8) == 0xf0 )
{
// byte 1 = 11110xxx (4 byte mapping)
ucs = ch & 0x07;
ucs = FKey(ch & 0x07);
}
else
{
@ -475,14 +475,14 @@ void FKeyboard::parseKeyBuffer()
// Read the rest from the fifo buffer
while ( ! isKeypressTimeout()
&& fifo_offset > 0
&& fkey != fc::Fkey_incomplete )
&& fkey != FKey::Incomplete )
{
fkey = parseKeyString();
fkey = keyCorrection(fkey);
if ( fkey == fc::Fkey_mouse
|| fkey == fc::Fkey_extended_mouse
|| fkey == fc::Fkey_urxvt_mouse )
if ( fkey == FKey::X11mouse
|| fkey == FKey::Extended_mouse
|| fkey == FKey::Urxvt_mouse )
{
key = fkey;
mouseTracking();
@ -490,14 +490,14 @@ void FKeyboard::parseKeyBuffer()
break;
}
if ( fkey != fc::Fkey_incomplete )
if ( fkey != FKey::Incomplete )
{
fkey_queue.push(fkey);
fifo_offset = int(std::strlen(fifo_buf));
}
}
fkey = 0;
fkey = FKey::None;
if ( fkey_queue.size() >= MAX_QUEUE_SIZE )
break;
@ -521,13 +521,13 @@ FKey FKeyboard::parseKeyString()
if ( keycode != NOT_SET )
return keycode;
keycode = getMetaKey();
keycode = getKnownKey();
if ( keycode != NOT_SET )
return keycode;
if ( ! isKeypressTimeout() )
return fc::Fkey_incomplete;
return FKey::Incomplete;
}
return getSingleKey();
@ -572,11 +572,11 @@ void FKeyboard::substringKeyHandling()
unprocessed_buffer_data = false;
if ( fifo_buf[1] == 'O' )
fkey = fc::Fmkey_O;
fkey = FKey::Meta_O;
else if ( fifo_buf[1] == '[' )
fkey = fc::Fmkey_left_square_bracket;
fkey = FKey::Meta_left_square_bracket;
else
fkey = fc::Fmkey_right_square_bracket;
fkey = FKey::Meta_right_square_bracket;
fkey_queue.push(fkey);
}

View File

@ -69,7 +69,7 @@ FLabel& FLabel::operator = (const FString& s)
}
//----------------------------------------------------------------------
FLabel& FLabel::operator << (fc::SpecialCharacter c)
FLabel& FLabel::operator << (UniChar c)
{
setText(text + static_cast<wchar_t>(c));
return *this;
@ -105,12 +105,12 @@ void FLabel::setAccelWidget (FWidget* widget)
}
//----------------------------------------------------------------------
void FLabel::setAlignment (fc::text_alignment align)
void FLabel::setAlignment (Align align)
{
if ( align != fc::alignLeft
&& align != fc::alignCenter
&& align != fc::alignRight )
alignment = fc::alignLeft;
if ( align != Align::Left
&& align != Align::Center
&& align != Align::Right )
alignment = Align::Left;
else
alignment = align;
}
@ -165,7 +165,7 @@ void FLabel::hide()
//----------------------------------------------------------------------
void FLabel::onMouseDown (FMouseEvent* ev)
{
if ( ev->getButton() != fc::LeftButton )
if ( ev->getButton() != MouseButton::Left )
return;
if ( ! (isEnabled() && accel_widget) )
@ -173,21 +173,12 @@ void FLabel::onMouseDown (FMouseEvent* ev)
// send click to the parent widget
if ( auto parent = getParentWidget() )
{
const int b = ev->getButton();
const auto b = ev->getButton();
const auto& tp = ev->getTermPos();
const auto& p = parent->termToWidgetPos(tp);
try
{
const auto& _ev = \
std::make_shared<FMouseEvent>(fc::MouseDown_Event, p, tp, b);
FApplication::sendEvent (parent, _ev.get());
}
catch (const std::bad_alloc&)
{
badAllocOutput ("FMouseEvent");
return;
}
const auto& _ev = \
std::make_shared<FMouseEvent>(Event::MouseDown, p, tp, b);
FApplication::sendEvent (parent, _ev.get());
}
return;
@ -224,7 +215,7 @@ void FLabel::onAccel (FAccelEvent* ev)
accel_widget->setFocus();
focused_widget->redraw();
accel_widget->redraw();
FFocusEvent in (fc::FocusIn_Event);
FFocusEvent in (Event::FocusIn);
FApplication::sendEvent(accel_widget, &in);
if ( getStatusBar() )
@ -261,22 +252,22 @@ void FLabel::setHotkeyAccelerator()
std::size_t FLabel::getAlignOffset (const std::size_t length) const
{
const std::size_t width(getWidth());
assert ( alignment == fc::alignLeft
|| alignment == fc::alignCenter
|| alignment == fc::alignRight );
assert ( alignment == Align::Left
|| alignment == Align::Center
|| alignment == Align::Right );
switch ( alignment )
{
case fc::alignLeft:
case Align::Left:
return 0;
case fc::alignCenter:
case Align::Center:
if ( length < width )
return (width - length) / 2;
else
return 0;
case fc::alignRight:
case Align::Right:
if ( length < width )
return width - length;
else
@ -397,8 +388,8 @@ void FLabel::printLine (FString& line)
{
if ( ! std::iswprint(std::wint_t(line[z]))
&& ! FTerm::isNewFont()
&& ( line[z] < fc::NF_rev_left_arrow2
|| line[z] > fc::NF_check_mark ) )
&& ( line[z] < UniChar::NF_rev_left_arrow2
|| line[z] > UniChar::NF_check_mark ) )
{
line[z] = L' ';
}

View File

@ -75,7 +75,7 @@ FLineEdit& FLineEdit::operator = (const FString& s)
}
//----------------------------------------------------------------------
FLineEdit& FLineEdit::operator << (fc::SpecialCharacter c)
FLineEdit& FLineEdit::operator << (UniChar c)
{
setText(text + static_cast<wchar_t>(c));
return *this;
@ -117,8 +117,8 @@ bool FLineEdit::setFocus (bool enable)
bool FLineEdit::setShadow (bool enable)
{
if ( enable
&& FTerm::getEncoding() != fc::VT100
&& FTerm::getEncoding() != fc::ASCII )
&& FTerm::getEncoding() != Encoding::VT100
&& FTerm::getEncoding() != Encoding::ASCII )
{
setFlags().shadow = true;
setShadowSize(FSize{1, 1});
@ -296,65 +296,25 @@ void FLineEdit::onKeyPress (FKeyEvent* ev)
if ( isReadOnly() )
return;
const FKey key = ev->key();
const auto key = ev->key();
switch ( key )
if ( key_map.find(key) != key_map.end() )
{
case fc::Fkey_left:
cursorLeft();
ev->accept();
break;
case fc::Fkey_right:
cursorRight();
ev->accept();
break;
case fc::Fkey_home:
cursorHome();
ev->accept();
break;
case fc::Fkey_end:
cursorEnd();
ev->accept();
break;
case fc::Fkey_dc: // del key
deleteCurrentCharacter();
ev->accept();
break;
case fc::Fkey_erase:
case fc::Fkey_backspace:
deletePreviousCharacter();
ev->accept();
break;
case fc::Fkey_ic: // insert key
switchInsertMode();
ev->accept();
break;
case fc::Fkey_return:
case fc::Fkey_enter:
acceptInput();
ev->accept();
break;
case fc::Fkey_tab:
ev->ignore();
break;
default:
if ( keyInput(key) )
ev->accept();
key_map[key]();
ev->accept();
}
else if ( key == FKey::Tab )
{
ev->ignore();
}
else if ( keyInput(key) )
{
ev->accept();
}
// end of switch
if ( ev->isAccepted()
&& key != fc::Fkey_return
&& key != fc::Fkey_enter )
&& key != FKey::Return
&& key != FKey::Enter )
{
drawInputField();
forceTerminalUpdate();
@ -364,7 +324,7 @@ void FLineEdit::onKeyPress (FKeyEvent* ev)
//----------------------------------------------------------------------
void FLineEdit::onMouseDown (FMouseEvent* ev)
{
if ( ev->getButton() != fc::LeftButton || isReadOnly() )
if ( ev->getButton() != MouseButton::Left || isReadOnly() )
return;
if ( ! hasFocus() )
@ -404,10 +364,10 @@ void FLineEdit::onMouseDown (FMouseEvent* ev)
//----------------------------------------------------------------------
void FLineEdit::onMouseUp (FMouseEvent*)
{
if ( drag_scroll != FLineEdit::noScroll )
if ( drag_scroll != DragScrollMode::None )
{
delOwnTimers();
drag_scroll = FLineEdit::noScroll;
drag_scroll = DragScrollMode::None;
scroll_timer = false;
}
}
@ -415,7 +375,7 @@ void FLineEdit::onMouseUp (FMouseEvent*)
//----------------------------------------------------------------------
void FLineEdit::onMouseMove (FMouseEvent* ev)
{
if ( ev->getButton() != fc::LeftButton || isReadOnly() )
if ( ev->getButton() != MouseButton::Left || isReadOnly() )
return;
const std::size_t len = print_text.getLength();
@ -442,13 +402,13 @@ void FLineEdit::onMouseMove (FMouseEvent* ev)
{
scroll_timer = true;
addTimer(scroll_repeat);
drag_scroll = FLineEdit::scrollLeft;
drag_scroll = DragScrollMode::Leftward;
}
if ( text_offset == 0 )
{
delOwnTimers();
drag_scroll = FLineEdit::noScroll;
drag_scroll = DragScrollMode::None;
}
}
else if ( mouse_x >= int(getWidth()) )
@ -458,13 +418,13 @@ void FLineEdit::onMouseMove (FMouseEvent* ev)
{
scroll_timer = true;
addTimer(scroll_repeat);
drag_scroll = FLineEdit::scrollRight;
drag_scroll = DragScrollMode::Rightward;
}
if ( cursor_pos == len )
{
delOwnTimers();
drag_scroll = FLineEdit::noScroll;
drag_scroll = DragScrollMode::None;
}
}
else
@ -472,7 +432,7 @@ void FLineEdit::onMouseMove (FMouseEvent* ev)
// no dragging
delOwnTimers();
scroll_timer = false;
drag_scroll = FLineEdit::noScroll;
drag_scroll = DragScrollMode::None;
}
}
@ -494,42 +454,32 @@ void FLineEdit::onTimer (FTimerEvent*)
{
const auto len = print_text.getLength();
switch ( int(drag_scroll) )
if ( drag_scroll == DragScrollMode::Leftward )
{
case FLineEdit::noScroll:
if ( text_offset == 0 )
{
drag_scroll = DragScrollMode::None;
return;
}
case FLineEdit::scrollLeft:
if ( text_offset == 0 )
{
drag_scroll = FLineEdit::noScroll;
return;
}
text_offset--;
text_offset--;
if ( cursor_pos > 0 )
cursor_pos--;
}
else if ( drag_scroll == DragScrollMode::Rightward )
{
if ( text_offset == endPosToOffset(len).first )
{
drag_scroll = DragScrollMode::None;
return;
}
if ( cursor_pos > 0 )
cursor_pos--;
if ( text_offset < endPosToOffset(len).first )
text_offset++;
break;
case FLineEdit::scrollRight:
if ( text_offset == endPosToOffset(len).first )
{
drag_scroll = FLineEdit::noScroll;
return;
}
if ( text_offset < endPosToOffset(len).first )
text_offset++;
if ( cursor_pos < len )
cursor_pos++;
break;
default:
break;
if ( cursor_pos < len )
cursor_pos++;
}
adjustTextOffset();
@ -610,15 +560,15 @@ void FLineEdit::adjustLabel()
if ( hasHotkey() )
label_width--;
assert ( label_orientation == LabelOrientation::above
|| label_orientation == LabelOrientation::left );
assert ( label_orientation == LabelOrientation::Above
|| label_orientation == LabelOrientation::Left );
if ( label_orientation == LabelOrientation::above )
if ( label_orientation == LabelOrientation::Above )
{
label->setGeometry ( FPoint{w->getX(), w->getY() - 1}
, FSize{label_width, 1} );
}
else if ( label_orientation == LabelOrientation::left )
else if ( label_orientation == LabelOrientation::Left )
{
label->setGeometry ( FPoint{w->getX() - int(label_width) - 1, w->getY()}
, FSize{label_width, 1} );
@ -643,6 +593,7 @@ void FLineEdit::init()
label->setAccelWidget(this);
setShadow();
resetColors();
mapKeyFunctions();
if ( isReadOnly() )
unsetVisibleCursor();
@ -650,6 +601,21 @@ void FLineEdit::init()
setVisibleCursor();
}
//----------------------------------------------------------------------
inline void FLineEdit::mapKeyFunctions()
{
key_map[FKey::Left] = [this] { cursorLeft(); };
key_map[FKey::Right] = [this] { cursorRight(); };
key_map[FKey::Home] = [this] { cursorHome(); };
key_map[FKey::End] = [this] { cursorEnd(); };
key_map[FKey::Del_char] = [this] { deleteCurrentCharacter(); };
key_map[FKey::Erase] = [this] { deletePreviousCharacter(); };
key_map[FKey::Backspace] = [this] { deletePreviousCharacter(); };
key_map[FKey::Insert] = [this] { switchInsertMode(); };
key_map[FKey::Return] = [this] { acceptInput(); };
key_map[FKey::Enter] = [this] { acceptInput(); };
}
//----------------------------------------------------------------------
bool FLineEdit::hasHotkey() const
{
@ -710,15 +676,15 @@ void FLineEdit::drawInputField()
const std::size_t text_offset_column = [this] ()
{
assert ( input_type == InputType::textfield
|| input_type == InputType::password );
assert ( input_type == InputType::Textfield
|| input_type == InputType::Password );
switch ( input_type )
{
case InputType::textfield:
case InputType::Textfield:
return printTextField();
case InputType::password:
case InputType::Password:
return printPassword();
}
@ -773,7 +739,7 @@ inline std::size_t FLineEdit::printPassword()
const FString show_text{print_text.mid(1 + text_offset, getWidth() - 2)};
if ( ! show_text.isEmpty() )
print() << FString{show_text.getLength(), fc::Bullet}; // •
print() << FString{show_text.getLength(), UniChar::Bullet}; // •
x_pos = show_text.getLength();
return text_offset_column;
@ -782,11 +748,11 @@ inline std::size_t FLineEdit::printPassword()
//----------------------------------------------------------------------
inline std::size_t FLineEdit::getCursorColumnPos() const
{
if ( input_type == InputType::textfield )
if ( input_type == InputType::Textfield )
{
return getColumnWidth (print_text, cursor_pos);
}
else if ( input_type == InputType::password )
else if ( input_type == InputType::Password )
{
return cursor_pos;
}
@ -797,13 +763,13 @@ inline std::size_t FLineEdit::getCursorColumnPos() const
//----------------------------------------------------------------------
inline FString FLineEdit::getPasswordText() const
{
return FString{text.getLength(), fc::Bullet}; // •
return FString{text.getLength(), UniChar::Bullet}; // •
}
//----------------------------------------------------------------------
inline bool FLineEdit::isPasswordField() const
{
return bool( input_type == InputType::password );
return bool( input_type == InputType::Password );
}
//----------------------------------------------------------------------

View File

@ -124,12 +124,12 @@ void FListBox::setCurrentItem (FListBoxItems::iterator iter)
//----------------------------------------------------------------------
void FListBox::showInsideBrackets ( const std::size_t index
, fc::brackets_type b )
, BracketType b )
{
auto iter = index2iterator(index - 1);
iter->brackets = b;
if ( b == fc::NoBrackets )
if ( b == BracketType::None )
return;
const auto column_width = getColumnWidth(iter->getText()) + 2;
@ -185,7 +185,7 @@ void FListBox::hide()
void FListBox::insert (const FListBoxItem& listItem)
{
const std::size_t column_width = getColumnWidth(listItem.text);
const bool has_brackets(listItem.brackets);
const bool has_brackets(listItem.brackets != BracketType::None);
recalculateHorizontalBar (column_width, has_brackets);
itemlist.push_back (listItem);
@ -304,13 +304,13 @@ void FListBox::onKeyPress (FKeyEvent* ev)
//----------------------------------------------------------------------
void FListBox::onMouseDown (FMouseEvent* ev)
{
if ( ev->getButton() != fc::LeftButton
&& ev->getButton() != fc::RightButton )
if ( ev->getButton() != MouseButton::Left
&& ev->getButton() != MouseButton::Right )
{
return;
}
if ( ev->getButton() == fc::RightButton && ! isMultiSelection() )
if ( ev->getButton() == MouseButton::Right && ! isMultiSelection() )
return;
getWidgetFocus();
@ -332,7 +332,7 @@ void FListBox::onMouseDown (FMouseEvent* ev)
inc_search.clear();
if ( ev->getButton() == fc::RightButton )
if ( ev->getButton() == MouseButton::Right )
multiSelection(current);
if ( current_before != current )
@ -357,10 +357,10 @@ void FListBox::onMouseUp (FMouseEvent* ev)
{
click_on_list = false;
if ( drag_scroll != fc::noScroll )
if ( drag_scroll != DragScrollMode::None )
stopDragScroll();
if ( ev->getButton() == fc::LeftButton )
if ( ev->getButton() == MouseButton::Left )
{
const int mouse_x = ev->getX();
const int mouse_y = ev->getY();
@ -377,11 +377,11 @@ void FListBox::onMouseUp (FMouseEvent* ev)
//----------------------------------------------------------------------
void FListBox::onMouseMove (FMouseEvent* ev)
{
if ( ev->getButton() != fc::LeftButton
&& ev->getButton() != fc::RightButton )
if ( ev->getButton() != MouseButton::Left
&& ev->getButton() != MouseButton::Right )
return;
if ( ev->getButton() == fc::RightButton && ! isMultiSelection() )
if ( ev->getButton() == MouseButton::Right && ! isMultiSelection() )
return;
const std::size_t current_before = current;
@ -404,12 +404,12 @@ void FListBox::onMouseMove (FMouseEvent* ev)
if ( current_before != current )
{
// Handle multiple selections + changes
if ( ev->getButton() == fc::RightButton)
if ( ev->getButton() == MouseButton::Right )
{
processChanged();
multiSelectionUpTo(current);
}
else if ( ev->getButton() == fc::LeftButton)
else if ( ev->getButton() == MouseButton::Left )
processChanged();
}
@ -436,7 +436,7 @@ void FListBox::onMouseMove (FMouseEvent* ev)
//----------------------------------------------------------------------
void FListBox::onMouseDoubleClick (FMouseEvent* ev)
{
if ( ev->getButton() != fc::LeftButton )
if ( ev->getButton() != MouseButton::Left )
return;
const int mouse_x = ev->getX();
@ -458,25 +458,17 @@ void FListBox::onTimer (FTimerEvent*)
const std::size_t current_before = current;
const int yoffset_before = yoffset;
switch ( int(drag_scroll) )
if ( ( drag_scroll == DragScrollMode::Upward
|| drag_scroll == DragScrollMode::SelectUpward )
&& ! dragScrollUp() )
{
case fc::noScroll:
return;
case fc::scrollUp:
case fc::scrollUpSelect:
if ( ! dragScrollUp() )
return;
break;
case fc::scrollDown:
case fc::scrollDownSelect:
if ( ! dragScrollDown() )
return;
break;
default:
break;
return;
}
else if ( ( drag_scroll == DragScrollMode::Downward
|| drag_scroll == DragScrollMode::SelectDownward )
&& ! dragScrollDown() )
{
return;
}
if ( current_before != current )
@ -485,8 +477,8 @@ void FListBox::onTimer (FTimerEvent*)
processChanged();
// Handle multiple selections
if ( drag_scroll == fc::scrollUpSelect
|| drag_scroll == fc::scrollDownSelect )
if ( drag_scroll == DragScrollMode::SelectUpward
|| drag_scroll == DragScrollMode::SelectDownward )
multiSelectionUpTo(current);
}
@ -507,24 +499,15 @@ void FListBox::onWheel (FWheelEvent* ev)
const std::size_t current_before = current;
const int yoffset_before = yoffset;
static constexpr int wheel_distance = 4;
const int wheel = ev->getWheel();
const MouseWheel wheel = ev->getWheel();
if ( drag_scroll != fc::noScroll )
if ( drag_scroll != DragScrollMode::None )
stopDragScroll();
switch ( wheel )
{
case fc::WheelUp:
wheelUp (wheel_distance);
break;
case fc::WheelDown:
wheelDown (wheel_distance);
break;
default:
break;
}
if ( wheel == MouseWheel::Up )
wheelUp (wheel_distance);
else if ( wheel == MouseWheel::Down )
wheelDown (wheel_distance);
if ( current_before != current )
{
@ -641,8 +624,8 @@ inline FString FListBox::getString (FListBoxItems::iterator iter)
//----------------------------------------------------------------------
void FListBox::init()
{
initScrollbar (vbar, fc::vertical, this, &FListBox::cb_vbarChange);
initScrollbar (hbar, fc::horizontal, this, &FListBox::cb_hbarChange);
initScrollbar (vbar, Orientation::Vertical, this, &FListBox::cb_vbarChange);
initScrollbar (hbar, Orientation::Horizontal, this, &FListBox::cb_hbarChange);
setGeometry (FPoint{1, 1}, FSize{5, 4}, false); // initialize geometry values
nf_offset = FTerm::isNewFont() ? 1 : 0;
setTopPadding(1);
@ -655,36 +638,28 @@ void FListBox::init()
//----------------------------------------------------------------------
inline void FListBox::mapKeyFunctions()
{
key_map[fc::Fkey_return] = std::bind(&FListBox::acceptSelection, this);
key_map[fc::Fkey_enter] = std::bind(&FListBox::acceptSelection, this);
key_map[fc::Fkey_up] = std::bind(&FListBox::onePosUp, this);
key_map[fc::Fkey_down] = std::bind(&FListBox::onePosDown, this);
auto left = static_cast<void(FListBox::*)()>(&FListBox::scrollLeft);
key_map[fc::Fkey_left] = std::bind(left, this);
auto right = static_cast<void(FListBox::*)()>(&FListBox::scrollRight);
key_map[fc::Fkey_right] = std::bind(right, this);
key_map[fc::Fkey_ppage] = std::bind(&FListBox::onePageUp, this);
key_map[fc::Fkey_npage] = std::bind(&FListBox::onePageDown, this);
key_map[fc::Fkey_home] = std::bind(&FListBox::firstPos, this);
key_map[fc::Fkey_end] = std::bind(&FListBox::lastPos, this);
key_map_result[fc::Fkey_ic] = \
std::bind(&FListBox::changeSelectionAndPosition, this);
key_map_result[fc::Fkey_space] = \
std::bind(&FListBox::spacebarProcessing, this);
key_map_result[fc::Fkey_erase] = \
std::bind(&FListBox::deletePreviousCharacter, this);
key_map_result[fc::Fkey_backspace] = \
std::bind(&FListBox::deletePreviousCharacter, this);
key_map_result[fc::Fkey_escape] = \
std::bind(&FListBox::skipIncrementalSearch, this);
key_map_result[fc::Fkey_escape_mintty] = \
std::bind(&FListBox::skipIncrementalSearch, this);
key_map[FKey::Return] = [this] { acceptSelection(); };
key_map[FKey::Enter] = [this] { acceptSelection(); };
key_map[FKey::Up] = [this] { onePosUp(); };
key_map[FKey::Down] = [this] { onePosDown(); };
key_map[FKey::Left] = [this] { scrollLeft(); };
key_map[FKey::Right] = [this] { scrollRight(); };
key_map[FKey::Page_up] = [this] { onePageUp(); };
key_map[FKey::Page_down] = [this] { onePageDown(); };
key_map[FKey::Home] = [this] { firstPos(); };
key_map[FKey::End] = [this] { lastPos(); };
key_map_result[FKey::Insert] = [this] { return changeSelectionAndPosition(); };
key_map_result[FKey::Space] = [this] { return spacebarProcessing(); };
key_map_result[FKey::Erase] = [this] { return deletePreviousCharacter(); };
key_map_result[FKey::Backspace] = [this] { return deletePreviousCharacter(); };
key_map_result[FKey::Escape] = [this] { return skipIncrementalSearch(); };
key_map_result[FKey::Escape_mintty] = [this] { return skipIncrementalSearch(); };
}
//----------------------------------------------------------------------
void FListBox::processKeyAction (FKeyEvent* ev)
{
const auto idx = int(ev->key());
const auto idx = ev->key();
if ( key_map.find(idx) != key_map.end() )
{
@ -864,7 +839,7 @@ inline void FListBox::drawListLine ( int y
std::size_t column_width = getColumnWidth(element);
if ( FTerm::isMonochron() && isCurrentLine && getFlags().focus )
print (fc::BlackRightPointingPointer); // ►
print (UniChar::BlackRightPointingPointer); // ►
else
print (' ');
@ -883,7 +858,7 @@ inline void FListBox::drawListLine ( int y
if ( FTerm::isMonochron() && isCurrentLine && getFlags().focus )
{
print (fc::BlackLeftPointingPointer); // ◄
print (UniChar::BlackLeftPointingPointer); // ◄
column_width++;
}
@ -892,17 +867,17 @@ inline void FListBox::drawListLine ( int y
}
//----------------------------------------------------------------------
inline void FListBox::printLeftBracket (fc::brackets_type bracket_type)
inline void FListBox::printLeftBracket (BracketType bracket_type)
{
if ( bracket_type != fc::NoBrackets )
print ("\0[({<"[bracket_type]);
if ( bracket_type != BracketType::None )
print ("\0[({<"[std::size_t(bracket_type)]);
}
//----------------------------------------------------------------------
inline void FListBox::printRightBracket (fc::brackets_type bracket_type)
inline void FListBox::printRightBracket (BracketType bracket_type)
{
if ( bracket_type != fc::NoBrackets )
print ("\0])}>"[bracket_type]);
if ( bracket_type != BracketType::None )
print ("\0])}>"[std::size_t(bracket_type)]);
}
//----------------------------------------------------------------------
@ -915,7 +890,7 @@ inline void FListBox::drawListBracketsLine ( int y
const bool isCurrentLine( y + yoffset + 1 == int(current) );
if ( FTerm::isMonochron() && isCurrentLine && getFlags().focus )
print (fc::BlackRightPointingPointer); // ►
print (UniChar::BlackRightPointingPointer); // ►
else
print (' ');
@ -959,7 +934,7 @@ inline void FListBox::drawListBracketsLine ( int y
if ( FTerm::isMonochron() && isCurrentLine && getFlags().focus )
{
print (fc::BlackLeftPointingPointer); // ◄
print (UniChar::BlackLeftPointingPointer); // ◄
column_width++;
}
@ -1251,7 +1226,7 @@ bool FListBox::dragScrollUp()
{
if ( current == 1 )
{
drag_scroll = fc::noScroll;
drag_scroll = DragScrollMode::None;
return false;
}
@ -1266,7 +1241,7 @@ bool FListBox::dragScrollDown()
if ( current == element_count )
{
drag_scroll = fc::noScroll;
drag_scroll = DragScrollMode::None;
return false;
}
@ -1275,9 +1250,9 @@ bool FListBox::dragScrollDown()
}
//----------------------------------------------------------------------
void FListBox::dragUp (int mouse_button)
void FListBox::dragUp (MouseButton mouse_button)
{
if ( drag_scroll != fc::noScroll
if ( drag_scroll != DragScrollMode::None
&& scroll_distance < int(getClientHeight()) )
scroll_distance++;
@ -1286,23 +1261,23 @@ void FListBox::dragUp (int mouse_button)
scroll_timer = true;
addTimer(scroll_repeat);
if ( mouse_button == fc::RightButton )
drag_scroll = fc::scrollUpSelect;
if ( mouse_button == MouseButton::Right )
drag_scroll = DragScrollMode::SelectUpward;
else
drag_scroll = fc::scrollUp;
drag_scroll = DragScrollMode::Upward;
}
if ( current == 1 )
{
delOwnTimers();
drag_scroll = fc::noScroll;
drag_scroll = DragScrollMode::None;
}
}
//----------------------------------------------------------------------
void FListBox::dragDown (int mouse_button)
void FListBox::dragDown (MouseButton mouse_button)
{
if ( drag_scroll != fc::noScroll
if ( drag_scroll != DragScrollMode::None
&& scroll_distance < int(getClientHeight()) )
scroll_distance++;
@ -1311,16 +1286,16 @@ void FListBox::dragDown (int mouse_button)
scroll_timer = true;
addTimer(scroll_repeat);
if ( mouse_button == fc::RightButton )
drag_scroll = fc::scrollDownSelect;
if ( mouse_button == MouseButton::Right )
drag_scroll = DragScrollMode::SelectDownward;
else
drag_scroll = fc::scrollDown;
drag_scroll = DragScrollMode::Downward;
}
if ( current == getCount() )
{
delOwnTimers();
drag_scroll = fc::noScroll;
drag_scroll = DragScrollMode::None;
}
}
@ -1328,7 +1303,7 @@ void FListBox::dragDown (int mouse_button)
void FListBox::stopDragScroll()
{
delOwnTimers();
drag_scroll = fc::noScroll;
drag_scroll = DragScrollMode::None;
scroll_distance = 1;
scroll_timer = false;
}
@ -1717,7 +1692,7 @@ void FListBox::changeOnResize() const
//----------------------------------------------------------------------
void FListBox::lazyConvert(FListBoxItems::iterator iter, std::size_t y)
{
if ( conv_type != lazy_convert || ! iter->getText().isNull() )
if ( conv_type != ConvertType::Lazy || ! iter->getText().isNull() )
return;
lazy_inserter (*iter, source_container, y + std::size_t(yoffset));
@ -1731,49 +1706,48 @@ void FListBox::lazyConvert(FListBoxItems::iterator iter, std::size_t y)
//----------------------------------------------------------------------
void FListBox::cb_vbarChange (const FWidget*)
{
FScrollbar::SType scrollType;
const std::size_t current_before = current;
const FScrollbar::ScrollType scrollType = vbar->getScrollType();
static constexpr int wheel_distance = 4;
const std::size_t current_before = current;
int distance{1};
const int yoffset_before = yoffset;
scrollType = vbar->getScrollType();
assert ( scrollType == FScrollbar::SType::noScroll
|| scrollType == FScrollbar::SType::scrollJump
|| scrollType == FScrollbar::SType::scrollStepBackward
|| scrollType == FScrollbar::SType::scrollStepForward
|| scrollType == FScrollbar::SType::scrollPageBackward
|| scrollType == FScrollbar::SType::scrollPageForward
|| scrollType == FScrollbar::SType::scrollWheelUp
|| scrollType == FScrollbar::SType::scrollWheelDown );
assert ( scrollType == FScrollbar::ScrollType::None
|| scrollType == FScrollbar::ScrollType::Jump
|| scrollType == FScrollbar::ScrollType::StepBackward
|| scrollType == FScrollbar::ScrollType::StepForward
|| scrollType == FScrollbar::ScrollType::PageBackward
|| scrollType == FScrollbar::ScrollType::PageForward
|| scrollType == FScrollbar::ScrollType::WheelUp
|| scrollType == FScrollbar::ScrollType::WheelDown );
switch ( scrollType )
{
case FScrollbar::SType::noScroll:
case FScrollbar::ScrollType::None:
break;
case FScrollbar::SType::scrollPageBackward:
case FScrollbar::ScrollType::PageBackward:
distance = int(getClientHeight());
// fall through
case FScrollbar::SType::scrollStepBackward:
case FScrollbar::ScrollType::StepBackward:
prevListItem (distance);
break;
case FScrollbar::SType::scrollPageForward:
case FScrollbar::ScrollType::PageForward:
distance = int(getClientHeight());
// fall through
case FScrollbar::SType::scrollStepForward:
case FScrollbar::ScrollType::StepForward:
nextListItem (distance);
break;
case FScrollbar::SType::scrollJump:
case FScrollbar::ScrollType::Jump:
scrollToY (vbar->getValue());
break;
case FScrollbar::SType::scrollWheelUp:
case FScrollbar::ScrollType::WheelUp:
wheelUp (wheel_distance);
break;
case FScrollbar::SType::scrollWheelDown:
case FScrollbar::ScrollType::WheelDown:
wheelDown (wheel_distance);
break;
}
@ -1787,7 +1761,7 @@ void FListBox::cb_vbarChange (const FWidget*)
if ( isShown() )
drawList();
if ( scrollType >= FScrollbar::SType::scrollStepBackward )
if ( scrollType >= FScrollbar::ScrollType::StepBackward )
{
vbar->setValue (yoffset);
@ -1801,49 +1775,49 @@ void FListBox::cb_vbarChange (const FWidget*)
//----------------------------------------------------------------------
void FListBox::cb_hbarChange (const FWidget*)
{
static constexpr int padding_space = 2; // 1 leading space + 1 trailing space
const FScrollbar::ScrollType scrollType = hbar->getScrollType();
static constexpr int wheel_distance = 4;
FScrollbar::SType scrollType;
static constexpr int padding_space = 2; // 1 leading space + 1 trailing space
int distance{1};
const int xoffset_before = xoffset;
scrollType = hbar->getScrollType();
assert ( scrollType == FScrollbar::SType::noScroll
|| scrollType == FScrollbar::SType::scrollJump
|| scrollType == FScrollbar::SType::scrollStepBackward
|| scrollType == FScrollbar::SType::scrollStepForward
|| scrollType == FScrollbar::SType::scrollPageBackward
|| scrollType == FScrollbar::SType::scrollPageForward
|| scrollType == FScrollbar::SType::scrollWheelUp
|| scrollType == FScrollbar::SType::scrollWheelDown );
assert ( scrollType == FScrollbar::ScrollType::None
|| scrollType == FScrollbar::ScrollType::Jump
|| scrollType == FScrollbar::ScrollType::StepBackward
|| scrollType == FScrollbar::ScrollType::StepForward
|| scrollType == FScrollbar::ScrollType::PageBackward
|| scrollType == FScrollbar::ScrollType::PageForward
|| scrollType == FScrollbar::ScrollType::WheelUp
|| scrollType == FScrollbar::ScrollType::WheelDown );
switch ( scrollType )
{
case FScrollbar::SType::noScroll:
case FScrollbar::ScrollType::None:
break;
case FScrollbar::SType::scrollPageBackward:
case FScrollbar::ScrollType::PageBackward:
distance = int(getClientWidth()) - padding_space;
// fall through
case FScrollbar::SType::scrollStepBackward:
case FScrollbar::ScrollType::StepBackward:
scrollLeft (distance);
break;
case FScrollbar::SType::scrollPageForward:
case FScrollbar::ScrollType::PageForward:
distance = int(getClientWidth()) - padding_space;
// fall through
case FScrollbar::SType::scrollStepForward:
case FScrollbar::ScrollType::StepForward:
scrollRight (distance);
break;
case FScrollbar::SType::scrollJump:
case FScrollbar::ScrollType::Jump:
scrollToX (hbar->getValue());
break;
case FScrollbar::SType::scrollWheelUp:
case FScrollbar::ScrollType::WheelUp:
scrollLeft (wheel_distance);
break;
case FScrollbar::SType::scrollWheelDown:
case FScrollbar::ScrollType::WheelDown:
scrollRight (wheel_distance);
break;
}
@ -1855,7 +1829,7 @@ void FListBox::cb_hbarChange (const FWidget*)
drawList();
if ( scrollType >= FScrollbar::SType::scrollStepBackward )
if ( scrollType >= FScrollbar::ScrollType::StepBackward )
{
hbar->setValue (xoffset);

View File

@ -651,12 +651,12 @@ std::size_t FListView::getCount() const
}
//----------------------------------------------------------------------
fc::text_alignment FListView::getColumnAlignment (int column) const
Align FListView::getColumnAlignment (int column) const
{
// Get the alignment for a column
if ( column < 1 || header.empty() || column > int(header.size()) )
return fc::alignLeft;
return Align::Left;
// Convert column position to address offset (index)
const auto index = std::size_t(column - 1);
@ -677,21 +677,21 @@ FString FListView::getColumnText (int column) const
}
//----------------------------------------------------------------------
fc::sorting_type FListView::getColumnSortType (int column) const
SortType FListView::getColumnSortType (int column) const
{
fc::sorting_type type;
SortType s_type;
const auto col = std::size_t(column);
try
{
type = sort_type.at(col);
s_type = sort_type.at(col);
}
catch (const std::out_of_range&)
{
type = fc::unknown;
s_type = SortType::Unknown;
}
return type;
return s_type;
}
//----------------------------------------------------------------------
@ -710,7 +710,7 @@ void FListView::setGeometry ( const FPoint& pos, const FSize& size
}
//----------------------------------------------------------------------
void FListView::setColumnAlignment (int column, fc::text_alignment align)
void FListView::setColumnAlignment (int column, Align align)
{
// Set the alignment for a column
@ -745,7 +745,7 @@ void FListView::setColumnText (int column, const FString& label)
}
//----------------------------------------------------------------------
void FListView::setColumnSortType (int column, fc::sorting_type type)
void FListView::setColumnSortType (int column, SortType type)
{
// Sets the sort type by which the list is to be sorted
@ -761,7 +761,7 @@ void FListView::setColumnSortType (int column, fc::sorting_type type)
}
//----------------------------------------------------------------------
void FListView::setColumnSort (int column, fc::sorting_order order)
void FListView::setColumnSort (int column, SortOrder order)
{
// Sets the column to sort by + the sorting order
@ -929,43 +929,43 @@ void FListView::sort()
if ( sort_column < 1 && sort_column > int(header.size()) )
return;
fc::sorting_type column_sort_type = getColumnSortType(sort_column);
assert ( column_sort_type == fc::by_name
|| column_sort_type == fc::by_number
|| column_sort_type == fc::user_defined
|| column_sort_type == fc::unknown );
SortType column_sort_type = getColumnSortType(sort_column);
assert ( column_sort_type == SortType::Name
|| column_sort_type == SortType::Number
|| column_sort_type == SortType::UserDefined
|| column_sort_type == SortType::Unknown );
switch ( column_sort_type )
{
case fc::unknown:
case fc::by_name:
if ( sort_order == fc::ascending )
case SortType::Unknown:
case SortType::Name:
if ( sort_order == SortOrder::Ascending )
{
sort (sortAscendingByName);
}
else if ( sort_order == fc::descending )
else if ( sort_order == SortOrder::Descending )
{
sort (sortDescendingByName);
}
break;
case fc::by_number:
if ( sort_order == fc::ascending )
case SortType::Number:
if ( sort_order == SortOrder::Ascending )
{
sort (sortAscendingByNumber);
}
else if ( sort_order == fc::descending )
else if ( sort_order == SortOrder::Descending )
{
sort (sortDescendingByNumber);
}
break;
case fc::user_defined:
if ( sort_order == fc::ascending && user_defined_ascending )
case SortType::UserDefined:
if ( sort_order == SortOrder::Ascending && user_defined_ascending )
{
sort (user_defined_ascending);
}
else if ( sort_order == fc::descending && user_defined_descending )
else if ( sort_order == SortOrder::Descending && user_defined_descending )
{
sort (user_defined_descending);
}
@ -1000,7 +1000,7 @@ void FListView::onKeyPress (FKeyEvent* ev)
//----------------------------------------------------------------------
void FListView::onMouseDown (FMouseEvent* ev)
{
if ( ev->getButton() != fc::LeftButton )
if ( ev->getButton() != MouseButton::Left )
{
clicked_expander_pos.setPoint(-1, -1);
return;
@ -1078,10 +1078,10 @@ void FListView::onMouseDown (FMouseEvent* ev)
//----------------------------------------------------------------------
void FListView::onMouseUp (FMouseEvent* ev)
{
if ( drag_scroll != fc::noScroll )
if ( drag_scroll != DragScrollMode::None )
stopDragScroll();
if ( ev->getButton() == fc::LeftButton )
if ( ev->getButton() == MouseButton::Left )
{
const int mouse_x = ev->getX();
const int mouse_y = ev->getY();
@ -1148,7 +1148,7 @@ void FListView::onMouseUp (FMouseEvent* ev)
//----------------------------------------------------------------------
void FListView::onMouseMove (FMouseEvent* ev)
{
if ( ev->getButton() != fc::LeftButton )
if ( ev->getButton() != MouseButton::Left )
{
clicked_expander_pos.setPoint(-1, -1);
return;
@ -1189,7 +1189,7 @@ void FListView::onMouseMove (FMouseEvent* ev)
//----------------------------------------------------------------------
void FListView::onMouseDoubleClick (FMouseEvent* ev)
{
if ( ev->getButton() != fc::LeftButton )
if ( ev->getButton() != MouseButton::Left )
return;
const int mouse_x = ev->getX();
@ -1231,25 +1231,17 @@ void FListView::onTimer (FTimerEvent*)
const int position_before = current_iter.getPosition();
first_line_position_before = first_visible_line.getPosition();
switch ( int(drag_scroll) )
if ( ( drag_scroll == DragScrollMode::Upward
|| drag_scroll == DragScrollMode::SelectUpward )
&& ! dragScrollUp(position_before) )
{
case fc::noScroll:
return;
case fc::scrollUp:
case fc::scrollUpSelect:
if ( ! dragScrollUp(position_before) )
return;
break;
case fc::scrollDown:
case fc::scrollDownSelect:
if ( ! dragScrollDown(position_before) )
return;
break;
default:
break;
return;
}
else if ( ( drag_scroll == DragScrollMode::Downward
|| drag_scroll == DragScrollMode::SelectDownward )
&& ! dragScrollDown(position_before) )
{
return;
}
if ( isShown() )
@ -1270,22 +1262,13 @@ void FListView::onWheel (FWheelEvent* ev)
static constexpr int wheel_distance = 4;
first_line_position_before = first_visible_line.getPosition();
if ( drag_scroll != fc::noScroll )
if ( drag_scroll != DragScrollMode::None )
stopDragScroll();
switch ( ev->getWheel() )
{
case fc::WheelUp:
wheelUp (wheel_distance);
break;
case fc::WheelDown:
wheelDown (wheel_distance);
break;
default:
break;
}
if ( ev->getWheel() == MouseWheel::Up )
wheelUp (wheel_distance);
else if ( ev->getWheel() == MouseWheel::Down )
wheelDown (wheel_distance);
if ( position_before != current_iter.getPosition() )
processChanged();
@ -1426,8 +1409,8 @@ void FListView::setNullIterator (const iterator& null_iter)
//----------------------------------------------------------------------
void FListView::init()
{
initScrollbar (vbar, fc::vertical, this, &FListView::cb_vbarChange);
initScrollbar (hbar, fc::horizontal, this, &FListView::cb_hbarChange);
initScrollbar (vbar, Orientation::Vertical, this, &FListView::cb_vbarChange);
initScrollbar (hbar, Orientation::Horizontal, this, &FListView::cb_hbarChange);
selflist.push_back(this);
root = selflist.begin();
getNullIterator() = selflist.end();
@ -1443,25 +1426,25 @@ void FListView::init()
//----------------------------------------------------------------------
inline void FListView::mapKeyFunctions()
{
key_map[fc::Fkey_return] = std::bind(&FListView::processClick, this);
key_map[fc::Fkey_enter] = std::bind(&FListView::processClick, this);
key_map[fc::Fkey_space] = std::bind(&FListView::toggleCheckbox, this);
key_map[fc::Fkey_up] = [this] { stepBackward(); };
key_map[fc::Fkey_down] = [this] { stepForward(); };
key_map[fc::Fkey_left] = std::bind(&FListView::collapseAndScrollLeft, this);
key_map[fc::Fkey_right] = std::bind(&FListView::expandAndScrollRight, this);
key_map[fc::Fkey_ppage] = [this] { stepBackward(int(getClientHeight()) - 1); };
key_map[fc::Fkey_npage] = [this] { stepForward(int(getClientHeight()) - 1); };
key_map[fc::Fkey_home] = std::bind(&FListView::firstPos, this);
key_map[fc::Fkey_end] = std::bind(&FListView::lastPos, this);
key_map_result[FKey('+')] = std::bind(&FListView::expandSubtree, this);
key_map_result[FKey('-')] = std::bind(&FListView::collapseSubtree, this);
key_map[FKey::Return] = [this] { processClick(); };
key_map[FKey::Enter] = [this] { processClick(); };
key_map[FKey::Space] = [this] { toggleCheckbox(); };
key_map[FKey::Up] = [this] { stepBackward(); };
key_map[FKey::Down] = [this] { stepForward(); };
key_map[FKey::Left] = [this] { collapseAndScrollLeft(); };
key_map[FKey::Right] = [this] { expandAndScrollRight(); };
key_map[FKey::Page_up] = [this] { stepBackward(int(getClientHeight()) - 1); };
key_map[FKey::Page_down] = [this] { stepForward(int(getClientHeight()) - 1); };
key_map[FKey::Home] = [this] { firstPos(); };
key_map[FKey::End] = [this] { lastPos(); };
key_map_result[FKey('+')] = [this] { return expandSubtree(); };
key_map_result[FKey('-')] = [this] { return collapseSubtree(); };
}
//----------------------------------------------------------------------
void FListView::processKeyAction (FKeyEvent* ev)
{
const auto idx = int(ev->key());
const auto idx = ev->key();
if ( key_map.find(idx) != key_map.end() )
{
@ -1492,26 +1475,26 @@ void FListView::sort (Compare cmp)
}
//----------------------------------------------------------------------
std::size_t FListView::getAlignOffset ( const fc::text_alignment align
std::size_t FListView::getAlignOffset ( const Align align
, const std::size_t column_width
, const std::size_t width ) const
{
assert ( align == fc::alignLeft
|| align == fc::alignCenter
|| align == fc::alignRight );
assert ( align == Align::Left
|| align == Align::Center
|| align == Align::Right );
switch ( align )
{
case fc::alignLeft:
case Align::Left:
return 0;
case fc::alignCenter:
case Align::Center:
if ( column_width < width )
return (width - column_width) / 2;
else
return 0;
case fc::alignRight:
case Align::Right:
if ( column_width < width )
return width - column_width;
else
@ -1715,7 +1698,7 @@ void FListView::drawListLine ( const FListViewItem* item
// Increment the value of col for the column position
// and the next iteration
col++;
const fc::text_alignment align = getColumnAlignment(int(col));
const Align align = getColumnAlignment(int(col));
const std::size_t align_offset = getAlignOffset (align, column_width, width);
if ( tree_view && col == 1 )
@ -1738,7 +1721,7 @@ void FListView::drawListLine ( const FListViewItem* item
line += FString { leading_space + width
- align_offset - column_width, L' '};
}
else if ( align == fc::alignRight )
else if ( align == Align::Right )
{
// Ellipse right align text
const std::size_t first = getColumnWidth(text) + 1 - width;
@ -1853,7 +1836,7 @@ inline FString FListView::getCheckBox (const FListViewItem* item) const
{
try
{
checkbox[1] = fc::Times; // Times ×
checkbox[1] = wchar_t(UniChar::Times); // Times ×
}
catch (const std::out_of_range&)
{
@ -1880,12 +1863,12 @@ inline FString FListView::getLinePrefix ( const FListViewItem* item
{
if ( item->isExpand() )
{
line += fc::BlackDownPointingTriangle; // ▼
line += UniChar::BlackDownPointingTriangle; // ▼
line += L' ';
}
else
{
line += fc::BlackRightPointingPointer; // ►
line += UniChar::BlackRightPointingPointer; // ►
line += L' ';
}
}
@ -1911,10 +1894,10 @@ inline void FListView::drawSortIndicator ( std::size_t& length
setColor();
length++;
if ( sort_order == fc::ascending )
headerline << fc::BlackUpPointingTriangle; // ▲
else if ( sort_order == fc::descending )
headerline << fc::BlackDownPointingTriangle; // ▼
if ( sort_order == SortOrder::Ascending )
headerline << UniChar::BlackUpPointingTriangle; // ▲
else if ( sort_order == SortOrder::Descending )
headerline << UniChar::BlackDownPointingTriangle; // ▼
if ( length < column_max )
{
@ -1927,7 +1910,7 @@ inline void FListView::drawSortIndicator ( std::size_t& length
inline void FListView::drawHeaderBorder (std::size_t length)
{
setColor();
const FString line {length, fc::BoxDrawingsHorizontal};
const FString line {length, UniChar::BoxDrawingsHorizontal};
headerline << line; // horizontal line
}
@ -2053,17 +2036,17 @@ void FListView::drawBufferedHeadline()
print() << FPoint{2, 1};
if ( left_truncated_fullwidth )
print (fc::SingleLeftAngleQuotationMark); //
print (UniChar::SingleLeftAngleQuotationMark); //
print() << FTermBuffer(first, last);
if ( right_truncated_fullwidth )
print (fc::SingleRightAngleQuotationMark); //
print (UniChar::SingleRightAngleQuotationMark); //
while ( column_width < getClientWidth() )
{
setColor();
print(fc::BoxDrawingsHorizontal);
print(UniChar::BoxDrawingsHorizontal);
column_width++;
}
}
@ -2236,10 +2219,10 @@ void FListView::mouseHeaderClicked()
if ( header_pos > header_start
&& header_pos <= header_start + click_width )
{
if ( has_sort_indicator && sort_order == fc::ascending )
setColumnSort (column, fc::descending);
if ( has_sort_indicator && sort_order == SortOrder::Ascending )
setColumnSort (column, SortOrder::Descending);
else
setColumnSort (column, fc::ascending);
setColumnSort (column, SortOrder::Ascending);
sort();
@ -2312,7 +2295,7 @@ bool FListView::dragScrollUp (int position_before)
{
if ( position_before == 0 )
{
drag_scroll = fc::noScroll;
drag_scroll = DragScrollMode::None;
return false;
}
@ -2327,7 +2310,7 @@ bool FListView::dragScrollDown (int position_before)
if ( position_before + 1 == element_count )
{
drag_scroll = fc::noScroll;
drag_scroll = DragScrollMode::None;
return false;
}
@ -2336,9 +2319,9 @@ bool FListView::dragScrollDown (int position_before)
}
//----------------------------------------------------------------------
void FListView::dragUp (int mouse_button)
void FListView::dragUp (MouseButton mouse_button)
{
if ( drag_scroll != fc::noScroll
if ( drag_scroll != DragScrollMode::None
&& scroll_distance < int(getClientHeight()) )
scroll_distance++;
@ -2347,23 +2330,23 @@ void FListView::dragUp (int mouse_button)
scroll_timer = true;
addTimer(scroll_repeat);
if ( mouse_button == fc::RightButton )
drag_scroll = fc::scrollUpSelect;
if ( mouse_button == MouseButton::Right )
drag_scroll = DragScrollMode::SelectUpward;
else
drag_scroll = fc::scrollUp;
drag_scroll = DragScrollMode::Upward;
}
if ( current_iter.getPosition() == 0 )
{
delOwnTimers();
drag_scroll = fc::noScroll;
drag_scroll = DragScrollMode::None;
}
}
//----------------------------------------------------------------------
void FListView::dragDown (int mouse_button)
void FListView::dragDown (MouseButton mouse_button)
{
if ( drag_scroll != fc::noScroll
if ( drag_scroll != DragScrollMode::None
&& scroll_distance < int(getClientHeight()) )
scroll_distance++;
@ -2372,16 +2355,16 @@ void FListView::dragDown (int mouse_button)
scroll_timer = true;
addTimer(scroll_repeat);
if ( mouse_button == fc::RightButton )
drag_scroll = fc::scrollDownSelect;
if ( mouse_button == MouseButton::Right )
drag_scroll = DragScrollMode::SelectDownward;
else
drag_scroll = fc::scrollDown;
drag_scroll = DragScrollMode::Downward;
}
if ( current_iter.getPosition() - 1 == int(getCount()) )
{
delOwnTimers();
drag_scroll = fc::noScroll;
drag_scroll = DragScrollMode::None;
}
}
@ -2391,7 +2374,7 @@ void FListView::stopDragScroll()
delOwnTimers();
scroll_timer = false;
scroll_distance = 1;
drag_scroll = fc::noScroll;
drag_scroll = DragScrollMode::None;
}
//----------------------------------------------------------------------
@ -2765,47 +2748,47 @@ void FListView::scrollBy (int dx, int dy)
//----------------------------------------------------------------------
void FListView::cb_vbarChange (const FWidget*)
{
FScrollbar::SType scrollType = vbar->getScrollType();
const FScrollbar::ScrollType scrollType = vbar->getScrollType();
static constexpr int wheel_distance = 4;
int distance{1};
first_line_position_before = first_visible_line.getPosition();
assert ( scrollType == FScrollbar::SType::noScroll
|| scrollType == FScrollbar::SType::scrollJump
|| scrollType == FScrollbar::SType::scrollStepBackward
|| scrollType == FScrollbar::SType::scrollStepForward
|| scrollType == FScrollbar::SType::scrollPageBackward
|| scrollType == FScrollbar::SType::scrollPageForward
|| scrollType == FScrollbar::SType::scrollWheelUp
|| scrollType == FScrollbar::SType::scrollWheelDown );
assert ( scrollType == FScrollbar::ScrollType::None
|| scrollType == FScrollbar::ScrollType::Jump
|| scrollType == FScrollbar::ScrollType::StepBackward
|| scrollType == FScrollbar::ScrollType::StepForward
|| scrollType == FScrollbar::ScrollType::PageBackward
|| scrollType == FScrollbar::ScrollType::PageForward
|| scrollType == FScrollbar::ScrollType::WheelUp
|| scrollType == FScrollbar::ScrollType::WheelDown );
switch ( scrollType )
{
case FScrollbar::SType::noScroll:
case FScrollbar::ScrollType::None:
break;
case FScrollbar::SType::scrollPageBackward:
case FScrollbar::ScrollType::PageBackward:
distance = int(getClientHeight());
// fall through
case FScrollbar::SType::scrollStepBackward:
case FScrollbar::ScrollType::StepBackward:
stepBackward(distance);
break;
case FScrollbar::SType::scrollPageForward:
case FScrollbar::ScrollType::PageForward:
distance = int(getClientHeight());
// fall through
case FScrollbar::SType::scrollStepForward:
case FScrollbar::ScrollType::StepForward:
stepForward(distance);
break;
case FScrollbar::SType::scrollJump:
case FScrollbar::ScrollType::Jump:
scrollToY (vbar->getValue());
break;
case FScrollbar::SType::scrollWheelUp:
case FScrollbar::ScrollType::WheelUp:
wheelUp (wheel_distance);
break;
case FScrollbar::SType::scrollWheelDown:
case FScrollbar::ScrollType::WheelDown:
wheelDown (wheel_distance);
break;
}
@ -2813,8 +2796,8 @@ void FListView::cb_vbarChange (const FWidget*)
if ( isShown() )
drawList();
if ( scrollType >= FScrollbar::SType::scrollStepBackward
&& scrollType <= FScrollbar::SType::scrollPageForward )
if ( scrollType >= FScrollbar::ScrollType::StepBackward
&& scrollType <= FScrollbar::ScrollType::PageForward )
{
vbar->setValue (first_visible_line.getPosition());
@ -2828,47 +2811,47 @@ void FListView::cb_vbarChange (const FWidget*)
//----------------------------------------------------------------------
void FListView::cb_hbarChange (const FWidget*)
{
FScrollbar::SType scrollType = hbar->getScrollType();
const FScrollbar::ScrollType scrollType = hbar->getScrollType();
static constexpr int wheel_distance = 4;
int distance{1};
const int xoffset_before = xoffset;
assert ( scrollType == FScrollbar::SType::noScroll
|| scrollType == FScrollbar::SType::scrollJump
|| scrollType == FScrollbar::SType::scrollStepBackward
|| scrollType == FScrollbar::SType::scrollStepForward
|| scrollType == FScrollbar::SType::scrollPageBackward
|| scrollType == FScrollbar::SType::scrollPageForward
|| scrollType == FScrollbar::SType::scrollWheelUp
|| scrollType == FScrollbar::SType::scrollWheelDown );
assert ( scrollType == FScrollbar::ScrollType::None
|| scrollType == FScrollbar::ScrollType::Jump
|| scrollType == FScrollbar::ScrollType::StepBackward
|| scrollType == FScrollbar::ScrollType::StepForward
|| scrollType == FScrollbar::ScrollType::PageBackward
|| scrollType == FScrollbar::ScrollType::PageForward
|| scrollType == FScrollbar::ScrollType::WheelUp
|| scrollType == FScrollbar::ScrollType::WheelDown );
switch ( scrollType )
{
case FScrollbar::SType::noScroll:
case FScrollbar::ScrollType::None:
break;
case FScrollbar::SType::scrollPageBackward:
case FScrollbar::ScrollType::PageBackward:
distance = int(getClientWidth());
// fall through
case FScrollbar::SType::scrollStepBackward:
case FScrollbar::ScrollType::StepBackward:
scrollBy (-distance, 0);
break;
case FScrollbar::SType::scrollPageForward:
case FScrollbar::ScrollType::PageForward:
distance = int(getClientWidth());
// fall through
case FScrollbar::SType::scrollStepForward:
case FScrollbar::ScrollType::StepForward:
scrollBy (distance, 0);
break;
case FScrollbar::SType::scrollJump:
case FScrollbar::ScrollType::Jump:
scrollToX (hbar->getValue());
break;
case FScrollbar::SType::scrollWheelUp:
case FScrollbar::ScrollType::WheelUp:
scrollBy (-wheel_distance, 0);
break;
case FScrollbar::SType::scrollWheelDown:
case FScrollbar::ScrollType::WheelDown:
scrollBy (wheel_distance, 0);
break;
}
@ -2879,7 +2862,7 @@ void FListView::cb_hbarChange (const FWidget*)
drawList();
}
if ( scrollType >= FScrollbar::SType::scrollStepBackward )
if ( scrollType >= FScrollbar::ScrollType::StepBackward )
{
hbar->setValue (xoffset);

View File

@ -137,50 +137,33 @@ void FMenu::onKeyPress (FKeyEvent* ev)
if ( menu_bar && menu_bar->hotkeyMenu(ev) )
return;
switch ( ev->key() )
{
case fc::Fkey_up:
selectPrevItem();
break;
const auto key = ev->key();
// Ignore these keys:
// Dialog Switch Accelerator Handling in FApplication
std::array<FKey, 9> ignore_list = // Meta-1..9
{{
FKey::Meta_1, FKey::Meta_2, FKey::Meta_3,
FKey::Meta_4, FKey::Meta_5, FKey::Meta_6,
FKey::Meta_7, FKey::Meta_8, FKey::Meta_9
}};
case fc::Fkey_down:
selectNextItem();
break;
if ( std::any_of( std::begin(ignore_list)
, std::end(ignore_list)
, [&key] (FKey k) { return key == k; } ) )
return;
case fc::Fkey_left:
selectPrevMenu(ev);
break;
case fc::Fkey_right:
selectNextMenu(ev);
break;
case fc::Fkey_return:
case fc::Fkey_enter:
acceptSelection();
break;
case fc::Fkey_escape:
case fc::Fkey_escape_mintty:
closeMenu();
break;
case fc::Fmkey_1:
case fc::Fmkey_2:
case fc::Fmkey_3:
case fc::Fmkey_4:
case fc::Fmkey_5:
case fc::Fmkey_6:
case fc::Fmkey_7:
case fc::Fmkey_8:
case fc::Fmkey_9:
// do nothing:
// handle the dialog switch accelerator in FApplication
return;
default:
break;
}
if ( key == FKey::Up )
selectPrevItem();
else if ( key == FKey::Down )
selectNextItem();
else if ( key == FKey::Left )
selectPrevMenu(ev);
else if ( key == FKey::Right )
selectNextMenu(ev);
else if ( key == FKey::Return || key == FKey::Enter )
acceptSelection();
else if ( key == FKey::Escape || key == FKey::Escape_mintty )
closeMenu();
// always accept key event -> no forwarding to the parent widget
ev->accept();
@ -191,7 +174,7 @@ void FMenu::onMouseDown (FMouseEvent* ev)
{
shown_sub_menu = nullptr;
if ( ev->getButton() != fc::LeftButton )
if ( ev->getButton() != MouseButton::Left )
{
if ( opened_sub_menu )
{
@ -231,7 +214,7 @@ void FMenu::onMouseDown (FMouseEvent* ev)
//----------------------------------------------------------------------
void FMenu::onMouseUp (FMouseEvent* ev)
{
if ( ev->getButton() != fc::LeftButton )
if ( ev->getButton() != MouseButton::Left )
return;
if ( mouse_down )
@ -253,7 +236,7 @@ void FMenu::onMouseUp (FMouseEvent* ev)
//----------------------------------------------------------------------
void FMenu::onMouseMove (FMouseEvent* ev)
{
if ( ev->getButton() != fc::LeftButton )
if ( ev->getButton() != MouseButton::Left )
return;
if ( ! isWindowActive() )
@ -507,7 +490,7 @@ void FMenu::calculateDimensions()
{
item_width += 3;
}
else if ( accel_key )
else if ( accel_key != FKey::None )
{
const std::size_t accel_len = FTerm::getKeyName(accel_key).getLength();
item_width += accel_len + 2;
@ -914,20 +897,12 @@ void FMenu::passEventToSubMenu (const FMouseEvent& ev)
const auto& t = ev.getTermPos();
const auto& p = opened_sub_menu->termToWidgetPos(t);
const int b = ev.getButton();
try
{
const auto& _ev = \
std::make_shared<FMouseEvent>(fc::MouseMove_Event, p, t, b);
opened_sub_menu->mouse_down = true;
setClickedWidget(opened_sub_menu);
opened_sub_menu->onMouseMove(_ev.get());
}
catch (const std::bad_alloc&)
{
badAllocOutput ("FMouseEvent");
}
const MouseButton b = ev.getButton();
const auto& _ev = \
std::make_shared<FMouseEvent>(Event::MouseMove, p, t, b);
opened_sub_menu->mouse_down = true;
setClickedWidget(opened_sub_menu);
opened_sub_menu->onMouseMove(_ev.get());
}
//----------------------------------------------------------------------
@ -938,20 +913,12 @@ void FMenu::passEventToSuperMenu (const FMouseEvent& ev)
auto smenu = superMenuAt (ev.getTermPos());
const auto& t = ev.getTermPos();
const auto& p = smenu->termToWidgetPos(t);
const int b = ev.getButton();
try
{
const auto& _ev = \
std::make_shared<FMouseEvent>(fc::MouseMove_Event, p, t, b);
smenu->mouse_down = true;
setClickedWidget(smenu);
smenu->onMouseMove(_ev.get());
}
catch (const std::bad_alloc&)
{
badAllocOutput ("FMouseEvent");
}
const MouseButton b = ev.getButton();
const auto& _ev = \
std::make_shared<FMouseEvent>(Event::MouseMove, p, t, b);
smenu->mouse_down = true;
setClickedWidget(smenu);
smenu->onMouseMove(_ev.get());
}
//----------------------------------------------------------------------
@ -962,20 +929,12 @@ void FMenu::passEventToMenuBar (const FMouseEvent& ev) const
auto menu_bar = getMenuBar();
const auto& t = ev.getTermPos();
const auto& p = menu_bar->termToWidgetPos(t);
const int b = ev.getButton();
try
{
const auto& _ev = \
std::make_shared<FMouseEvent>(fc::MouseMove_Event, p, t, b);
setClickedWidget(menu_bar);
menu_bar->mouse_down = true;
menu_bar->onMouseMove(_ev.get());
}
catch (const std::bad_alloc&)
{
badAllocOutput ("FMouseEvent");
}
const MouseButton b = ev.getButton();
const auto& _ev = \
std::make_shared<FMouseEvent>(Event::MouseMove, p, t, b);
setClickedWidget(menu_bar);
menu_bar->mouse_down = true;
menu_bar->onMouseMove(_ev.get());
}
//----------------------------------------------------------------------
@ -1229,19 +1188,19 @@ inline void FMenu::drawSeparator (int y)
if ( FTerm::isNewFont() )
{
print (fc::NF_border_line_vertical_right);
print (UniChar::NF_border_line_vertical_right);
FString line { std::size_t(getWidth()) - 2
, fc::BoxDrawingsHorizontal };
, UniChar::BoxDrawingsHorizontal };
print (line);
print (fc::NF_rev_border_line_vertical_left);
print (UniChar::NF_rev_border_line_vertical_left);
}
else
{
print (fc::BoxDrawingsVerticalAndRight);
print (UniChar::BoxDrawingsVerticalAndRight);
FString line { std::size_t(getWidth()) - 2
, fc::BoxDrawingsHorizontal};
, UniChar::BoxDrawingsHorizontal};
print (line);
print (fc::BoxDrawingsVerticalAndLeft);
print (UniChar::BoxDrawingsVerticalAndLeft);
}
if ( FTerm::isMonochron() )
@ -1284,7 +1243,7 @@ inline void FMenu::drawMenuLine (FMenuItem* m_item, int y)
if ( m_item->hasMenu() )
drawSubMenuIndicator (column_width);
else if ( accel_key )
else if ( accel_key != FKey::None )
drawAcceleratorKey (column_width, accel_key);
// Draw the trailing spaces of the selected line
@ -1312,16 +1271,16 @@ inline void FMenu::drawCheckMarkPrefix (const FMenuItem* m_item)
if ( is_radio_btn )
{
if ( FTerm::isNewFont() )
print (fc::NF_Bullet); // NF_Bullet ●
print (UniChar::NF_Bullet); // NF_Bullet ●
else
print (fc::BlackCircle); // BlackCircle ●
print (UniChar::BlackCircle); // BlackCircle ●
}
else
{
if ( FTerm::isNewFont() )
print (fc::NF_check_mark); // NF_check_mark ✓
print (UniChar::NF_check_mark); // NF_check_mark ✓
else
print (fc::SquareRoot); // SquareRoot √
print (UniChar::SquareRoot); // SquareRoot √
}
}
else
@ -1329,10 +1288,10 @@ inline void FMenu::drawCheckMarkPrefix (const FMenuItem* m_item)
const auto& wc = getColorTheme();
setColor (wc->menu_inactive_fg, getBackgroundColor());
if ( FTerm::getEncoding() == fc::ASCII )
if ( FTerm::getEncoding() == Encoding::ASCII )
print ('-');
else
print (fc::SmallBullet); // ·
print (UniChar::SmallBullet); // ·
setColor();
}
@ -1350,8 +1309,8 @@ inline void FMenu::drawMenuText (MenuText& data)
{
if ( ! std::iswprint(std::wint_t(data.text[z]))
&& ! FTerm::isNewFont()
&& ( data.text[z] < fc::NF_rev_left_arrow2
|| data.text[z] > fc::NF_check_mark )
&& ( data.text[z] < UniChar::NF_rev_left_arrow2
|| data.text[z] > UniChar::NF_check_mark )
&& ! FTerm::charEncodable(wchar_t(data.text[z])) )
{
data.text[z] = L' ';
@ -1388,7 +1347,7 @@ inline void FMenu::drawSubMenuIndicator (std::size_t& startpos)
// Print filling blank spaces
print (FString{len, L' '});
// Print BlackRightPointingPointer ►
print (fc::BlackRightPointingPointer);
print (UniChar::BlackRightPointingPointer);
startpos = max_item_width - (c + 2);
}
}

View File

@ -92,71 +92,66 @@ void FMenuBar::adjustSize()
//----------------------------------------------------------------------
void FMenuBar::onKeyPress (FKeyEvent* ev)
{
switch ( ev->key() )
const auto key = ev->key();
if ( key == FKey::Return
|| key == FKey::Enter
|| key == FKey::Up
|| key == FKey::Down )
{
case fc::Fkey_return:
case fc::Fkey_enter:
case fc::Fkey_up:
case fc::Fkey_down:
if ( hasSelectedItem() )
if ( hasSelectedItem() )
{
auto sel_item = getSelectedItem();
if ( sel_item->hasMenu() )
{
auto sel_item = getSelectedItem();
auto menu = sel_item->getMenu();
sel_item->openMenu();
menu->selectFirstItem();
auto first_item = menu->getSelectedItem();
if ( sel_item->hasMenu() )
{
auto menu = sel_item->getMenu();
sel_item->openMenu();
menu->selectFirstItem();
auto first_item = menu->getSelectedItem();
if ( first_item )
first_item->setFocus();
if ( first_item )
first_item->setFocus();
menu->redraw();
menu->redraw();
if ( getStatusBar() )
getStatusBar()->drawMessage();
if ( getStatusBar() )
getStatusBar()->drawMessage();
redraw();
drop_down = true;
}
else if ( ev->key() == fc::Fkey_return
|| ev->key() == fc::Fkey_enter )
{
unselectItem();
redraw();
sel_item->processClicked();
}
redraw();
drop_down = true;
}
else if ( key == FKey::Return || key == FKey::Enter )
{
unselectItem();
redraw();
sel_item->processClicked();
}
}
ev->accept();
break;
case fc::Fkey_left:
selectPrevItem();
ev->accept();
break;
case fc::Fkey_right:
selectNextItem();
ev->accept();
break;
case fc::Fkey_escape:
case fc::Fkey_escape_mintty:
leaveMenuBar();
ev->accept();
break;
default:
break;
ev->accept();
}
else if ( key == FKey::Left )
{
selectPrevItem();
ev->accept();
}
else if ( key == FKey::Right )
{
selectNextItem();
ev->accept();
}
else if ( key == FKey::Escape || key == FKey::Escape_mintty )
{
leaveMenuBar();
ev->accept();
}
}
//----------------------------------------------------------------------
void FMenuBar::onMouseDown (FMouseEvent* ev)
{
if ( ev->getButton() != fc::LeftButton )
if ( ev->getButton() != MouseButton::Left )
{
mouse_down = false;
@ -186,7 +181,7 @@ void FMenuBar::onMouseDown (FMouseEvent* ev)
//----------------------------------------------------------------------
void FMenuBar::onMouseUp (FMouseEvent* ev)
{
if ( ev->getButton() != fc::LeftButton )
if ( ev->getButton() != MouseButton::Left )
return;
if ( mouse_down )
@ -201,7 +196,7 @@ void FMenuBar::onMouseUp (FMouseEvent* ev)
//----------------------------------------------------------------------
void FMenuBar::onMouseMove (FMouseEvent* ev)
{
if ( ev->getButton() != fc::LeftButton )
if ( ev->getButton() != MouseButton::Left )
return;
if ( ! isWindowActive() )
@ -254,9 +249,9 @@ void FMenuBar::init()
if ( getRootWidget() )
getRootWidget()->setTopPadding(1, true);
addAccelerator (fc::Fkey_f10);
addAccelerator (fc::Fckey_space);
addAccelerator (fc::Fkey_menu);
addAccelerator (FKey::F10);
addAccelerator (FKey::Ctrl_space);
addAccelerator (FKey::Menu);
resetColors();
unsetFocusable();
}
@ -423,7 +418,7 @@ bool FMenuBar::hotkeyMenu (FKeyEvent*& ev)
if ( hotkey > 0xff00 && hotkey < 0xff5f ) // full-width character
hotkey -= 0xfee0;
if ( fc::Fmkey_meta + FKey(std::tolower(int(hotkey))) == key )
if ( FKey::Meta_offset + FKey(std::tolower(int(hotkey))) == key )
{
auto sel_item = getSelectedItem();
@ -607,8 +602,8 @@ inline void FMenuBar::drawMenuText (menuText& data)
if ( ! std::iswprint(std::wint_t(data.text[z]))
&& ! FTerm::isNewFont()
&& ( data.text[z] < fc::NF_rev_left_arrow2
|| data.text[z] > fc::NF_check_mark ) )
&& ( data.text[z] < UniChar::NF_rev_left_arrow2
|| data.text[z] > UniChar::NF_check_mark ) )
{
data.text[z] = L' ';
}
@ -940,20 +935,12 @@ void FMenuBar::passEventToMenu (const FMouseEvent& ev) const
{
const auto& t = ev.getTermPos();
const auto& p = menu->termToWidgetPos(t);
const int b = ev.getButton();
try
{
const auto& _ev = \
std::make_shared<FMouseEvent>(fc::MouseMove_Event, p, t, b);
menu->mouse_down = true;
setClickedWidget(menu);
menu->onMouseMove(_ev.get());
}
catch (const std::bad_alloc&)
{
badAllocOutput ("FMouseEvent");
}
const MouseButton b = ev.getButton();
const auto& _ev = \
std::make_shared<FMouseEvent>(Event::MouseMove, p, t, b);
menu->mouse_down = true;
setClickedWidget(menu);
menu->onMouseMove(_ev.get());
}
}

View File

@ -96,7 +96,7 @@ bool FMenuItem::setEnable (bool enable)
if ( super && isMenuBar(super) )
{
// Meta + hotkey
super->addAccelerator ( fc::Fmkey_meta + FKey(std::tolower(int(hotkey)))
super->addAccelerator ( FKey::Meta_offset + FKey(std::tolower(int(hotkey)))
, this );
}
}
@ -175,7 +175,7 @@ void FMenuItem::setText (const FString& txt)
text_width = getColumnWidth(txt);
hotkey = finalcut::getHotkey(text);
if ( hotkey )
if ( hotkey != FKey::None )
{
text_length--;
text_width--;
@ -213,7 +213,7 @@ void FMenuItem::delAccelerator (FWidget* obj)
{
if ( iter->object == obj )
{
accel_key = 0;
accel_key = FKey::None;
iter = list.erase(iter);
}
else
@ -287,19 +287,19 @@ void FMenuItem::onMouseDoubleClick (FMouseEvent* ev)
if ( isMenu(super_menu) )
{
auto smenu = static_cast<FMenu*>(super_menu);
passMouseEvent (smenu, ev, fc::MouseDoubleClick_Event);
passMouseEvent (smenu, ev, Event::MouseDoubleClick);
}
if ( isMenuBar(super_menu) )
{
auto mbar = static_cast<FMenuBar*>(super_menu);
passMouseEvent (mbar, ev, fc::MouseDoubleClick_Event);
passMouseEvent (mbar, ev, Event::MouseDoubleClick);
}
if ( isDialog(super_menu) )
{
auto dgl = static_cast<FDialog*>(super_menu);
passMouseEvent (dgl, ev, fc::MouseDoubleClick_Event);
passMouseEvent (dgl, ev, Event::MouseDoubleClick);
}
}
@ -312,19 +312,19 @@ void FMenuItem::onMouseDown (FMouseEvent* ev)
if ( isMenu(super_menu) )
{
auto smenu = static_cast<FMenu*>(super_menu);
passMouseEvent (smenu, ev, fc::MouseDown_Event);
passMouseEvent (smenu, ev, Event::MouseDown);
}
if ( isMenuBar(super_menu) )
{
auto mbar = static_cast<FMenuBar*>(super_menu);
passMouseEvent (mbar, ev, fc::MouseDown_Event);
passMouseEvent (mbar, ev, Event::MouseDown);
}
if ( isDialog(super_menu) )
{
auto dgl = static_cast<FDialog*>(super_menu);
passMouseEvent (dgl, ev, fc::MouseDown_Event);
passMouseEvent (dgl, ev, Event::MouseDown);
}
}
@ -337,19 +337,19 @@ void FMenuItem::onMouseUp (FMouseEvent* ev)
if ( isMenu(super_menu) )
{
auto smenu = static_cast<FMenu*>(super_menu);
passMouseEvent (smenu, ev, fc::MouseUp_Event);
passMouseEvent (smenu, ev, Event::MouseUp);
}
if ( isMenuBar(super_menu) )
{
auto mbar = static_cast<FMenuBar*>(super_menu);
passMouseEvent (mbar, ev, fc::MouseUp_Event);
passMouseEvent (mbar, ev, Event::MouseUp);
}
if ( isDialog(super_menu) )
{
auto dgl = static_cast<FDialog*>(super_menu);
passMouseEvent (dgl, ev, fc::MouseUp_Event);
passMouseEvent (dgl, ev, Event::MouseUp);
}
}
@ -362,19 +362,19 @@ void FMenuItem::onMouseMove (FMouseEvent* ev)
if ( isMenu(super_menu) )
{
auto smenu = static_cast<FMenu*>(super_menu);
passMouseEvent (smenu, ev, fc::MouseMove_Event);
passMouseEvent (smenu, ev, Event::MouseMove);
}
if ( isMenuBar(super_menu) )
{
auto mbar = static_cast<FMenuBar*>(super_menu);
passMouseEvent (mbar, ev, fc::MouseMove_Event);
passMouseEvent (mbar, ev, Event::MouseMove);
}
if ( isDialog(super_menu) )
{
auto dgl = static_cast<FDialog*>(super_menu);
passMouseEvent (dgl, ev, fc::MouseMove_Event);
passMouseEvent (dgl, ev, Event::MouseMove);
}
}
@ -512,7 +512,7 @@ void FMenuItem::init()
if ( hotkey > 0xff00 && hotkey < 0xff5f ) // full-width character
hotkey -= 0xfee0;
if ( hotkey )
if ( hotkey != FKey::None )
{
text_length--;
text_width--;
@ -526,7 +526,7 @@ void FMenuItem::init()
setSuperMenu (parent);
if ( accel_key )
if ( accel_key != FKey::None )
addAccelerator (accel_key);
auto menu_list = getFMenuList(*parent);
@ -539,8 +539,8 @@ void FMenuItem::init()
auto menubar_ptr = static_cast<FMenuBar*>(parent);
menubar_ptr->calculateDimensions();
if ( hotkey ) // Meta + hotkey
menubar_ptr->addAccelerator ( fc::Fmkey_meta + FKey(std::tolower(int(hotkey)))
if ( hotkey != FKey::None ) // Meta + hotkey
menubar_ptr->addAccelerator ( FKey::Meta_offset + FKey(std::tolower(int(hotkey)))
, this );
addCallback // for this element
@ -621,7 +621,7 @@ void FMenuItem::createDialogList (FMenu* winmenu) const
}
if ( n < 9 )
win_item->addAccelerator (fc::Fmkey_1 + n); // Meta + 1..9
win_item->addAccelerator (FKey::Meta_1 + n); // Meta + 1..9
win_item->addCallback
(
@ -650,46 +650,31 @@ void FMenuItem::createDialogList (FMenu* winmenu) const
//----------------------------------------------------------------------
template <typename T>
void FMenuItem::passMouseEvent ( T widget, const FMouseEvent* ev
, fc::events ev_type ) const
, Event ev_type ) const
{
if ( ! widget )
return;
const auto& t = ev->getTermPos();
const auto& p2 = widget->termToWidgetPos(t);
const int b = ev->getButton();
std::shared_ptr<FMouseEvent> _ev;
const auto b = ev->getButton();
auto _ev = std::make_shared<FMouseEvent>(ev_type, p2, t, b);
try
if ( ev_type == Event::MouseDoubleClick )
{
_ev = std::make_shared<FMouseEvent>(ev_type, p2, t, b);
widget->onMouseDoubleClick(_ev.get());
}
catch (const std::bad_alloc&)
else if ( ev_type == Event::MouseDown )
{
badAllocOutput ("FMouseEvent");
return;
widget->onMouseDown(_ev.get());
}
switch ( int(ev_type) )
else if ( ev_type == Event::MouseUp )
{
case fc::MouseDoubleClick_Event:
widget->onMouseDoubleClick(_ev.get());
break;
case fc::MouseDown_Event:
widget->onMouseDown(_ev.get());
break;
case fc::MouseUp_Event:
widget->onMouseUp(_ev.get());
break;
case fc::MouseMove_Event:
widget->onMouseMove(_ev.get());
break;
default:
break;
widget->onMouseUp(_ev.get());
}
else if ( ev_type == Event::MouseMove )
{
widget->onMouseMove(_ev.get());
}
}
@ -700,7 +685,7 @@ void FMenuItem::cb_switchToDialog (FDialog* win) const
return;
auto focus = getFocusWidget();
FAccelEvent a_ev (fc::Accelerator_Event, focus);
FAccelEvent a_ev (Event::Accelerator, focus);
FApplication::sendEvent (win, &a_ev);
}

View File

@ -51,7 +51,7 @@ constexpr std::array<const char* const, 8> button_text =
//----------------------------------------------------------------------
FMessageBox::FMessageBox (FWidget* parent)
: FDialog{parent}
, button_digit{ButtonType::Ok, ButtonType::Reject, ButtonType::Reject}
, button_digit{{ButtonType::Ok, ButtonType::Reject, ButtonType::Reject}}
{
setTitlebarText("Message for you");
init();
@ -66,7 +66,7 @@ FMessageBox::FMessageBox ( const FString& caption
, FWidget* parent )
: FDialog{parent}
, text{message}
, button_digit{button0, button1, button2}
, button_digit{{button0, button1, button2}}
{
setTitlebarText(caption);
init();

View File

@ -34,6 +34,7 @@
#include "final/fmouse.h"
#include "final/fobject.h"
#include "final/fterm.h"
#include "final/ftermlinux.h"
#include "final/ftermxterminal.h"
#include "final/ftypes.h"
@ -144,12 +145,12 @@ void FMouseData::clearButtonState()
b_state.left_button = State::Undefined;
b_state.right_button = State::Undefined;
b_state.middle_button = State::Undefined;
b_state.shift_button = 0;
b_state.control_button = 0;
b_state.meta_button = 0;
b_state.wheel_up = 0;
b_state.wheel_down = 0;
b_state.mouse_moved = 0;
b_state.shift_button = false;
b_state.control_button = false;
b_state.meta_button = false;
b_state.wheel_up = false;
b_state.wheel_down = false;
b_state.mouse_moved = false;
}
@ -380,7 +381,7 @@ void FMouseGPM::processEvent (struct timeval*)
setPos (FPoint{ std::max(gpm_ev.x, sInt16(1))
, std::max(gpm_ev.y, sInt16(1)) });
if ( gpmEvent(false) == mouse_event )
if ( gpmEvent(false) == gpmEventType::Mouse )
setPending(true);
else
setPending(false);
@ -486,20 +487,12 @@ bool FMouseGPM::getGpmKeyPressed (bool is_pending)
{
setPending(is_pending);
has_gpm_mouse_data = false;
const int type = gpmEvent();
const auto type = gpmEvent();
switch ( type )
{
case mouse_event:
has_gpm_mouse_data = true;
break;
case keyboard_event:
return true;
default:
return false;
}
if ( type == gpmEventType::Mouse )
has_gpm_mouse_data = true;
else if ( type == gpmEventType::Keyboard )
return true;
return false;
}
@ -512,7 +505,7 @@ void FMouseGPM::drawPointer() const
}
//----------------------------------------------------------------------
int FMouseGPM::gpmEvent (bool clear) const
FMouseGPM::gpmEventType FMouseGPM::gpmEvent (bool clear) const
{
const int max = ( gpm_fd > stdin_no ) ? gpm_fd : stdin_no;
fd_set ifds{};
@ -530,16 +523,16 @@ int FMouseGPM::gpmEvent (bool clear) const
if ( clear )
FD_CLR (stdin_no, &ifds);
return keyboard_event;
return gpmEventType::Keyboard;
}
if ( clear && result > 0 && FD_ISSET(gpm_fd, &ifds) )
FD_CLR (gpm_fd, &ifds);
if ( result > 0 )
return mouse_event;
return gpmEventType::Mouse;
else
return no_event;
return gpmEventType::None;
}
#endif // F_HAVE_LIBGPM
@ -1212,13 +1205,13 @@ void FMouseUrxvt::setButtonState (const int btn, const struct timeval* time)
FMouseControl::FMouseControl()
{
#ifdef F_HAVE_LIBGPM
if ( FTerm::isLinuxTerm() )
mouse_protocol[FMouse::MouseType::gpm].reset(FMouse::createMouseObject<FMouseGPM>());
if ( FTermLinux::isLinuxConsole() )
mouse_protocol[FMouse::MouseType::Gpm].reset(FMouse::createMouseObject<FMouseGPM>());
#endif
mouse_protocol[FMouse::MouseType::x11].reset(FMouse::createMouseObject<FMouseX11>());
mouse_protocol[FMouse::MouseType::sgr].reset(FMouse::createMouseObject<FMouseSGR>());
mouse_protocol[FMouse::MouseType::urxvt].reset(FMouse::createMouseObject<FMouseUrxvt>());
mouse_protocol[FMouse::MouseType::X11].reset(FMouse::createMouseObject<FMouseX11>());
mouse_protocol[FMouse::MouseType::Sgr].reset(FMouse::createMouseObject<FMouseSGR>());
mouse_protocol[FMouse::MouseType::Urxvt].reset(FMouse::createMouseObject<FMouseUrxvt>());
}
//----------------------------------------------------------------------
@ -1250,14 +1243,14 @@ void FMouseControl::clearEvent()
if ( mouse_protocol[mtype] )
mouse_protocol[mtype]->clearEvent();
}
while ( mtype != FMouse::MouseType::none );
while ( mtype != FMouse::MouseType::None );
}
//----------------------------------------------------------------------
#ifdef F_HAVE_LIBGPM
void FMouseControl::setStdinNo (int file_descriptor)
{
auto mouse = mouse_protocol[FMouse::MouseType::gpm].get();
auto mouse = mouse_protocol[FMouse::MouseType::Gpm].get();
auto gpm_mouse = static_cast<FMouseGPM*>(mouse);
if ( gpm_mouse )
@ -1271,13 +1264,13 @@ void FMouseControl::setStdinNo (int)
//----------------------------------------------------------------------
void FMouseControl::setMaxWidth (uInt16 x_max)
{
mouse_protocol[FMouse::MouseType::urxvt]->setMaxWidth(x_max);
mouse_protocol[FMouse::MouseType::Urxvt]->setMaxWidth(x_max);
}
//----------------------------------------------------------------------
void FMouseControl::setMaxHeight (uInt16 y_max)
{
mouse_protocol[FMouse::MouseType::urxvt]->setMaxHeight(y_max);
mouse_protocol[FMouse::MouseType::Urxvt]->setMaxHeight(y_max);
}
//----------------------------------------------------------------------
@ -1486,7 +1479,7 @@ bool FMouseControl::isGpmMouseEnabled()
if ( mouse_protocol.empty() )
return false;
const auto& mouse = mouse_protocol[FMouse::MouseType::gpm].get();
const auto& mouse = mouse_protocol[FMouse::MouseType::Gpm].get();
const auto& gpm_mouse = static_cast<FMouseGPM*>(mouse);
if ( gpm_mouse )
@ -1507,7 +1500,7 @@ void FMouseControl::enable()
#ifdef F_HAVE_LIBGPM
if ( use_gpm_mouse )
{
auto mouse = mouse_protocol[FMouse::MouseType::gpm].get();
auto mouse = mouse_protocol[FMouse::MouseType::Gpm].get();
auto gpm_mouse = static_cast<FMouseGPM*>(mouse);
if ( gpm_mouse )
@ -1525,7 +1518,7 @@ void FMouseControl::disable()
#ifdef F_HAVE_LIBGPM
if ( use_gpm_mouse )
{
auto mouse = mouse_protocol[FMouse::MouseType::gpm].get();
auto mouse = mouse_protocol[FMouse::MouseType::Gpm].get();
auto gpm_mouse = static_cast<FMouseGPM*>(mouse);
if ( gpm_mouse )
@ -1590,7 +1583,7 @@ bool FMouseControl::getGpmKeyPressed (bool pending)
if ( mouse_protocol.empty() )
return false;
auto mouse = mouse_protocol[FMouse::MouseType::gpm].get();
auto mouse = mouse_protocol[FMouse::MouseType::Gpm].get();
auto gpm_mouse = static_cast<FMouseGPM*>(mouse);
if ( gpm_mouse )
@ -1612,7 +1605,7 @@ void FMouseControl::drawPointer()
if ( mouse_protocol.empty() )
return;
auto mouse = mouse_protocol[FMouse::MouseType::gpm].get();
auto mouse = mouse_protocol[FMouse::MouseType::Gpm].get();
auto gpm_mouse = static_cast<FMouseGPM*>(mouse);
if ( gpm_mouse )
@ -1638,7 +1631,7 @@ FMouse::MouseType FMouseControl::getMouseWithData()
}
);
return ( iter != mouse_protocol.end() ) ? iter->first : FMouse::MouseType::none;
return ( iter != mouse_protocol.end() ) ? iter->first : FMouse::MouseType::None;
}
//----------------------------------------------------------------------
@ -1654,7 +1647,7 @@ FMouse::MouseType FMouseControl::getMouseWithEvent()
}
);
return ( iter != mouse_protocol.end() ) ? iter->first : FMouse::MouseType::none;
return ( iter != mouse_protocol.end() ) ? iter->first : FMouse::MouseType::None;
}
//----------------------------------------------------------------------

View File

@ -164,11 +164,11 @@ bool FObject::event (FEvent* ev)
{
// Receives events on this object
if ( ev->getType() == fc::Timer_Event )
if ( ev->getType() == Event::Timer )
{
onTimer ( static_cast<FTimerEvent*>(ev) );
}
else if ( ev->getType() == fc::User_Event )
else if ( ev->getType() == Event::User )
{
onUserEvent ( static_cast<FUserEvent*>(ev) );
}
@ -405,7 +405,7 @@ uInt FObject::processTimerEvent()
if ( timer.interval.tv_usec > 0 || timer.interval.tv_sec > 0 )
activated++;
FTimerEvent t_ev(fc::Timer_Event, timer.id);
FTimerEvent t_ev(Event::Timer, timer.id);
performTimerAction (timer.object, &t_ev);
}

View File

@ -524,17 +524,19 @@ FColor FOptiAttr::vga2ansi (FColor color)
// 1 1 1 0 | 1 0 1 1
// 1 1 1 1 | 1 1 1 1
if ( color == fc::Default )
color = 0;
if ( color == FColor::Default )
color = FColor::Black;
else if ( color < 16 )
{
constexpr std::array<FColor, 16> lookup_table =
{{
0, 4, 2, 6, 1, 5, 3, 7,
8, 12, 10, 14, 9, 13, 11, 15
FColor(0), FColor(4), FColor(2), FColor(6),
FColor(1), FColor(5), FColor(3), FColor(7),
FColor(8), FColor(12), FColor(10), FColor(14),
FColor(9), FColor(13), FColor(11), FColor(15)
}};
color = lookup_table[color];
color = lookup_table[uInt16(color)];
}
return color;
@ -986,8 +988,8 @@ inline bool FOptiAttr::unsetTermPCcharset (FChar& term)
//----------------------------------------------------------------------
bool FOptiAttr::setTermDefaultColor (FChar& term)
{
term.fg_color = fc::Default;
term.bg_color = fc::Default;
term.fg_color = FColor::Default;
term.bg_color = FColor::Default;
if ( append_sequence(F_orig_pair.cap) )
return true;
@ -1092,8 +1094,8 @@ void FOptiAttr::setAttributesOff (FChar& term)
//----------------------------------------------------------------------
bool FOptiAttr::hasColor (const FChar& attr)
{
if ( attr.fg_color == fc::Default
&& attr.bg_color == fc::Default )
if ( attr.fg_color == FColor::Default
&& attr.bg_color == FColor::Default )
return false;
else
return true;
@ -1139,8 +1141,8 @@ inline bool FOptiAttr::hasColorChanged ( const FChar& term
//----------------------------------------------------------------------
inline void FOptiAttr::resetColor (FChar& attr) const
{
attr.fg_color = fc::Default;
attr.bg_color = fc::Default;
attr.fg_color = FColor::Default;
attr.bg_color = FColor::Default;
}
//----------------------------------------------------------------------
@ -1288,24 +1290,24 @@ void FOptiAttr::change_color (FChar& term, FChar& next)
{
if ( monochron )
{
next.fg_color = fc::Default;
next.bg_color = fc::Default;
next.fg_color = FColor::Default;
next.bg_color = FColor::Default;
return;
}
if ( next.fg_color != fc::Default )
next.fg_color %= max_color;
if ( next.fg_color != FColor::Default )
next.fg_color %= uInt16(max_color);
if ( next.bg_color != fc::Default )
next.bg_color %= max_color;
if ( next.bg_color != FColor::Default )
next.bg_color %= uInt16(max_color);
FColor fg = next.fg_color;
FColor bg = next.bg_color;
if ( fg == fc::Default || bg == fc::Default )
if ( fg == FColor::Default || bg == FColor::Default )
change_to_default_color (term, next, fg, bg);
if ( fake_reverse && fg == fc::Default && bg == fc::Default )
if ( fake_reverse && fg == FColor::Default && bg == FColor::Default )
return;
if ( fake_reverse
@ -1313,7 +1315,7 @@ void FOptiAttr::change_color (FChar& term, FChar& next)
{
std::swap (fg, bg);
if ( fg == fc::Default || bg == fc::Default )
if ( fg == FColor::Default || bg == FColor::Default )
setTermDefaultColor(term);
}
@ -1329,18 +1331,18 @@ inline void FOptiAttr::change_to_default_color ( FChar& term, FChar& next
{
if ( ansi_default_color )
{
if ( fg == fc::Default && term.fg_color != fc::Default
&& bg == fc::Default && term.bg_color != fc::Default )
if ( fg == FColor::Default && term.fg_color != FColor::Default
&& bg == FColor::Default && term.bg_color != FColor::Default )
{
setTermDefaultColor(term);
}
else if ( fg == fc::Default && term.fg_color != fc::Default )
else if ( fg == FColor::Default && term.fg_color != FColor::Default )
{
std::string sgr_39{CSI "39m"};
append_sequence (sgr_39.c_str());
term.fg_color = fc::Default;
term.fg_color = FColor::Default;
}
else if ( bg == fc::Default && term.bg_color != fc::Default )
else if ( bg == FColor::Default && term.bg_color != FColor::Default )
{
const char* sgr_49;
const auto& op = F_orig_pair.cap;
@ -1351,14 +1353,14 @@ inline void FOptiAttr::change_to_default_color ( FChar& term, FChar& next
sgr_49 = CSI "49m";
append_sequence (sgr_49);
term.bg_color = fc::Default;
term.bg_color = FColor::Default;
}
}
else if ( ! setTermDefaultColor(term) )
{
// Fallback to gray on black
fg = next.fg_color = fc::LightGray;
bg = next.bg_color = fc::Black;
fg = next.fg_color = FColor::LightGray;
bg = next.bg_color = FColor::Black;
}
}

View File

@ -88,8 +88,8 @@ void FProgressbar::setGeometry ( const FPoint& pos, const FSize& size
bool FProgressbar::setShadow (bool enable)
{
if ( enable
&& FTerm::getEncoding() != fc::VT100
&& FTerm::getEncoding() != fc::ASCII )
&& FTerm::getEncoding() != Encoding::VT100
&& FTerm::getEncoding() != Encoding::ASCII )
{
setFlags().shadow = true;
setShadowSize(FSize{1, 1});
@ -191,7 +191,7 @@ std::size_t FProgressbar::drawProgressIndicator()
const double length = double(bar_length * percentage) / 100;
auto len = std::size_t(trunc(length));
print() << FColorPair {wc->progressbar_fg, wc->progressbar_fg}
<< FString {len, fc::FullBlock}; // █
<< FString {len, UniChar::FullBlock}; // █
if ( len >= bar_length )
return len;
@ -209,7 +209,7 @@ std::size_t FProgressbar::drawProgressIndicator()
else
{
print() << FColorPair{wc->progressbar_fg, wc->progressbar_bg}
<< fc::LeftHalfBlock; // ▌
<< UniChar::LeftHalfBlock; // ▌
}
len++;
@ -226,7 +226,7 @@ void FProgressbar::drawProgressBackground (std::size_t len)
setColor (wc->progressbar_fg, wc->progressbar_bg);
if ( FTerm::getMaxColor() < 16 )
print() << FString {bg_len, fc::MediumShade}; // ▒
print() << FString {bg_len, UniChar::MediumShade}; // ▒
else
print() << FString {bg_len, L' '};
}

View File

@ -100,7 +100,7 @@ inline void FRadioButton::drawChecked()
else
{
print ('(');
print (fc::Bullet); // Bullet ●
print (UniChar::Bullet); // Bullet ●
print (')');
}
}

View File

@ -45,7 +45,7 @@ FScrollbar::FScrollbar(FWidget* parent)
}
//----------------------------------------------------------------------
FScrollbar::FScrollbar(fc::orientation o, FWidget* parent)
FScrollbar::FScrollbar(Orientation o, FWidget* parent)
: FWidget{parent}
{
setOrientation (o);
@ -127,16 +127,16 @@ void FScrollbar::setPageSize (int document_size, int page_size)
}
//----------------------------------------------------------------------
void FScrollbar::setOrientation (fc::orientation o)
void FScrollbar::setOrientation (Orientation o)
{
length = ( o == fc::vertical ) ? getHeight() : getWidth();
length = ( o == Orientation::Vertical ) ? getHeight() : getWidth();
if ( o == fc::vertical && bar_orientation == fc::horizontal )
if ( o == Orientation::Vertical && bar_orientation == Orientation::Horizontal )
{
setWidth(1);
setHeight(length);
}
else if ( o == fc::horizontal && bar_orientation == fc::vertical )
else if ( o == Orientation::Horizontal && bar_orientation == Orientation::Vertical )
{
setWidth(length);
setHeight(1);
@ -184,7 +184,7 @@ void FScrollbar::redraw()
//----------------------------------------------------------------------
void FScrollbar::calculateSliderValues()
{
if ( FTerm::isNewFont() && bar_orientation == fc::horizontal )
if ( FTerm::isNewFont() && bar_orientation == Orientation::Horizontal )
bar_length = ( length > 2 ) ? length - 4 : 1;
else
bar_length = ( length > 2 ) ? length - 2 : 1;
@ -231,7 +231,7 @@ void FScrollbar::drawBar()
if ( slider_pos == current_slider_pos || length < 3 )
return;
if ( bar_orientation == fc::vertical )
if ( bar_orientation == Orientation::Vertical )
drawVerticalBar();
else // horizontal
drawHorizontalBar();
@ -242,8 +242,8 @@ void FScrollbar::drawBar()
//----------------------------------------------------------------------
void FScrollbar::onMouseDown (FMouseEvent* ev)
{
if ( ev->getButton() != fc::LeftButton
&& ev->getButton() != fc::MiddleButton )
if ( ev->getButton() != MouseButton::Left
&& ev->getButton() != MouseButton::Middle )
return;
if ( min == max )
@ -252,7 +252,7 @@ void FScrollbar::onMouseDown (FMouseEvent* ev)
const int mouse_x = ev->getX();
const int mouse_y = ev->getY();
if ( ev->getButton() == fc::MiddleButton )
if ( ev->getButton() == MouseButton::Middle )
{
jumpToClickPos (mouse_x, mouse_y);
return;
@ -261,18 +261,18 @@ void FScrollbar::onMouseDown (FMouseEvent* ev)
// Process left mouse button
scroll_type = getClickedScrollType(mouse_x, mouse_y);
if ( scroll_type == SType::noScroll )
if ( scroll_type == ScrollType::None )
{
slider_click_pos = getSliderClickPos (mouse_x, mouse_y);
if ( slider_click_pos > 0 )
scroll_type = SType::scrollJump;
scroll_type = ScrollType::Jump;
}
if ( scroll_type == SType::scrollPageBackward
|| scroll_type == SType::scrollPageForward )
if ( scroll_type == ScrollType::PageBackward
|| scroll_type == ScrollType::PageForward )
{
if ( bar_orientation == fc::vertical )
if ( bar_orientation == Orientation::Vertical )
slider_click_stop_pos = mouse_y - 2;
else
{
@ -285,8 +285,8 @@ void FScrollbar::onMouseDown (FMouseEvent* ev)
else
slider_click_stop_pos = -1;
if ( scroll_type >= SType::scrollStepBackward
&& scroll_type <= SType::scrollPageForward )
if ( scroll_type >= ScrollType::StepBackward
&& scroll_type <= ScrollType::PageForward )
{
processScroll();
threshold_reached = false;
@ -297,30 +297,30 @@ void FScrollbar::onMouseDown (FMouseEvent* ev)
//----------------------------------------------------------------------
void FScrollbar::onMouseUp (FMouseEvent* ev)
{
if ( ev->getButton() != fc::LeftButton
&& ev->getButton() != fc::MiddleButton )
if ( ev->getButton() != MouseButton::Left
&& ev->getButton() != MouseButton::Middle )
return;
slider_click_pos = -1;
if ( scroll_type != SType::noScroll )
if ( scroll_type != ScrollType::None )
{
delOwnTimers();
scroll_type = SType::noScroll;
scroll_type = ScrollType::None;
}
}
//----------------------------------------------------------------------
void FScrollbar::onMouseMove (FMouseEvent* ev)
{
if ( ev->getButton() != fc::LeftButton
&& ev->getButton() != fc::MiddleButton )
if ( ev->getButton() != MouseButton::Left
&& ev->getButton() != MouseButton::Middle )
return;
const int mouse_x = ev->getX();
const int mouse_y = ev->getY();
if ( ev->getButton() == fc::MiddleButton )
if ( ev->getButton() == MouseButton::Middle )
{
jumpToClickPos (mouse_x, mouse_y);
return;
@ -329,11 +329,11 @@ void FScrollbar::onMouseMove (FMouseEvent* ev)
// Process left mouse button
const auto new_scroll_type = getClickedScrollType(mouse_x, mouse_y);
if ( scroll_type == SType::scrollJump )
if ( scroll_type == ScrollType::Jump )
{
int new_val{};
if ( bar_orientation == fc::vertical )
if ( bar_orientation == Orientation::Vertical )
{
const int dy = mouse_y - slider_click_pos;
slider_click_pos = mouse_y;
@ -362,7 +362,7 @@ void FScrollbar::onMouseMove (FMouseEvent* ev)
{
delOwnTimers();
}
else if ( scroll_type != SType::scrollJump )
else if ( scroll_type != ScrollType::Jump )
{
addTimer(repeat_time);
}
@ -376,18 +376,18 @@ void FScrollbar::onMouseMove (FMouseEvent* ev)
//----------------------------------------------------------------------
void FScrollbar::onWheel (FWheelEvent* ev)
{
const int wheel = ev->getWheel();
const MouseWheel wheel = ev->getWheel();
if ( scroll_type != SType::noScroll )
if ( scroll_type != ScrollType::None )
{
delOwnTimers();
scroll_type = SType::noScroll;
scroll_type = ScrollType::None;
}
if ( wheel == fc::WheelUp )
scroll_type = SType::scrollWheelUp;
else if ( wheel == fc::WheelDown )
scroll_type = SType::scrollWheelDown;
if ( wheel == MouseWheel::Up )
scroll_type = ScrollType::WheelUp;
else if ( wheel == MouseWheel::Down )
scroll_type = ScrollType::WheelDown;
processScroll();
}
@ -395,7 +395,7 @@ void FScrollbar::onWheel (FWheelEvent* ev)
//----------------------------------------------------------------------
void FScrollbar::onTimer (FTimerEvent*)
{
if ( scroll_type == SType::noScroll )
if ( scroll_type == ScrollType::None )
return;
if ( ! threshold_reached )
@ -406,20 +406,20 @@ void FScrollbar::onTimer (FTimerEvent*)
}
// Timer stop condition
if ( ( scroll_type == SType::scrollPageBackward
if ( ( scroll_type == ScrollType::PageBackward
&& slider_pos == slider_click_stop_pos )
|| ( scroll_type == SType::scrollPageForward
|| ( scroll_type == ScrollType::PageForward
&& slider_pos == slider_click_stop_pos ) )
{
const auto max_slider_pos = int(bar_length - slider_length);
if ( scroll_type == SType::scrollPageBackward
if ( scroll_type == ScrollType::PageBackward
&& slider_pos == 0 )
{
jumpToClickPos(0); // Scroll to the start
processScroll();
}
else if ( scroll_type == SType::scrollPageForward
else if ( scroll_type == ScrollType::PageForward
&& slider_pos == max_slider_pos )
{
jumpToClickPos (max_slider_pos); // Scroll to the end
@ -505,15 +505,15 @@ inline void FScrollbar::drawVerticalBackgroundLine()
if ( FTerm::isNewFont() )
{
if ( FTerm::isMonochron() || max_color < 16 )
print (fc::MediumShade); // ▒
print (UniChar::MediumShade); // ▒
else
print (fc::NF_border_line_left); // ⎸
print (UniChar::NF_border_line_left); // ⎸
}
if ( FTerm::isMonochron() || max_color < 16 )
print (fc::MediumShade); // ▒
print (UniChar::MediumShade); // ▒
else if ( FTerm::isNewFont() )
print (fc::NF_rev_border_line_right); //⎹
print (UniChar::NF_rev_border_line_right); //⎹
else
print (' ');
}
@ -557,9 +557,9 @@ void FScrollbar::drawHorizontalBar()
inline void FScrollbar::drawHorizontalBackgroundColumn()
{
if ( FTerm::isNewFont() && max_color > 8 )
print (fc::NF_border_line_up_and_down); // ニ
print (UniChar::NF_border_line_up_and_down); // ニ
else if ( FTerm::isMonochron() || max_color < 16 )
print (fc::MediumShade); // ▒
print (UniChar::MediumShade); // ▒
else
print (' ');
}
@ -574,7 +574,7 @@ void FScrollbar::drawButtons()
{
print() << FPoint{1, 1};
if ( bar_orientation == fc::vertical )
if ( bar_orientation == Orientation::Vertical )
{
print() << NF_button_arrow_up
<< FPoint{1, int(length)}
@ -594,17 +594,17 @@ void FScrollbar::drawButtons()
if ( FTerm::isMonochron() )
setReverse(true);
if ( bar_orientation == fc::vertical )
if ( bar_orientation == Orientation::Vertical )
{
print() << fc::BlackUpPointingTriangle // ▲
print() << UniChar::BlackUpPointingTriangle // ▲
<< FPoint{1, int(length)}
<< fc::BlackDownPointingTriangle; // ▼
<< UniChar::BlackDownPointingTriangle; // ▼
}
else // horizontal
{
print() << fc::BlackLeftPointingPointer // ◄
print() << UniChar::BlackLeftPointingPointer // ◄
<< FPoint{int(length), 1}
<< fc::BlackRightPointingPointer; // ►
<< UniChar::BlackRightPointingPointer; // ►
}
if ( FTerm::isMonochron() )
@ -613,9 +613,9 @@ void FScrollbar::drawButtons()
}
//----------------------------------------------------------------------
FScrollbar::SType FScrollbar::getClickedScrollType (int x, int y) const
FScrollbar::ScrollType FScrollbar::getClickedScrollType (int x, int y) const
{
if ( bar_orientation == fc::vertical )
if ( bar_orientation == Orientation::Vertical )
{
return getVerticalClickedScrollType(y);
}
@ -626,72 +626,72 @@ FScrollbar::SType FScrollbar::getClickedScrollType (int x, int y) const
}
//----------------------------------------------------------------------
FScrollbar::SType FScrollbar::getVerticalClickedScrollType (int y) const
FScrollbar::ScrollType FScrollbar::getVerticalClickedScrollType (int y) const
{
if ( y == 1 )
{
return SType::scrollStepBackward; // decrement button
return ScrollType::StepBackward; // decrement button
}
else if ( y > 1 && y <= slider_pos + 1 )
{
return SType::scrollPageBackward; // before slider
return ScrollType::PageBackward; // before slider
}
else if ( y > slider_pos + int(slider_length) + 1 && y < int(getHeight()) )
{
return SType::scrollPageForward; // after slider
return ScrollType::PageForward; // after slider
}
else if ( y == int(getHeight()) )
{
return SType::scrollStepForward; // increment button
return ScrollType::StepForward; // increment button
}
return SType::noScroll;
return ScrollType::None;
}
//----------------------------------------------------------------------
FScrollbar::SType FScrollbar::getHorizontalClickedScrollType (int x) const
FScrollbar::ScrollType FScrollbar::getHorizontalClickedScrollType (int x) const
{
if ( FTerm::isNewFont() )
{
if ( x == 1 || x == 2 )
{
return SType::scrollStepBackward; // decrement button
return ScrollType::StepBackward; // decrement button
}
else if ( x > 2 && x <= slider_pos + 2 )
{
return SType::scrollPageBackward; // before slider
return ScrollType::PageBackward; // before slider
}
else if ( x > slider_pos + int(slider_length) + 2 && x < int(getWidth()) - 1 )
{
return SType::scrollPageForward; // after slider
return ScrollType::PageForward; // after slider
}
else if ( x == int(getWidth()) - 1 || x == int(getWidth()) )
{
return SType::scrollStepForward; // increment button
return ScrollType::StepForward; // increment button
}
return SType::noScroll;
return ScrollType::None;
}
else
{
if ( x == 1 )
{
return SType::scrollStepBackward; // decrement button
return ScrollType::StepBackward; // decrement button
}
else if ( x > 1 && x <= slider_pos + 1 )
{
return SType::scrollPageBackward; // before slider
return ScrollType::PageBackward; // before slider
}
else if ( x > slider_pos + int(slider_length) + 1 && x < int(getWidth()) )
{
return SType::scrollPageForward; // after slider
return ScrollType::PageForward; // after slider
}
else if ( x == int(getWidth()) )
{
return SType::scrollStepForward; // increment button
return ScrollType::StepForward; // increment button
}
return SType::noScroll;
return ScrollType::None;
}
}
@ -700,7 +700,7 @@ int FScrollbar::getSliderClickPos (int mouse_x, int mouse_y) const
{
// Get the clicked position on the slider
if ( bar_orientation == fc::vertical )
if ( bar_orientation == Orientation::Vertical )
{
if ( mouse_y > slider_pos + 1
&& mouse_y <= slider_pos + int(slider_length) + 1 )
@ -730,7 +730,7 @@ void FScrollbar::jumpToClickPos (int x, int y)
{
int new_val{};
if ( bar_orientation == fc::vertical )
if ( bar_orientation == Orientation::Vertical )
{
if ( y > 1 && y < int(getHeight()) )
{
@ -758,7 +758,7 @@ void FScrollbar::jumpToClickPos (int x, int y)
setValue(new_val);
drawBar();
forceTerminalUpdate();
scroll_type = SType::scrollJump;
scroll_type = ScrollType::Jump;
processScroll();
}
}
@ -766,7 +766,7 @@ void FScrollbar::jumpToClickPos (int x, int y)
//----------------------------------------------------------------------
void FScrollbar::jumpToClickPos (int pos)
{
if ( bar_orientation == fc::vertical )
if ( bar_orientation == Orientation::Vertical )
jumpToClickPos (0, pos + 2);
else
{
@ -781,9 +781,9 @@ void FScrollbar::jumpToClickPos (int pos)
void FScrollbar::avoidScrollOvershoot()
{
// Avoid overshoot
if ( ( scroll_type == SType::scrollPageBackward
if ( ( scroll_type == ScrollType::PageBackward
&& slider_pos < slider_click_stop_pos )
|| ( scroll_type == SType::scrollPageForward
|| ( scroll_type == ScrollType::PageForward
&& slider_pos > slider_click_stop_pos ) )
{
jumpToClickPos (slider_click_stop_pos);
@ -804,9 +804,9 @@ void FScrollbar::changeOnResize()
const FSize& size = getSize();
const std::size_t w = size.getWidth();
const std::size_t h = size.getHeight();
length = ( bar_orientation == fc::vertical ) ? h : w;
length = ( bar_orientation == Orientation::Vertical ) ? h : w;
if ( bar_orientation == fc::vertical )
if ( bar_orientation == Orientation::Vertical )
{
setWidth(FTerm::isNewFont() ? 2 : 1);
setHeight(length);

View File

@ -212,6 +212,9 @@ void FScrollView::setPos (const FPoint& p, bool adjust)
//----------------------------------------------------------------------
void FScrollView::setWidth (std::size_t w, bool adjust)
{
if ( w <= vertical_border_spacing + nf_offset )
return;
FWidget::setWidth (w, adjust);
viewport_geometry.setWidth(w - vertical_border_spacing - nf_offset);
calculateScrollbarPos();
@ -223,6 +226,9 @@ void FScrollView::setWidth (std::size_t w, bool adjust)
//----------------------------------------------------------------------
void FScrollView::setHeight (std::size_t h, bool adjust)
{
if ( h <= horizontal_border_spacing )
return;
FWidget::setHeight (h, adjust);
viewport_geometry.setHeight(h - horizontal_border_spacing);
calculateScrollbarPos();
@ -236,6 +242,11 @@ void FScrollView::setSize (const FSize& size, bool adjust)
{
const std::size_t w = size.getWidth();
const std::size_t h = size.getHeight();
if ( w <= vertical_border_spacing + nf_offset
|| h <= horizontal_border_spacing )
return;
FWidget::setSize (size, adjust);
viewport_geometry.setSize ( w - vertical_border_spacing - nf_offset
, h - horizontal_border_spacing );
@ -309,7 +320,7 @@ bool FScrollView::setBorder (bool enable)
}
//----------------------------------------------------------------------
void FScrollView::setHorizontalScrollBarMode (fc::scrollBarMode mode)
void FScrollView::setHorizontalScrollBarMode (ScrollBarMode mode)
{
h_mode = mode;
@ -318,7 +329,7 @@ void FScrollView::setHorizontalScrollBarMode (fc::scrollBarMode mode)
}
//----------------------------------------------------------------------
void FScrollView::setVerticalScrollBarMode (fc::scrollBarMode mode)
void FScrollView::setVerticalScrollBarMode (ScrollBarMode mode)
{
v_mode = mode;
@ -327,7 +338,7 @@ void FScrollView::setVerticalScrollBarMode (fc::scrollBarMode mode)
}
//----------------------------------------------------------------------
void FScrollView::clearArea (int fillchar)
void FScrollView::clearArea (wchar_t fillchar)
{
if ( viewport )
clearArea (viewport, fillchar);
@ -462,7 +473,7 @@ void FScrollView::drawBorder()
//----------------------------------------------------------------------
void FScrollView::onKeyPress (FKeyEvent* ev)
{
const auto idx = int(ev->key());
const auto idx = ev->key();
if ( key_map.find(idx) != key_map.end() )
{
@ -476,18 +487,13 @@ void FScrollView::onWheel (FWheelEvent* ev)
{
static constexpr int distance = 4;
switch ( ev->getWheel() )
if ( ev->getWheel() == MouseWheel::Up )
{
case fc::WheelUp:
scrollBy (0, -distance);
break;
case fc::WheelDown:
scrollBy (0, distance);
break;
default:
break;
scrollBy (0, -distance);
}
else if ( ev->getWheel() == MouseWheel::Down )
{
scrollBy (0, distance);
}
}
@ -500,9 +506,9 @@ void FScrollView::onFocusIn (FFocusEvent* in_ev)
{
auto prev_element = getFocusWidget();
if ( in_ev->getFocusType() == fc::FocusNextWidget )
if ( in_ev->getFocusType() == FocusTypes::NextWidget )
focusFirstChild();
else if ( in_ev->getFocusType() == fc::FocusPreviousWidget )
else if ( in_ev->getFocusType() == FocusTypes::PreviousWidget )
focusLastChild();
if ( prev_element )
@ -511,7 +517,7 @@ void FScrollView::onFocusIn (FFocusEvent* in_ev)
if ( getFocusWidget() )
getFocusWidget()->redraw();
FFocusEvent cfi (fc::ChildFocusIn_Event);
FFocusEvent cfi (Event::ChildFocusIn);
onChildFocusIn(&cfi);
}
}
@ -560,7 +566,7 @@ void FScrollView::onChildFocusOut (FFocusEvent* out_ev)
const auto& focus = FWidget::getFocusWidget();
if ( out_ev->getFocusType() == fc::FocusNextWidget )
if ( out_ev->getFocusType() == FocusTypes::NextWidget )
{
const auto& last_widget = getLastFocusableWidget(getChildren());
@ -570,7 +576,7 @@ void FScrollView::onChildFocusOut (FFocusEvent* out_ev)
focusNextChild();
}
}
else if ( out_ev->getFocusType() == fc::FocusPreviousWidget )
else if ( out_ev->getFocusType() == FocusTypes::PreviousWidget )
{
const auto& first_widget = getFirstFocusableWidget(getChildren());
@ -717,8 +723,8 @@ void FScrollView::init()
assert ( parent != nullptr );
assert ( ! parent->isInstanceOf("FScrollView") );
initScrollbar (vbar, fc::vertical, &FScrollView::cb_vbarChange);
initScrollbar (hbar, fc::horizontal, &FScrollView::cb_hbarChange);
initScrollbar (vbar, Orientation::Vertical, &FScrollView::cb_vbarChange);
initScrollbar (hbar, Orientation::Horizontal, &FScrollView::cb_hbarChange);
mapKeyFunctions();
resetColors();
setGeometry (FPoint{1, 1}, FSize{4, 4});
@ -754,14 +760,14 @@ void FScrollView::init()
//----------------------------------------------------------------------
inline void FScrollView::mapKeyFunctions()
{
key_map[fc::Fkey_up] = [this] { scrollBy (0, -1); };
key_map[fc::Fkey_down] = [this] { scrollBy (0, 1); };
key_map[fc::Fkey_left] = [this] { scrollBy (-1, 0); };
key_map[fc::Fkey_right] = [this] { scrollBy (1, 0); };
key_map[fc::Fkey_ppage] = [this] { scrollBy (0, -int(getViewportHeight())); };
key_map[fc::Fkey_npage] = [this] { scrollBy (0, int(getViewportHeight())); };
key_map[fc::Fkey_home] = [this] { scrollToY (1); };
key_map[fc::Fkey_end] = \
key_map[FKey::Up] = [this] { scrollBy (0, -1); };
key_map[FKey::Down] = [this] { scrollBy (0, 1); };
key_map[FKey::Left] = [this] { scrollBy (-1, 0); };
key_map[FKey::Right] = [this] { scrollBy (1, 0); };
key_map[FKey::Page_up] = [this] { scrollBy (0, -int(getViewportHeight())); };
key_map[FKey::Page_down] = [this] { scrollBy (0, int(getViewportHeight())); };
key_map[FKey::Home] = [this] { scrollToY (1); };
key_map[FKey::End] = \
[this] ()
{
auto yoffset_end = int(getScrollHeight() - getViewportHeight());
@ -793,24 +799,24 @@ void FScrollView::calculateScrollbarPos() const
//----------------------------------------------------------------------
void FScrollView::setHorizontalScrollBarVisibility() const
{
assert ( v_mode == fc::Auto
|| v_mode == fc::Hidden
|| v_mode == fc::Scroll );
assert ( h_mode == ScrollBarMode::Auto
|| h_mode == ScrollBarMode::Hidden
|| h_mode == ScrollBarMode::Scroll );
switch ( h_mode )
{
case fc::Auto:
case ScrollBarMode::Auto:
if ( getScrollWidth() > getViewportWidth() )
hbar->show();
else
hbar->hide();
break;
case fc::Hidden:
case ScrollBarMode::Hidden:
hbar->hide();
break;
case fc::Scroll:
case ScrollBarMode::Scroll:
hbar->show();
break;
}
@ -819,24 +825,24 @@ void FScrollView::setHorizontalScrollBarVisibility() const
//----------------------------------------------------------------------
void FScrollView::setVerticalScrollBarVisibility() const
{
assert ( v_mode == fc::Auto
|| v_mode == fc::Hidden
|| v_mode == fc::Scroll );
assert ( v_mode == ScrollBarMode::Auto
|| v_mode == ScrollBarMode::Hidden
|| v_mode == ScrollBarMode::Scroll );
switch ( v_mode )
{
case fc::Auto:
case ScrollBarMode::Auto:
if ( getScrollHeight() > getViewportHeight() )
vbar->show();
else
vbar->hide();
break;
case fc::Hidden:
case ScrollBarMode::Hidden:
vbar->hide();
break;
case fc::Scroll:
case ScrollBarMode::Scroll:
vbar->show();
break;
}
@ -865,19 +871,19 @@ void FScrollView::setViewportCursor()
//----------------------------------------------------------------------
void FScrollView::cb_vbarChange (const FWidget*)
{
FScrollbar::SType scrollType = vbar->getScrollType();
FScrollbar::ScrollType scrollType = vbar->getScrollType();
static constexpr int wheel_distance = 4;
int distance{1};
assert ( scrollType == FScrollbar::SType::noScroll
|| scrollType == FScrollbar::SType::scrollJump
|| scrollType == FScrollbar::SType::scrollStepBackward
|| scrollType == FScrollbar::SType::scrollStepForward
|| scrollType == FScrollbar::SType::scrollPageBackward
|| scrollType == FScrollbar::SType::scrollPageForward
|| scrollType == FScrollbar::SType::scrollWheelUp
|| scrollType == FScrollbar::SType::scrollWheelDown );
assert ( scrollType == FScrollbar::ScrollType::None
|| scrollType == FScrollbar::ScrollType::Jump
|| scrollType == FScrollbar::ScrollType::StepBackward
|| scrollType == FScrollbar::ScrollType::StepForward
|| scrollType == FScrollbar::ScrollType::PageBackward
|| scrollType == FScrollbar::ScrollType::PageForward
|| scrollType == FScrollbar::ScrollType::WheelUp
|| scrollType == FScrollbar::ScrollType::WheelDown );
if ( scrollType >= FScrollbar::SType::scrollStepBackward )
if ( scrollType >= FScrollbar::ScrollType::StepBackward )
{
update_scrollbar = true;
}
@ -888,32 +894,32 @@ void FScrollView::cb_vbarChange (const FWidget*)
switch ( scrollType )
{
case FScrollbar::SType::noScroll:
case FScrollbar::ScrollType::None:
break;
case FScrollbar::SType::scrollPageBackward:
case FScrollbar::ScrollType::PageBackward:
distance = int(getViewportHeight());
// fall through
case FScrollbar::SType::scrollStepBackward:
case FScrollbar::ScrollType::StepBackward:
scrollBy (0, -distance);
break;
case FScrollbar::SType::scrollPageForward:
case FScrollbar::ScrollType::PageForward:
distance = int(getViewportHeight());
// fall through
case FScrollbar::SType::scrollStepForward:
case FScrollbar::ScrollType::StepForward:
scrollBy (0, distance);
break;
case FScrollbar::SType::scrollJump:
case FScrollbar::ScrollType::Jump:
scrollToY (1 + int(vbar->getValue()));
break;
case FScrollbar::SType::scrollWheelUp:
case FScrollbar::ScrollType::WheelUp:
scrollBy (0, -wheel_distance);
break;
case FScrollbar::SType::scrollWheelDown:
case FScrollbar::ScrollType::WheelDown:
scrollBy (0, wheel_distance);
break;
}
@ -924,19 +930,19 @@ void FScrollView::cb_vbarChange (const FWidget*)
//----------------------------------------------------------------------
void FScrollView::cb_hbarChange (const FWidget*)
{
FScrollbar::SType scrollType = hbar->getScrollType();
FScrollbar::ScrollType scrollType = hbar->getScrollType();
static constexpr int wheel_distance = 4;
int distance{1};
assert ( scrollType == FScrollbar::SType::noScroll
|| scrollType == FScrollbar::SType::scrollJump
|| scrollType == FScrollbar::SType::scrollStepBackward
|| scrollType == FScrollbar::SType::scrollStepForward
|| scrollType == FScrollbar::SType::scrollPageBackward
|| scrollType == FScrollbar::SType::scrollPageForward
|| scrollType == FScrollbar::SType::scrollWheelUp
|| scrollType == FScrollbar::SType::scrollWheelDown );
assert ( scrollType == FScrollbar::ScrollType::None
|| scrollType == FScrollbar::ScrollType::Jump
|| scrollType == FScrollbar::ScrollType::StepBackward
|| scrollType == FScrollbar::ScrollType::StepForward
|| scrollType == FScrollbar::ScrollType::PageBackward
|| scrollType == FScrollbar::ScrollType::PageForward
|| scrollType == FScrollbar::ScrollType::WheelUp
|| scrollType == FScrollbar::ScrollType::WheelDown );
if ( scrollType >= FScrollbar::SType::scrollStepBackward )
if ( scrollType >= FScrollbar::ScrollType::StepBackward )
{
update_scrollbar = true;
}
@ -947,32 +953,32 @@ void FScrollView::cb_hbarChange (const FWidget*)
switch ( scrollType )
{
case FScrollbar::SType::noScroll:
case FScrollbar::ScrollType::None:
break;
case FScrollbar::SType::scrollPageBackward:
case FScrollbar::ScrollType::PageBackward:
distance = int(getViewportWidth());
// fall through
case FScrollbar::SType::scrollStepBackward:
case FScrollbar::ScrollType::StepBackward:
scrollBy (-distance, 0);
break;
case FScrollbar::SType::scrollPageForward:
case FScrollbar::ScrollType::PageForward:
distance = int(getViewportWidth());
// fall through
case FScrollbar::SType::scrollStepForward:
case FScrollbar::ScrollType::StepForward:
scrollBy (distance, 0);
break;
case FScrollbar::SType::scrollJump:
case FScrollbar::ScrollType::Jump:
scrollToX (1 + int(hbar->getValue()));
break;
case FScrollbar::SType::scrollWheelUp:
case FScrollbar::ScrollType::WheelUp:
scrollBy (-wheel_distance, 0);
break;
case FScrollbar::SType::scrollWheelDown:
case FScrollbar::ScrollType::WheelDown:
scrollBy (wheel_distance, 0);
break;
}

View File

@ -91,8 +91,8 @@ bool FSpinBox::setFocus (bool enable)
bool FSpinBox::setShadow (bool enable)
{
if ( enable
&& FTerm::getEncoding() != fc::VT100
&& FTerm::getEncoding() != fc::ASCII )
&& FTerm::getEncoding() != Encoding::VT100
&& FTerm::getEncoding() != Encoding::ASCII )
{
setFlags().shadow = true;
setShadowSize(FSize{1, 1});
@ -174,28 +174,33 @@ void FSpinBox::onKeyPress (FKeyEvent* ev)
const FKey key = ev->key();
switch ( key )
if ( key == FKey::Tab )
{
case fc::Fkey_tab:
focusNextChild();
break;
case fc::Fkey_btab:
focusPrevChild();
break;
case fc::Fkey_up:
increaseValue();
ev->accept();
break;
case fc::Fkey_down:
decreaseValue();
ev->accept();
break;
default:
break;
focusNextChild();
}
else if ( key == FKey::Back_tab )
{
focusPrevChild();
}
else if ( key == FKey::Up )
{
increaseValue();
ev->accept();
}
else if ( key == FKey::Down )
{
decreaseValue();
ev->accept();
}
else if ( key == FKey::Page_up )
{
increaseValue(10);
ev->accept();
}
else if ( key == FKey::Page_down )
{
decreaseValue(10);
ev->accept();
}
if ( ev->isAccepted() )
@ -205,8 +210,8 @@ void FSpinBox::onKeyPress (FKeyEvent* ev)
//----------------------------------------------------------------------
void FSpinBox::onMouseDown (FMouseEvent* ev)
{
if ( ev->getButton() != fc::LeftButton
&& ev->getButton() != fc::MiddleButton )
if ( ev->getButton() != MouseButton::Left
&& ev->getButton() != MouseButton::Middle )
return;
forceFocus();
@ -219,7 +224,7 @@ void FSpinBox::onMouseDown (FMouseEvent* ev)
if ( mouse_x == int(getWidth()) - 1 && mouse_y == 1 )
{
spining_state = FSpinBox::spinDown;
spining_state = SpiningState::Down;
decreaseValue();
updateInputField();
threshold_reached = false;
@ -227,7 +232,7 @@ void FSpinBox::onMouseDown (FMouseEvent* ev)
}
else if ( mouse_x == int(getWidth()) && mouse_y == 1 )
{
spining_state = FSpinBox::spinUp;
spining_state = SpiningState::Up;
increaseValue();
updateInputField();
threshold_reached = false;
@ -241,32 +246,27 @@ void FSpinBox::onMouseDown (FMouseEvent* ev)
void FSpinBox::onMouseUp (FMouseEvent*)
{
delOwnTimers();
spining_state = FSpinBox::noSpin;
spining_state = SpiningState::None;
}
//----------------------------------------------------------------------
void FSpinBox::onWheel (FWheelEvent* ev)
{
const int wheel = ev->getWheel();
const MouseWheel wheel = ev->getWheel();
delOwnTimers();
forceFocus();
spining_state = FSpinBox::noSpin;
spining_state = SpiningState::None;
switch ( wheel )
if ( wheel == MouseWheel::Up )
{
case fc::WheelUp:
increaseValue();
updateInputField();
break;
case fc::WheelDown:
decreaseValue();
updateInputField();
break;
default:
break;
increaseValue();
updateInputField();
}
else if ( wheel == MouseWheel::Down )
{
decreaseValue();
updateInputField();
}
}
@ -280,21 +280,21 @@ void FSpinBox::onTimer (FTimerEvent*)
addTimer(repeat_time);
}
assert ( spining_state == FSpinBox::noSpin
|| spining_state == FSpinBox::spinUp
|| spining_state == FSpinBox::spinDown );
assert ( spining_state == SpiningState::None
|| spining_state == SpiningState::Up
|| spining_state == SpiningState::Down );
switch ( spining_state )
{
case FSpinBox::noSpin:
case SpiningState::None:
break;
case FSpinBox::spinUp:
case SpiningState::Up:
increaseValue();
updateInputField();
break;
case FSpinBox::spinDown:
case SpiningState::Down:
decreaseValue();
updateInputField();
break;
@ -355,9 +355,9 @@ void FSpinBox::draw()
print() << FPoint{int(getWidth()) - 1, 1}
<< dec_button_color
<< fc::BlackDownPointingTriangle // ▼
<< UniChar::BlackDownPointingTriangle // ▼
<< inc_button_color
<< fc::BlackUpPointingTriangle; // ▲
<< UniChar::BlackUpPointingTriangle; // ▲
if ( getFlags().shadow )
drawShadow(this);
@ -373,11 +373,15 @@ inline void FSpinBox::updateInputField()
}
//----------------------------------------------------------------------
inline void FSpinBox::increaseValue()
inline void FSpinBox::increaseValue (sInt64 n)
{
if ( value < max )
{
value++;
if ( value < max - n )
value += n;
else
value = max;
processChanged();
}
else
@ -385,11 +389,15 @@ inline void FSpinBox::increaseValue()
}
//----------------------------------------------------------------------
inline void FSpinBox::decreaseValue()
inline void FSpinBox::decreaseValue (sInt64 n)
{
if ( value > min )
{
value--;
if ( value > min + n )
value -= n;
else
value = min;
processChanged();
}
else

View File

@ -69,7 +69,7 @@ void FStartOptions::setDefault()
color_change = true;
vgafont = false;
newfont = false;
encoding = fc::UNKNOWN;
encoding = Encoding::Unknown;
#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST)
meta_sends_escape = true;

View File

@ -237,7 +237,7 @@ void FStatusBar::drawMessage()
if ( hasKeys )
{
x += 2;
print (fc::BoxDrawingsVertical); // │
print (UniChar::BoxDrawingsVertical); // │
print (' ');
}
@ -331,7 +331,7 @@ void FStatusBar::onMouseDown (FMouseEvent* ev)
if ( hasActivatedKey() )
return;
if ( ev->getButton() != fc::LeftButton )
if ( ev->getButton() != MouseButton::Left )
{
mouse_down = false;
@ -392,7 +392,7 @@ void FStatusBar::onMouseUp (FMouseEvent* ev)
if ( hasActivatedKey() )
return;
if ( ev->getButton() != fc::LeftButton )
if ( ev->getButton() != MouseButton::Left )
return;
if ( mouse_down )
@ -439,7 +439,7 @@ void FStatusBar::onMouseMove (FMouseEvent* ev)
if ( hasActivatedKey() )
return;
if ( ev->getButton() != fc::LeftButton )
if ( ev->getButton() != MouseButton::Left )
return;
if ( mouse_down && ! key_list.empty() )
@ -639,7 +639,7 @@ void FStatusBar::drawKey (FKeyList::const_iterator iter)
if ( FTerm::hasHalfBlockCharacter() )
{
setColor (wc->statusbar_bg, wc->statusbar_active_hotkey_bg);
print (fc::LeftHalfBlock); // ▐
print (UniChar::LeftHalfBlock); // ▐
}
else
print (' ');
@ -654,7 +654,7 @@ void FStatusBar::drawKey (FKeyList::const_iterator iter)
// Not the last element
setColor (wc->statusbar_separator_fg, wc->statusbar_bg);
x++;
print (fc::BoxDrawingsVertical); // │
print (UniChar::BoxDrawingsVertical); // │
}
}
@ -686,7 +686,7 @@ void FStatusBar::drawActiveKey (FKeyList::const_iterator iter)
print (item->getText());
x++;
setColor (wc->statusbar_bg, wc->statusbar_active_hotkey_bg);
print (fc::RightHalfBlock); // ▌
print (UniChar::RightHalfBlock); // ▌
}
else
{

View File

@ -67,6 +67,11 @@ FString::FString (std::size_t len, wchar_t c)
*--pe = c;
}
//----------------------------------------------------------------------
FString::FString (std::size_t len, const UniChar& c)
: FString(len, wchar_t(c))
{ }
//----------------------------------------------------------------------
FString::FString (const FString& s) // copy constructor
{
@ -124,13 +129,10 @@ FString::FString (const char s[])
}
//----------------------------------------------------------------------
FString::FString (fc::SpecialCharacter c)
FString::FString (const UniChar& c)
{
if ( c )
{
std::array<wchar_t, 2> s{{ static_cast<wchar_t>(c), L'\0' }};
_assign (s.data());
}
std::array<wchar_t, 2> s{{ static_cast<wchar_t>(c), L'\0' }};
_assign (s.data());
}
//----------------------------------------------------------------------
@ -214,7 +216,7 @@ FString& FString::operator << (const FString& s)
}
//----------------------------------------------------------------------
FString& FString::operator << (fc::SpecialCharacter c)
FString& FString::operator << (const UniChar& c)
{
FString s{static_cast<wchar_t>(c)};
_insert (length, s.length, s.string);

View File

@ -63,22 +63,17 @@ void FSwitch::setText (const FString& txt)
//----------------------------------------------------------------------
void FSwitch::onKeyPress (FKeyEvent* ev)
{
switch ( ev->key() )
const auto key = ev->key();
if ( key == FKey::Home || key == FKey::Left )
{
case fc::Fkey_home:
case fc::Fkey_left:
setChecked();
ev->accept();
break;
case fc::Fkey_end:
case fc::Fkey_right:
unsetChecked();
ev->accept();
break;
default:
break;
setChecked();
ev->accept();
}
else if ( key == FKey::End || key == FKey::Right )
{
unsetChecked();
ev->accept();
}
if ( ev->isAccepted() )
@ -92,7 +87,7 @@ void FSwitch::onMouseDown (FMouseEvent* ev)
{
FToggleButton::onMouseDown(ev);
if ( ev->getButton() != fc::LeftButton )
if ( ev->getButton() != MouseButton::Left )
return;
button_pressed = true;
@ -104,7 +99,7 @@ void FSwitch::onMouseUp (FMouseEvent* ev)
{
FToggleButton::onMouseUp(ev);
if ( ev->getButton() != fc::LeftButton )
if ( ev->getButton() != MouseButton::Left )
return;
button_pressed = false;

View File

@ -580,7 +580,7 @@ bool FTerm::setVGAFont()
data->setVGAFont(true);
// Set font in xterm to vga
getFTermXTerminal()->setFont("vga");
data->setTermEncoding (fc::PC);
data->setTermEncoding (Encoding::PC);
data->setNewFont(false);
}
#if defined(__linux__)
@ -755,7 +755,7 @@ const char* FTerm::moveCursorString (int xold, int yold, int xnew, int ynew)
return opti_move->moveCursor (xold, yold, xnew, ynew);
}
else
return FTermcap::encodeMotionParameter(TCAP(fc::t_cursor_address), xnew, ynew);
return FTermcap::encodeMotionParameter(TCAP(t_cursor_address), xnew, ynew);
}
//----------------------------------------------------------------------
@ -842,7 +842,7 @@ void FTerm::setTermTitle (const FString& title)
}
//----------------------------------------------------------------------
void FTerm::setKDECursor (fc::kdeKonsoleCursorShape style)
void FTerm::setKDECursor (KdeKonsoleCursorShape style)
{
// Set cursor style in KDE konsole
@ -866,8 +866,8 @@ void FTerm::saveColorMap()
//----------------------------------------------------------------------
void FTerm::resetColorMap()
{
const auto& oc = TCAP(fc::t_orig_colors);
const auto& op = TCAP(fc::t_orig_pair);
const auto& oc = TCAP(t_orig_colors);
const auto& op = TCAP(t_orig_pair);
if ( oc )
putstring (oc);
@ -888,8 +888,8 @@ void FTerm::setPalette (FColor index, int r, int g, int b)
{
// Redefine RGB color value for a palette entry
const auto& Ic = TCAP(fc::t_initialize_color);
const auto& Ip = TCAP(fc::t_initialize_pair);
const auto& Ic = TCAP(t_initialize_color);
const auto& Ip = TCAP(t_initialize_pair);
bool state{false};
index = FOptiAttr::vga2ansi(index);
@ -970,44 +970,44 @@ void FTerm::resetBeep()
//----------------------------------------------------------------------
void FTerm::beep()
{
if ( TCAP(fc::t_bell) )
if ( TCAP(t_bell) )
{
putstring (TCAP(fc::t_bell));
putstring (TCAP(t_bell));
std::fflush(stdout);
}
}
//----------------------------------------------------------------------
void FTerm::setEncoding (fc::encoding enc)
void FTerm::setEncoding (Encoding enc)
{
const auto& data = FTerm::getFTermData();
data->setTermEncoding (enc);
assert ( enc == fc::UTF8
|| enc == fc::VT100 // VT100 line drawing
|| enc == fc::PC // CP-437
|| enc == fc::ASCII
|| enc == fc::UNKNOWN
|| enc == fc::NUM_OF_ENCODINGS );
assert ( enc == Encoding::UTF8
|| enc == Encoding::VT100 // VT100 line drawing
|| enc == Encoding::PC // CP-437
|| enc == Encoding::ASCII
|| enc == Encoding::Unknown
|| enc == Encoding::NUM_OF_ENCODINGS );
// Set the new putchar() function pointer
switch ( enc )
{
case fc::UTF8:
case Encoding::UTF8:
putchar() = &FTerm::putchar_UTF8;
break;
case fc::VT100:
case fc::PC:
case Encoding::VT100:
case Encoding::PC:
if ( isXTerminal() && data->hasUTF8Console() )
putchar() = &FTerm::putchar_UTF8;
else
putchar() = &FTerm::putchar_ASCII;
break;
case fc::ASCII:
case fc::UNKNOWN:
case fc::NUM_OF_ENCODINGS:
case Encoding::ASCII:
case Encoding::Unknown:
case Encoding::NUM_OF_ENCODINGS:
putchar() = &FTerm::putchar_ASCII;
}
@ -1015,18 +1015,18 @@ void FTerm::setEncoding (fc::encoding enc)
{
const auto& opti_move = FTerm::getFOptiMove();
if ( enc == fc::VT100 || enc == fc::PC )
if ( enc == Encoding::VT100 || enc == Encoding::PC )
{
const char* empty{nullptr};
opti_move->set_tabular (empty);
}
else
opti_move->set_tabular (TCAP(fc::t_tab));
opti_move->set_tabular (TCAP(t_tab));
}
}
//----------------------------------------------------------------------
fc::encoding FTerm::getEncoding()
Encoding FTerm::getEncoding()
{
const auto& data = FTerm::getFTermData();
return data->getTermEncoding();
@ -1062,20 +1062,20 @@ wchar_t FTerm::charEncode (wchar_t c)
}
//----------------------------------------------------------------------
wchar_t FTerm::charEncode (wchar_t c, fc::encoding enc)
wchar_t FTerm::charEncode (wchar_t c, Encoding enc)
{
wchar_t ch_enc = c;
for (auto&& entry : fc::character)
{
if ( entry[fc::UTF8] == uInt(c) )
if ( entry.unicode == c )
{
ch_enc = wchar_t(entry[enc]);
ch_enc = getCharacter(entry, enc);
break;
}
}
if ( enc == fc::PC && ch_enc == c )
if ( enc == Encoding::PC && ch_enc == c )
ch_enc = finalcut::unicode_to_cp437(c);
return ch_enc;
@ -1084,9 +1084,9 @@ wchar_t FTerm::charEncode (wchar_t c, fc::encoding enc)
//----------------------------------------------------------------------
bool FTerm::scrollTermForward()
{
if ( TCAP(fc::t_scroll_forward) )
if ( TCAP(t_scroll_forward) )
{
putstring (TCAP(fc::t_scroll_forward));
putstring (TCAP(t_scroll_forward));
std::fflush(stdout);
return true;
}
@ -1097,9 +1097,9 @@ bool FTerm::scrollTermForward()
//----------------------------------------------------------------------
bool FTerm::scrollTermReverse()
{
if ( TCAP(fc::t_scroll_reverse) )
if ( TCAP(t_scroll_reverse) )
{
putstring (TCAP(fc::t_scroll_reverse));
putstring (TCAP(t_scroll_reverse));
std::fflush(stdout);
return true;
}
@ -1186,7 +1186,7 @@ void FTerm::initScreenSettings()
#endif
// set xterm underline cursor
getFTermXTerminal()->setCursorStyle (fc::blinking_underline);
getFTermXTerminal()->setCursorStyle (XTermCursorStyle::BlinkingUnderline);
// set xterm color settings to defaults
getFTermXTerminal()->setDefaults();
@ -1276,13 +1276,13 @@ void FTerm::init_alt_charset()
std::unordered_map<uChar, uChar> vt100_alt_char;
if ( TCAP(fc::t_acs_chars) )
if ( TCAP(t_acs_chars) )
{
for (std::size_t n{0}; TCAP(fc::t_acs_chars)[n]; n += 2)
for (std::size_t n{0}; TCAP(t_acs_chars)[n]; n += 2)
{
// insert the VT100 key/value pairs into a map
const auto p1 = uChar(TCAP(fc::t_acs_chars)[n]);
const auto p2 = uChar(TCAP(fc::t_acs_chars)[n + 1]);
const auto p1 = uChar(TCAP(t_acs_chars)[n]);
const auto p2 = uChar(TCAP(t_acs_chars)[n + 1]);
vt100_alt_char[p1] = p2;
}
}
@ -1290,23 +1290,21 @@ void FTerm::init_alt_charset()
// Update array 'character' with discovered VT100 pairs
for (auto&& pair : fc::dec_special_graphics)
{
const auto vt100 = std::size_t(fc::DECSpecialGraphics::vt100);
const auto utf8 = std::size_t(fc::DECSpecialGraphics::utf8);
const auto keyChar = uChar(pair[vt100]);
const auto altChar = uChar(vt100_alt_char[keyChar]);
const auto utf8char = uInt(pair[utf8]);
const auto keyChar = uChar(pair.key);
const auto altChar = wchar_t(vt100_alt_char[keyChar]);
const auto utf8char = wchar_t(pair.unicode);
const auto p = std::find_if ( fc::character.begin()
, fc::character.end()
, [&utf8char] (std::array<uInt, 4> entry)
{ return entry[0] == utf8char; } );
, [&utf8char] (fc::CharEncodeMap entry)
{ return entry.unicode == utf8char; } );
if ( p != fc::character.end() ) // found in character
{
const auto item = std::size_t(std::distance(fc::character.begin(), p));
if ( altChar ) // update alternate character set
fc::character[item][fc::VT100] = altChar;
getCharacter(fc::character[item], Encoding::VT100) = altChar;
else // delete VT100 char in character
fc::character[item][fc::VT100] = 0;
getCharacter(fc::character[item], Encoding::VT100) = L'\0';
}
}
}
@ -1326,40 +1324,40 @@ void FTerm::init_pc_charset()
const auto& data = FTerm::getFTermData();
// Fallback if tcap "S2" is not found
if ( ! TCAP(fc::t_enter_pc_charset_mode) )
if ( ! TCAP(t_enter_pc_charset_mode) )
{
if ( data->hasUTF8Console() )
{
// Select iso8859-1 + null mapping
TCAP(fc::t_enter_pc_charset_mode) = ESC "%@" ESC "(U";
TCAP(t_enter_pc_charset_mode) = ESC "%@" ESC "(U";
}
else
{
// Select null mapping
TCAP(fc::t_enter_pc_charset_mode) = ESC "(U";
TCAP(t_enter_pc_charset_mode) = ESC "(U";
}
opti_attr->set_enter_pc_charset_mode \
(TCAP(fc::t_enter_pc_charset_mode));
(TCAP(t_enter_pc_charset_mode));
reinit = true;
}
// Fallback if tcap "S3" is not found
if ( ! TCAP(fc::t_exit_pc_charset_mode) )
if ( ! TCAP(t_exit_pc_charset_mode) )
{
if ( data->hasUTF8Console() )
{
// Select ascii mapping + utf8
TCAP(fc::t_exit_pc_charset_mode) = ESC "(B" ESC "%G";
TCAP(t_exit_pc_charset_mode) = ESC "(B" ESC "%G";
}
else
{
// Select ascii mapping
TCAP(fc::t_enter_pc_charset_mode) = ESC "(B";
TCAP(t_enter_pc_charset_mode) = ESC "(B";
}
opti_attr->set_exit_pc_charset_mode \
(TCAP(fc::t_exit_pc_charset_mode));
(TCAP(t_exit_pc_charset_mode));
reinit = true;
}
}
@ -1379,22 +1377,22 @@ void FTerm::init_cygwin_charmap()
// PC encoding changes
for (auto&& entry : fc::character)
{
if ( entry[fc::UTF8] == fc::BlackUpPointingTriangle ) // ▲
entry[fc::PC] = 0x18;
if ( entry.unicode == UniChar::BlackUpPointingTriangle ) // ▲
entry.pc = 0x18;
if ( entry[fc::UTF8] == fc::BlackDownPointingTriangle ) // ▼
entry[fc::PC] = 0x19;
if ( entry.unicode == UniChar::BlackDownPointingTriangle ) // ▼
entry.pc = 0x19;
if ( entry[fc::UTF8] == fc::InverseBullet // ◘
|| entry[fc::UTF8] == fc::InverseWhiteCircle // ◙
|| entry[fc::UTF8] == fc::UpDownArrow // ↕
|| entry[fc::UTF8] == fc::LeftRightArrow // ↔
|| entry[fc::UTF8] == fc::DoubleExclamationMark // ‼
|| entry[fc::UTF8] == fc::BlackRectangle // ▬
|| entry[fc::UTF8] == fc::RightwardsArrow // →
|| entry[fc::UTF8] == fc::Section // §
|| entry[fc::UTF8] == fc::SquareRoot ) // SquareRoot √
entry[fc::PC] = entry[fc::ASCII];
if ( entry.unicode == UniChar::InverseBullet // ◘
|| entry.unicode == UniChar::InverseWhiteCircle // ◙
|| entry.unicode == UniChar::UpDownArrow // ↕
|| entry.unicode == UniChar::LeftRightArrow // ↔
|| entry.unicode == UniChar::DoubleExclamationMark // ‼
|| entry.unicode == UniChar::BlackRectangle // ▬
|| entry.unicode == UniChar::RightwardsArrow // →
|| entry.unicode == UniChar::Section // §
|| entry.unicode == UniChar::SquareRoot ) // SquareRoot √
entry.pc = entry.ascii;
}
// General encoding changes
@ -1433,8 +1431,8 @@ void FTerm::init_teraterm_charmap()
return;
for (auto&& entry : fc::character)
if ( entry[fc::PC] < 0x20 )
entry[fc::PC] = entry[fc::ASCII];
if ( entry.pc < 0x20 )
entry.pc = entry.ascii;
}
//----------------------------------------------------------------------
@ -1460,26 +1458,26 @@ void FTerm::init_optiMove()
FOptiMove::TermEnv optimove_env =
{
TCAP(fc::t_cursor_home),
TCAP(fc::t_carriage_return),
TCAP(fc::t_cursor_to_ll),
TCAP(fc::t_tab),
TCAP(fc::t_back_tab),
TCAP(fc::t_cursor_up),
TCAP(fc::t_cursor_down),
TCAP(fc::t_cursor_left),
TCAP(fc::t_cursor_right),
TCAP(fc::t_cursor_address),
TCAP(fc::t_column_address),
TCAP(fc::t_row_address),
TCAP(fc::t_parm_up_cursor),
TCAP(fc::t_parm_down_cursor),
TCAP(fc::t_parm_left_cursor),
TCAP(fc::t_parm_right_cursor),
TCAP(fc::t_erase_chars),
TCAP(fc::t_repeat_char),
TCAP(fc::t_clr_bol),
TCAP(fc::t_clr_eol),
TCAP(t_cursor_home),
TCAP(t_carriage_return),
TCAP(t_cursor_to_ll),
TCAP(t_tab),
TCAP(t_back_tab),
TCAP(t_cursor_up),
TCAP(t_cursor_down),
TCAP(t_cursor_left),
TCAP(t_cursor_right),
TCAP(t_cursor_address),
TCAP(t_column_address),
TCAP(t_row_address),
TCAP(t_parm_up_cursor),
TCAP(t_parm_down_cursor),
TCAP(t_parm_left_cursor),
TCAP(t_parm_right_cursor),
TCAP(t_erase_chars),
TCAP(t_repeat_char),
TCAP(t_clr_bol),
TCAP(t_clr_eol),
FTermcap::tabstop,
FTermcap::automatic_left_margin,
FTermcap::eat_nl_glitch
@ -1496,41 +1494,41 @@ void FTerm::init_optiAttr()
FOptiAttr::TermEnv optiattr_env =
{
TCAP(fc::t_enter_bold_mode),
TCAP(fc::t_exit_bold_mode),
TCAP(fc::t_enter_dim_mode),
TCAP(fc::t_exit_dim_mode),
TCAP(fc::t_enter_italics_mode),
TCAP(fc::t_exit_italics_mode),
TCAP(fc::t_enter_underline_mode),
TCAP(fc::t_exit_underline_mode),
TCAP(fc::t_enter_blink_mode),
TCAP(fc::t_exit_blink_mode),
TCAP(fc::t_enter_reverse_mode),
TCAP(fc::t_exit_reverse_mode),
TCAP(fc::t_enter_standout_mode),
TCAP(fc::t_exit_standout_mode),
TCAP(fc::t_enter_secure_mode),
TCAP(fc::t_exit_secure_mode),
TCAP(fc::t_enter_protected_mode),
TCAP(fc::t_exit_protected_mode),
TCAP(fc::t_enter_crossed_out_mode),
TCAP(fc::t_exit_crossed_out_mode),
TCAP(fc::t_enter_dbl_underline_mode),
TCAP(fc::t_exit_dbl_underline_mode),
TCAP(fc::t_set_attributes),
TCAP(fc::t_exit_attribute_mode),
TCAP(fc::t_enter_alt_charset_mode),
TCAP(fc::t_exit_alt_charset_mode),
TCAP(fc::t_enter_pc_charset_mode),
TCAP(fc::t_exit_pc_charset_mode),
TCAP(fc::t_set_a_foreground),
TCAP(fc::t_set_a_background),
TCAP(fc::t_set_foreground),
TCAP(fc::t_set_background),
TCAP(fc::t_orig_pair),
TCAP(fc::t_orig_pair),
TCAP(fc::t_orig_colors),
TCAP(t_enter_bold_mode),
TCAP(t_exit_bold_mode),
TCAP(t_enter_dim_mode),
TCAP(t_exit_dim_mode),
TCAP(t_enter_italics_mode),
TCAP(t_exit_italics_mode),
TCAP(t_enter_underline_mode),
TCAP(t_exit_underline_mode),
TCAP(t_enter_blink_mode),
TCAP(t_exit_blink_mode),
TCAP(t_enter_reverse_mode),
TCAP(t_exit_reverse_mode),
TCAP(t_enter_standout_mode),
TCAP(t_exit_standout_mode),
TCAP(t_enter_secure_mode),
TCAP(t_exit_secure_mode),
TCAP(t_enter_protected_mode),
TCAP(t_exit_protected_mode),
TCAP(t_enter_crossed_out_mode),
TCAP(t_exit_crossed_out_mode),
TCAP(t_enter_dbl_underline_mode),
TCAP(t_exit_dbl_underline_mode),
TCAP(t_set_attributes),
TCAP(t_exit_attribute_mode),
TCAP(t_enter_alt_charset_mode),
TCAP(t_exit_alt_charset_mode),
TCAP(t_enter_pc_charset_mode),
TCAP(t_exit_pc_charset_mode),
TCAP(t_set_a_foreground),
TCAP(t_set_a_background),
TCAP(t_set_foreground),
TCAP(t_set_background),
TCAP(t_orig_pair),
TCAP(t_orig_pair),
TCAP(t_orig_colors),
FTermcap::max_color,
FTermcap::attr_without_color,
FTermcap::ansi_default_color
@ -1633,7 +1631,7 @@ void FTerm::init_encoding()
init_tab_quirks();
if ( getStartOptions().encoding != fc::UNKNOWN )
if ( getStartOptions().encoding != Encoding::Unknown )
{
setEncoding(getStartOptions().encoding);
}
@ -1646,11 +1644,11 @@ inline void FTerm::init_encoding_set()
const auto& data = FTerm::getFTermData();
auto& encoding_list = data->getEncodingList();
encoding_list["UTF8"] = fc::UTF8;
encoding_list["UTF-8"] = fc::UTF8;
encoding_list["VT100"] = fc::VT100; // VT100 line drawing
encoding_list["PC"] = fc::PC; // CP-437
encoding_list["ASCII"] = fc::ASCII;
encoding_list["UTF8"] = Encoding::UTF8;
encoding_list["UTF-8"] = Encoding::UTF8;
encoding_list["VT100"] = Encoding::VT100; // VT100 line drawing
encoding_list["PC"] = Encoding::PC; // CP-437
encoding_list["ASCII"] = Encoding::ASCII;
}
//----------------------------------------------------------------------
@ -1665,7 +1663,7 @@ void FTerm::init_term_encoding()
&& ! std::strcmp(nl_langinfo(CODESET), "UTF-8") )
{
data->setUTF8Console(true);
data->setTermEncoding (fc::UTF8);
data->setTermEncoding (Encoding::UTF8);
putchar() = &FTerm::putchar_UTF8; // function pointer
data->setUTF8(true);
setUTF8(true);
@ -1674,16 +1672,16 @@ void FTerm::init_term_encoding()
}
else if ( fsys->isTTY(stdout_no)
&& (std::strlen(termtype) > 0)
&& (TCAP(fc::t_exit_alt_charset_mode) != nullptr) )
&& (TCAP(t_exit_alt_charset_mode) != nullptr) )
{
data->setVT100Console (true);
data->setTermEncoding (fc::VT100);
data->setTermEncoding (Encoding::VT100);
putchar() = &FTerm::putchar_ASCII; // function pointer
}
else
{
data->setASCIIConsole (true);
data->setTermEncoding (fc::ASCII);
data->setTermEncoding (Encoding::ASCII);
putchar() = &FTerm::putchar_ASCII; // function pointer
}
}
@ -1697,11 +1695,11 @@ void FTerm::init_individual_term_encoding()
|| (isPuttyTerminal() && ! data->isUTF8())
|| (isTeraTerm() && ! data->isUTF8()) )
{
data->setTermEncoding (fc::PC);
data->setTermEncoding (Encoding::PC);
putchar() = &FTerm::putchar_ASCII; // function pointer
if ( hasUTF8()
&& getStartOptions().encoding == fc::UNKNOWN
&& getStartOptions().encoding == Encoding::Unknown
&& isXTerminal() )
putchar() = &FTerm::putchar_UTF8; // function pointer
}
@ -1712,7 +1710,7 @@ void FTerm::init_force_vt100_encoding()
{
const auto& data = FTerm::getFTermData();
data->setVT100Console(true);
data->setTermEncoding (fc::VT100);
data->setTermEncoding (Encoding::VT100);
putchar() = &FTerm::putchar_ASCII; // function pointer
}
@ -1725,10 +1723,10 @@ void FTerm::init_utf8_without_alt_charset()
const auto& data = FTerm::getFTermData();
if ( FTermcap::no_utf8_acs_chars && data->isUTF8()
&& data->getTermEncoding() == fc::VT100 )
&& data->getTermEncoding() == Encoding::VT100 )
{
data->setASCIIConsole(true);
data->setTermEncoding (fc::ASCII);
data->setTermEncoding (Encoding::ASCII);
putchar() = &FTerm::putchar_ASCII; // function pointer
}
}
@ -1743,7 +1741,7 @@ void FTerm::init_tab_quirks()
const auto& data = FTerm::getFTermData();
const auto& enc = data->getTermEncoding();
if ( enc == fc::VT100 || enc == fc::PC )
if ( enc == Encoding::VT100 || enc == Encoding::PC )
{
const char* empty{nullptr};
const auto& opti_move = FTerm::getFOptiMove();
@ -1851,15 +1849,15 @@ void FTerm::restoreColorPalette()
//----------------------------------------------------------------------
void FTerm::setInsertCursorStyle()
{
getFTermXTerminal()->setCursorStyle (fc::blinking_underline);
setKDECursor(fc::UnderlineCursor);
getFTermXTerminal()->setCursorStyle (XTermCursorStyle::BlinkingUnderline);
setKDECursor(KdeKonsoleCursorShape::Underline);
#if defined(__linux__)
const auto& linux_console = FTerm::getFTermLinux();
linux_console->setCursorStyle (fc::underscore_cursor);
linux_console->setCursorStyle (LinuxConsoleCursorStyle::Underscore);
#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST)
const auto& freebsd_console = FTerm::getFTermFreeBSD();
freebsd_console->setCursorStyle (fc::destructive_cursor);
freebsd_console->setCursorStyle (FreeBSDConsoleCursorStyle::Destructive);
#endif
if ( isUrxvtTerminal() )
@ -1869,15 +1867,15 @@ void FTerm::setInsertCursorStyle()
//----------------------------------------------------------------------
void FTerm::setOverwriteCursorStyle()
{
getFTermXTerminal()->setCursorStyle (fc::steady_block);
setKDECursor(fc::BlockCursor);
getFTermXTerminal()->setCursorStyle (XTermCursorStyle::SteadyBlock);
setKDECursor(KdeKonsoleCursorShape::Block);
#if defined(__linux__)
const auto& linux_console = FTerm::getFTermLinux();
linux_console->setCursorStyle (fc::full_block_cursor);
linux_console->setCursorStyle (LinuxConsoleCursorStyle::FullBlock);
#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST)
const auto& freebsd_console = FTerm::getFTermFreeBSD();
freebsd_console->setCursorStyle (fc::normal_cursor);
freebsd_console->setCursorStyle (FreeBSDConsoleCursorStyle::Normal);
#endif
if ( isUrxvtTerminal() )
@ -1891,8 +1889,8 @@ const char* FTerm::enableCursorString()
static constexpr std::size_t SIZE = 32;
static std::array<char, SIZE> enable_str{};
const auto& vs = TCAP(fc::t_cursor_visible);
const auto& ve = TCAP(fc::t_cursor_normal);
const auto& vs = TCAP(t_cursor_visible);
const auto& ve = TCAP(t_cursor_normal);
if ( ve )
std::strncpy (enable_str.data(), ve, SIZE - 1);
@ -1929,7 +1927,7 @@ const char* FTerm::disableCursorString()
{
// Returns the cursor disable string
const auto& vi = TCAP(fc::t_cursor_invisible);
const auto& vi = TCAP(t_cursor_invisible);
if ( vi )
return vi;
@ -1958,7 +1956,7 @@ void FTerm::enableMouse()
}
#endif // defined(__linux__)
if ( TCAP(fc::t_key_mouse) && ! isLinuxTerm() )
if ( TCAP(t_key_mouse) && ! isLinuxTerm() )
xterm_mouse = true;
const auto& keyboard = FTerm::getFKeyboard();
@ -1987,9 +1985,9 @@ inline void FTerm::enableKeypad()
{
// Enter 'keyboard_transmit' mode
if ( TCAP(fc::t_keypad_xmit) )
if ( TCAP(t_keypad_xmit) )
{
putstring (TCAP(fc::t_keypad_xmit));
putstring (TCAP(t_keypad_xmit));
std::fflush(stdout);
}
}
@ -1999,9 +1997,9 @@ inline void FTerm::disableKeypad()
{
// Leave 'keyboard_transmit' mode
if ( TCAP(fc::t_keypad_local) )
if ( TCAP(t_keypad_local) )
{
putstring (TCAP(fc::t_keypad_local));
putstring (TCAP(t_keypad_local));
std::fflush(stdout);
}
}
@ -2011,9 +2009,9 @@ inline void FTerm::enableAlternateCharset()
{
// Enable alternate charset
if ( TCAP(fc::t_enable_acs) )
if ( TCAP(t_enable_acs) )
{
putstring (TCAP(fc::t_enable_acs));
putstring (TCAP(t_enable_acs));
std::fflush(stdout);
}
}
@ -2045,16 +2043,16 @@ void FTerm::useAlternateScreenBuffer()
return;
// Save current cursor position
if ( TCAP(fc::t_save_cursor) )
if ( TCAP(t_save_cursor) )
{
putstring (TCAP(fc::t_save_cursor));
putstring (TCAP(t_save_cursor));
std::fflush(stdout);
}
// Saves the screen and the cursor position
if ( TCAP(fc::t_enter_ca_mode) )
if ( TCAP(t_enter_ca_mode) )
{
putstring (TCAP(fc::t_enter_ca_mode));
putstring (TCAP(t_enter_ca_mode));
std::fflush(stdout);
getFTermData()->setAlternateScreenInUse(true);
}
@ -2069,17 +2067,17 @@ void FTerm::useNormalScreenBuffer()
return;
// restores the screen and the cursor position
if ( TCAP(fc::t_exit_ca_mode) )
if ( TCAP(t_exit_ca_mode) )
{
putstring (TCAP(fc::t_exit_ca_mode));
putstring (TCAP(t_exit_ca_mode));
std::fflush(stdout);
getFTermData()->setAlternateScreenInUse(false);
}
// restore cursor to position of last save_cursor
if ( TCAP(fc::t_restore_cursor) )
if ( TCAP(t_restore_cursor) )
{
putstring (TCAP(fc::t_restore_cursor));
putstring (TCAP(t_restore_cursor));
std::fflush(stdout);
}
}
@ -2115,8 +2113,7 @@ void FTerm::init()
init_alt_charset();
// Pass the terminal capabilities to the keyboard object
const auto& keyboard = FTerm::getFKeyboard();
keyboard->setTermcapMap (fc::fkey);
FTerm::getFKeyboard()->setTermcapMap();
// Initializes locale information
init_locale();
@ -2267,7 +2264,7 @@ void FTerm::initOSspecifics() const
void FTerm::initTermspecifics() const
{
if ( isKdeTerminal() )
setKDECursor(fc::UnderlineCursor);
setKDECursor(KdeKonsoleCursorShape::Underline);
if ( isCygwinTerminal() )
init_cygwin_charmap();
@ -2304,16 +2301,16 @@ void FTerm::finish() const
FTermios::restoreTTYsettings();
// Turn off all attributes
if ( TCAP(fc::t_exit_attribute_mode) )
if ( TCAP(t_exit_attribute_mode) )
{
putstring (TCAP(fc::t_exit_attribute_mode));
putstring (TCAP(t_exit_attribute_mode));
std::fflush(stdout);
}
// Turn off pc charset mode
if ( TCAP(fc::t_exit_pc_charset_mode) )
if ( TCAP(t_exit_pc_charset_mode) )
{
putstring (TCAP(fc::t_exit_pc_charset_mode));
putstring (TCAP(t_exit_pc_charset_mode));
std::fflush(stdout);
}
@ -2321,7 +2318,7 @@ void FTerm::finish() const
getFTermXTerminal()->resetDefaults();
// Set xterm full block cursor
getFTermXTerminal()->setCursorStyle (fc::steady_block);
getFTermXTerminal()->setCursorStyle (XTermCursorStyle::SteadyBlock);
// Restore the color palette
restoreColorPalette();
@ -2332,7 +2329,7 @@ void FTerm::finish() const
finishOSspecifics();
if ( isKdeTerminal() )
setKDECursor(fc::BlockCursor);
setKDECursor(KdeKonsoleCursorShape::Block);
resetBeep();

View File

@ -45,13 +45,13 @@ namespace finalcut
// Enumeration
enum class FullWidthSupport
{
unknown = -1,
no = 0,
yes = 1
Unknown = -1,
No = 0,
Yes = 1
};
// global state
static FullWidthSupport has_fullwidth_support = FullWidthSupport::unknown;
static FullWidthSupport has_fullwidth_support = FullWidthSupport::Unknown;
// Function prototypes
bool hasAmbiguousWidth (wchar_t);
@ -169,29 +169,29 @@ const wchar_t ambiguous_width_list[] =
#endif
};
const wchar_t reverse_newfont_list[] =
{
fc::NF_rev_left_arrow2,
fc::NF_rev_right_arrow2,
fc::NF_rev_border_corner_upper_right,
fc::NF_rev_border_line_right,
fc::NF_rev_border_line_vertical_left,
fc::NF_rev_border_corner_lower_right,
fc::NF_rev_up_arrow2,
fc::NF_rev_down_arrow2,
fc::NF_rev_up_arrow1,
fc::NF_rev_down_arrow1,
fc::NF_rev_left_arrow1,
fc::NF_rev_right_arrow1,
fc::NF_rev_menu_button1,
fc::NF_rev_menu_button2,
fc::NF_rev_up_pointing_triangle1,
fc::NF_rev_down_pointing_triangle1,
fc::NF_rev_up_pointing_triangle2,
fc::NF_rev_down_pointing_triangle2,
fc::NF_rev_menu_button3,
fc::NF_rev_border_line_right_and_left
};
constexpr std::array<UniChar, 20> reverse_newfont_list =
{{
UniChar::NF_rev_left_arrow2,
UniChar::NF_rev_right_arrow2,
UniChar::NF_rev_border_corner_upper_right,
UniChar::NF_rev_border_line_right,
UniChar::NF_rev_border_line_vertical_left,
UniChar::NF_rev_border_corner_lower_right,
UniChar::NF_rev_up_arrow2,
UniChar::NF_rev_down_arrow2,
UniChar::NF_rev_up_arrow1,
UniChar::NF_rev_down_arrow1,
UniChar::NF_rev_left_arrow1,
UniChar::NF_rev_right_arrow1,
UniChar::NF_rev_menu_button1,
UniChar::NF_rev_menu_button2,
UniChar::NF_rev_up_pointing_triangle1,
UniChar::NF_rev_down_pointing_triangle1,
UniChar::NF_rev_up_pointing_triangle2,
UniChar::NF_rev_down_pointing_triangle2,
UniChar::NF_rev_menu_button3,
UniChar::NF_rev_border_line_right_and_left
}};
// FTerm non-member functions
@ -227,8 +227,11 @@ inline bool hasAmbiguousWidth (wchar_t wchar)
const auto& begin = std::begin(ambiguous_width_list);
const auto& end = std::end(ambiguous_width_list);
if ( std::find(begin, end, wchar) != end ) // found
if ( std::any_of(begin, end, [&wchar] (const wchar_t c)
{ return c == wchar; }) )
{
return true;
}
return false;
}
@ -239,8 +242,11 @@ bool isReverseNewFontchar (wchar_t wchar)
const auto& begin = std::begin(reverse_newfont_list);
const auto& end = std::end(reverse_newfont_list);
if ( std::find(begin, end, wchar) != end ) // found
if ( std::any_of(begin, end, [&wchar] (const UniChar& c)
{ return wchar_t(c) == wchar; }) )
{
return true;
}
return false;
}
@ -250,7 +256,7 @@ bool hasFullWidthSupports()
{
// Checks if the terminal has full-width character support
if ( has_fullwidth_support == FullWidthSupport::unknown )
if ( has_fullwidth_support == FullWidthSupport::Unknown )
{
if ( ! FTerm::isInitialized() )
return true; // Assume that it is a modern terminal with full-width support
@ -262,12 +268,12 @@ bool hasFullWidthSupports()
|| FTerm::isOpenBSDTerm()
|| FTerm::isSunTerminal()
|| FTerm::isAnsiTerminal() )
has_fullwidth_support = FullWidthSupport::no;
has_fullwidth_support = FullWidthSupport::No;
else
has_fullwidth_support = FullWidthSupport::yes;
has_fullwidth_support = FullWidthSupport::Yes;
}
return ( has_fullwidth_support == FullWidthSupport::yes) ? true : false;
return ( has_fullwidth_support == FullWidthSupport::Yes) ? true : false;
}
//----------------------------------------------------------------------
@ -394,7 +400,7 @@ FString getColumnSubString ( const FString& str
}
else
{
ch = fc::SingleLeftAngleQuotationMark; //
ch = wchar_t(UniChar::SingleLeftAngleQuotationMark); //
num = col_num = 1;
col_pos = col_first;
}
@ -408,7 +414,7 @@ FString getColumnSubString ( const FString& str
}
else if ( col_num < col_len )
{
ch = fc::SingleRightAngleQuotationMark; //
ch = wchar_t(UniChar::SingleRightAngleQuotationMark); //
num++;
break;
}
@ -495,7 +501,7 @@ std::size_t getColumnWidth (const wchar_t wchar)
else
#endif
if ( (wchar >= fc::NF_rev_left_arrow2 && wchar <= fc::NF_check_mark)
if ( (wchar >= UniChar::NF_rev_left_arrow2 && wchar <= UniChar::NF_check_mark)
|| ! hasFullWidthSupports() )
column_width = 1;
else
@ -509,7 +515,7 @@ std::size_t getColumnWidth (FChar& term_char)
{
const std::size_t char_width = getColumnWidth(term_char.ch[0]);
if ( char_width == 2 && FTerm::getEncoding() != fc::UTF8 )
if ( char_width == 2 && FTerm::getEncoding() != Encoding::UTF8 )
{
term_char.ch[0] = '.';
term_char.attr.bit.char_width = 1;

View File

@ -92,37 +92,37 @@ int FTermBuffer::write (wchar_t ch)
//----------------------------------------------------------------------
void FTermBuffer::write (const FStyle& style) const
{
FAttribute attr = style.getStyle();
Style attr = style.getStyle();
if ( attr == 0 )
if ( attr == Style::None )
FVTerm::setNormal();
else if ( (attr & fc::Bold) != 0 )
else if ( (attr & Style::Bold) != Style::None )
FVTerm::setBold();
else if ( (attr & fc::Dim) != 0 )
else if ( (attr & Style::Dim) != Style::None )
FVTerm::setDim();
else if ( (attr & fc::Italic) != 0 )
else if ( (attr & Style::Italic) != Style::None )
FVTerm::setItalic();
else if ( (attr & fc::Underline) != 0 )
else if ( (attr & Style::Underline) != Style::None )
FVTerm::setUnderline();
else if ( (attr & fc::Blink) != 0 )
else if ( (attr & Style::Blink) != Style::None )
FVTerm::setBlink();
else if ( (attr & fc::Reverse) != 0 )
else if ( (attr & Style::Reverse) != Style::None )
FVTerm::setReverse();
else if ( (attr & fc::Standout) != 0 )
else if ( (attr & Style::Standout) != Style::None )
FVTerm::setStandout();
else if ( (attr & fc::Invisible) != 0 )
else if ( (attr & Style::Invisible) != Style::None )
FVTerm::setInvisible();
else if ( (attr & fc::Protected) != 0 )
else if ( (attr & Style::Protected) != Style::None )
FVTerm::setProtected();
else if ( (attr & fc::CrossedOut) != 0 )
else if ( (attr & Style::CrossedOut) != Style::None )
FVTerm::setCrossedOut();
else if ( (attr & fc::DoubleUnderline) != 0 )
else if ( (attr & Style::DoubleUnderline) != Style::None )
FVTerm::setDoubleUnderline();
else if ( (attr & fc::Transparent) != 0 )
else if ( (attr & Style::Transparent) != Style::None )
FVTerm::setTransparent();
else if ( (attr & fc::ColorOverlay) != 0 )
else if ( (attr & Style::ColorOverlay) != Style::None )
FVTerm::setColorOverlay();
else if ( (attr & fc::InheritBackground) != 0 )
else if ( (attr & Style::InheritBackground) != Style::None )
FVTerm::setInheritBackground();
}

View File

@ -231,7 +231,7 @@ void FTermcap::termcapStrings()
for (auto&& entry : strings)
entry.string = getString(entry.tname);
const auto& ho = TCAP(fc::t_cursor_home);
const auto& ho = TCAP(t_cursor_home);
if ( std::strncmp(ho, "\033[H", 3) == 0 )
has_ansi_escape_sequences = true;
@ -243,7 +243,7 @@ void FTermcap::termcapKeys()
// Get termcap keys
// Read termcap key sequences up to the self-defined values
for (auto&& entry : fc::fkey)
for (auto&& entry : fc::fkey_cap_table)
{
if ( entry.string != nullptr )
break;

View File

@ -101,7 +101,7 @@ void FTermcapQuirks::freebsd()
{
// FreeBSD console fixes
TCAP(fc::t_acs_chars) = \
TCAP(t_acs_chars) = \
"-\036.\0370\333"
"a\260f\370g\361"
"h\261j\331k\277"
@ -110,7 +110,7 @@ void FTermcapQuirks::freebsd()
"v\301w\302x\263"
"y\363z\362~\371";
TCAP(fc::t_set_attributes) = \
TCAP(t_set_attributes) = \
CSI "0"
"%?%p1%p6%|%t;1%;"
"%?%p2%t;4%;"
@ -126,20 +126,20 @@ void FTermcapQuirks::freebsd()
void FTermcapQuirks::cygwin()
{
// Set invisible cursor for cygwin terminal
if ( ! TCAP(fc::t_cursor_invisible) )
TCAP(fc::t_cursor_invisible) = CSI "?25l";
if ( ! TCAP(t_cursor_invisible) )
TCAP(t_cursor_invisible) = CSI "?25l";
// Set visible cursor for cygwin terminal
if ( ! TCAP(fc::t_cursor_visible) )
TCAP(fc::t_cursor_visible) = CSI "?25h";
if ( ! TCAP(t_cursor_visible) )
TCAP(t_cursor_visible) = CSI "?25h";
// Set ansi blink for cygwin terminal
if ( ! TCAP(fc::t_enter_blink_mode) )
TCAP(fc::t_enter_blink_mode) = CSI "5m";
if ( ! TCAP(t_enter_blink_mode) )
TCAP(t_enter_blink_mode) = CSI "5m";
// Set enable alternate character set for cygwin terminal
if ( ! TCAP(fc::t_enable_acs) )
TCAP(fc::t_enable_acs) = ESC "(B" ESC ")0";
if ( ! TCAP(t_enable_acs) )
TCAP(t_enable_acs) = ESC "(B" ESC ")0";
// Set background color erase for cygwin terminal
FTermcap::background_color_erase = true;
@ -156,55 +156,55 @@ void FTermcapQuirks::linux()
// Set ansi foreground and background color
if ( FTerm::getMaxColor() > 8 )
{
TCAP(fc::t_set_a_foreground) = \
TCAP(t_set_a_foreground) = \
CSI "3%p1%{8}%m%d%?%p1%{7}%>%t;1%e;22%;m";
TCAP(fc::t_set_a_background) = \
TCAP(t_set_a_background) = \
CSI "4%p1%{8}%m%d%?%p1%{7}%>%t;5%e;25%;m";
// Avoid underline, blink, dim mode and reverse
FTermcap::attr_without_color = 30;
}
else
{
TCAP(fc::t_set_a_foreground) = CSI "3%p1%dm";
TCAP(fc::t_set_a_background) = CSI "4%p1%dm";
TCAP(t_set_a_foreground) = CSI "3%p1%dm";
TCAP(t_set_a_background) = CSI "4%p1%dm";
// Avoid underline and dim mode
FTermcap::attr_without_color = 18;
}
// Set select graphic rendition attributes
TCAP(fc::t_set_attributes) = \
TCAP(t_set_attributes) = \
CSI "0"
"%?%p6%t;1%;"
"%?%p1%p3%|%t;7%;"
"%?%p4%t;5%;m"
"%?%p9%t\016%e\017%;";
TCAP(fc::t_enter_alt_charset_mode) = SO;
TCAP(fc::t_exit_alt_charset_mode) = SI;
TCAP(fc::t_exit_attribute_mode) = CSI "0m" SI;
TCAP(fc::t_exit_bold_mode) = CSI "22m";
TCAP(fc::t_exit_blink_mode) = CSI "25m";
TCAP(fc::t_exit_reverse_mode) = CSI "27m";
TCAP(fc::t_exit_secure_mode) = nullptr;
TCAP(fc::t_exit_protected_mode) = nullptr;
TCAP(fc::t_exit_crossed_out_mode) = nullptr;
TCAP(fc::t_orig_pair) = CSI "39;49;25m";
TCAP(t_enter_alt_charset_mode) = SO;
TCAP(t_exit_alt_charset_mode) = SI;
TCAP(t_exit_attribute_mode) = CSI "0m" SI;
TCAP(t_exit_bold_mode) = CSI "22m";
TCAP(t_exit_blink_mode) = CSI "25m";
TCAP(t_exit_reverse_mode) = CSI "27m";
TCAP(t_exit_secure_mode) = nullptr;
TCAP(t_exit_protected_mode) = nullptr;
TCAP(t_exit_crossed_out_mode) = nullptr;
TCAP(t_orig_pair) = CSI "39;49;25m";
// Avoid underline and dim mode
TCAP(fc::t_enter_dim_mode) = nullptr;
TCAP(fc::t_exit_dim_mode) = nullptr;
TCAP(fc::t_enter_underline_mode) = nullptr;
TCAP(fc::t_exit_underline_mode) = nullptr;
TCAP(t_enter_dim_mode) = nullptr;
TCAP(t_exit_dim_mode) = nullptr;
TCAP(t_enter_underline_mode) = nullptr;
TCAP(t_exit_underline_mode) = nullptr;
}
//----------------------------------------------------------------------
void FTermcapQuirks::xterm()
{
// Fallback if "Ic" is not found
if ( ! TCAP(fc::t_initialize_color) )
if ( ! TCAP(t_initialize_color) )
{
FTermcap::can_change_color_palette = true;
TCAP(fc::t_initialize_color) = \
TCAP(t_initialize_color) = \
OSC "4;%p1%d;rgb:"
"%p2%{255}%*%{1000}%/%2.2X/"
"%p3%{255}%*%{1000}%/%2.2X/"
@ -212,12 +212,12 @@ void FTermcapQuirks::xterm()
}
// Fallback if "vi" is not found
if ( ! TCAP(fc::t_cursor_invisible) )
TCAP(fc::t_cursor_invisible) = CSI "?25l";
if ( ! TCAP(t_cursor_invisible) )
TCAP(t_cursor_invisible) = CSI "?25l";
// Fallback if "ve" is not found
if ( ! TCAP(fc::t_cursor_normal) )
TCAP(fc::t_cursor_normal) = CSI "?12l" CSI "?25h";
if ( ! TCAP(t_cursor_normal) )
TCAP(t_cursor_normal) = CSI "?12l" CSI "?25h";
}
//----------------------------------------------------------------------
@ -230,16 +230,16 @@ void FTermcapQuirks::rxvt()
if ( std::strncmp(termtype, "rxvt-16color", 12) == 0 )
{
TCAP(fc::t_enter_alt_charset_mode) = ESC "(0";
TCAP(fc::t_exit_alt_charset_mode) = ESC "(B";
TCAP(t_enter_alt_charset_mode) = ESC "(0";
TCAP(t_exit_alt_charset_mode) = ESC "(B";
}
// Set ansi foreground and background color
if ( ! term_detection->isUrxvtTerminal() )
{
TCAP(fc::t_set_a_foreground) = \
TCAP(t_set_a_foreground) = \
CSI "%?%p1%{8}%<%t%p1%{30}%+%e%p1%'R'%+%;%dm";
TCAP(fc::t_set_a_background) = \
TCAP(t_set_a_background) = \
CSI "%?%p1%{8}%<%t%p1%'('%+%e%p1%{92}%+%;%dm";
}
}
@ -253,24 +253,24 @@ void FTermcapQuirks::vte()
FTermcap::attr_without_color = 0;
// set exit underline for gnome terminal
TCAP(fc::t_exit_underline_mode) = CSI "24m";
TCAP(t_exit_underline_mode) = CSI "24m";
if ( term_detection->getGnomeTerminalID() >= 5300 ) // vte >= 0.53.0
{
if ( TCAP(fc::t_enter_ca_mode)
&& ! std::strstr(TCAP(fc::t_enter_ca_mode), "\033[22;0;0t") )
if ( TCAP(t_enter_ca_mode)
&& ! std::strstr(TCAP(t_enter_ca_mode), "\033[22;0;0t") )
{
// Save the cursor position, enter alternate screen buffer
// and save xterm icon and window title on stack
TCAP(fc::t_enter_ca_mode) = CSI "?1049h" CSI "22;0;0t";
TCAP(t_enter_ca_mode) = CSI "?1049h" CSI "22;0;0t";
}
if ( TCAP(fc::t_exit_ca_mode)
&& ! std::strstr(TCAP(fc::t_exit_ca_mode), "\033[23;0;0t") )
if ( TCAP(t_exit_ca_mode)
&& ! std::strstr(TCAP(t_exit_ca_mode), "\033[23;0;0t") )
{
// Use normal screen buffer, restore the cursor position
// and restore xterm icon and window title from stack
TCAP(fc::t_exit_ca_mode) = CSI "?1049l" CSI "23;0;0t";
TCAP(t_exit_ca_mode) = CSI "?1049l" CSI "23;0;0t";
}
}
}
@ -286,21 +286,21 @@ void FTermcapQuirks::putty()
FTermcap::attr_without_color = 0;
// Set ansi foreground and background color
TCAP(fc::t_set_a_foreground) = \
TCAP(t_set_a_foreground) = \
CSI "%?%p1%{8}%<"
"%t3%p1%d"
"%e%p1%{16}%<"
"%t9%p1%{8}%-%d"
"%e38;5;%p1%d%;m";
TCAP(fc::t_set_a_background) = \
TCAP(t_set_a_background) = \
CSI "%?%p1%{8}%<"
"%t4%p1%d"
"%e%p1%{16}%<"
"%t10%p1%{8}%-%d"
"%e48;5;%p1%d%;m";
TCAP(fc::t_set_attributes) = \
TCAP(t_set_attributes) = \
CSI "0"
"%?%p1%p6%|%t;1%;"
"%?%p5%t;2%;" // since putty 0.71
@ -309,49 +309,49 @@ void FTermcapQuirks::putty()
"%?%p4%t;5%;m"
"%?%p9%t\016%e\017%;";
// PuTTY 0.71 or higher
TCAP(fc::t_enter_dim_mode) = CSI "2m";
TCAP(t_enter_dim_mode) = CSI "2m";
// PuTTY 0.71 or higher
TCAP(fc::t_exit_dim_mode) = CSI "22m";
TCAP(t_exit_dim_mode) = CSI "22m";
if ( ! TCAP(fc::t_clr_bol) )
TCAP(fc::t_clr_bol) = CSI "1K";
if ( ! TCAP(t_clr_bol) )
TCAP(t_clr_bol) = CSI "1K";
if ( ! TCAP(fc::t_orig_pair) )
TCAP(fc::t_orig_pair) = CSI "39;49m";
if ( ! TCAP(t_orig_pair) )
TCAP(t_orig_pair) = CSI "39;49m";
if ( ! TCAP(fc::t_orig_colors) )
TCAP(fc::t_orig_colors) = OSC "R";
if ( ! TCAP(t_orig_colors) )
TCAP(t_orig_colors) = OSC "R";
if ( ! TCAP(fc::t_column_address) )
TCAP(fc::t_column_address) = CSI "%i%p1%dG";
if ( ! TCAP(t_column_address) )
TCAP(t_column_address) = CSI "%i%p1%dG";
if ( ! TCAP(fc::t_row_address) )
TCAP(fc::t_row_address) = CSI "%i%p1%dd";
if ( ! TCAP(t_row_address) )
TCAP(t_row_address) = CSI "%i%p1%dd";
if ( ! TCAP(fc::t_enable_acs) )
TCAP(fc::t_enable_acs) = ESC "(B" ESC ")0";
if ( ! TCAP(t_enable_acs) )
TCAP(t_enable_acs) = ESC "(B" ESC ")0";
if ( ! TCAP(fc::t_enter_am_mode) )
TCAP(fc::t_enter_am_mode) = CSI "?7h";
if ( ! TCAP(t_enter_am_mode) )
TCAP(t_enter_am_mode) = CSI "?7h";
if ( ! TCAP(fc::t_exit_am_mode) )
TCAP(fc::t_exit_am_mode) = CSI "?7l";
if ( ! TCAP(t_exit_am_mode) )
TCAP(t_exit_am_mode) = CSI "?7l";
if ( ! TCAP(fc::t_enter_pc_charset_mode) )
TCAP(fc::t_enter_pc_charset_mode) = CSI "11m";
if ( ! TCAP(t_enter_pc_charset_mode) )
TCAP(t_enter_pc_charset_mode) = CSI "11m";
if ( ! TCAP(fc::t_exit_pc_charset_mode) )
TCAP(fc::t_exit_pc_charset_mode) = CSI "10m";
if ( ! TCAP(t_exit_pc_charset_mode) )
TCAP(t_exit_pc_charset_mode) = CSI "10m";
if ( ! TCAP(fc::t_keypad_xmit) )
TCAP(fc::t_keypad_xmit) = CSI "?1h" ESC "=";
if ( ! TCAP(t_keypad_xmit) )
TCAP(t_keypad_xmit) = CSI "?1h" ESC "=";
if ( ! TCAP(fc::t_keypad_local) )
TCAP(fc::t_keypad_local) = CSI "?1l" ESC ">";
if ( ! TCAP(t_keypad_local) )
TCAP(t_keypad_local) = CSI "?1l" ESC ">";
if ( ! TCAP(fc::t_key_mouse) )
TCAP(fc::t_key_mouse) = CSI "M";
if ( ! TCAP(t_key_mouse) )
TCAP(t_key_mouse) = CSI "M";
}
//----------------------------------------------------------------------
@ -361,10 +361,10 @@ void FTermcapQuirks::teraterm()
FTermcap::eat_nl_glitch = true;
// Tera Term color settings
TCAP(fc::t_set_a_foreground) = CSI "38;5;%p1%dm";
TCAP(fc::t_set_a_background) = CSI "48;5;%p1%dm";
TCAP(fc::t_exit_attribute_mode) = CSI "0m" SI;
TCAP(fc::t_orig_pair) = CSI "39;49m";
TCAP(t_set_a_foreground) = CSI "38;5;%p1%dm";
TCAP(t_set_a_background) = CSI "48;5;%p1%dm";
TCAP(t_exit_attribute_mode) = CSI "0m" SI;
TCAP(t_orig_pair) = CSI "39;49m";
}
//----------------------------------------------------------------------
@ -374,77 +374,77 @@ void FTermcapQuirks::sunConsole()
FTermcap::eat_nl_glitch = true;
// Sun Microsystems workstation console parameter cursor control
TCAP(fc::t_parm_up_cursor) = CSI "%p1%dA";
TCAP(fc::t_parm_down_cursor) = CSI "%p1%dB";
TCAP(fc::t_parm_right_cursor) = CSI "%p1%dC";
TCAP(fc::t_parm_left_cursor) = CSI "%p1%dD";
TCAP(t_parm_up_cursor) = CSI "%p1%dA";
TCAP(t_parm_down_cursor) = CSI "%p1%dB";
TCAP(t_parm_right_cursor) = CSI "%p1%dC";
TCAP(t_parm_left_cursor) = CSI "%p1%dD";
// Sun Microsystems workstation console keys
for (std::size_t i{0}; fc::fkey[i].tname[0] != 0; i++)
for (std::size_t i{0}; fc::fkey_cap_table[i].tname[0] != 0; i++)
{
if ( std::strncmp(fc::fkey[i].tname, "K2", 2) == 0 )
fc::fkey[i].string = CSI "218z"; // center of keypad
if ( std::strncmp(fc::fkey_cap_table[i].tname, "K2", 2) == 0 )
fc::fkey_cap_table[i].string = CSI "218z"; // center of keypad
if ( std::strncmp(fc::fkey[i].tname, "kb", 2) == 0 )
fc::fkey[i].string = "\b"; // backspace key
if ( std::strncmp(fc::fkey_cap_table[i].tname, "kb", 2) == 0 )
fc::fkey_cap_table[i].string = "\b"; // backspace key
if ( std::strncmp(fc::fkey[i].tname, "kD", 2) == 0
&& std::strlen(fc::fkey[i].tname) == 2 )
fc::fkey[i].string = "\177"; // delete-character key
if ( std::strncmp(fc::fkey_cap_table[i].tname, "kD", 2) == 0
&& std::strlen(fc::fkey_cap_table[i].tname) == 2 )
fc::fkey_cap_table[i].string = "\177"; // delete-character key
if ( std::strncmp(fc::fkey[i].tname, "@7", 2) == 0 )
fc::fkey[i].string = CSI "220z"; // end key
if ( std::strncmp(fc::fkey_cap_table[i].tname, "@7", 2) == 0 )
fc::fkey_cap_table[i].string = CSI "220z"; // end key
if ( std::strncmp(fc::fkey[i].tname, "k;", 2) == 0 )
fc::fkey[i].string = CSI "233z"; // F10 function key
if ( std::strncmp(fc::fkey_cap_table[i].tname, "k;", 2) == 0 )
fc::fkey_cap_table[i].string = CSI "233z"; // F10 function key
if ( std::strncmp(fc::fkey[i].tname, "F1", 2) == 0 )
fc::fkey[i].string = CSI "234z"; // F11 function key
if ( std::strncmp(fc::fkey_cap_table[i].tname, "F1", 2) == 0 )
fc::fkey_cap_table[i].string = CSI "234z"; // F11 function key
if ( std::strncmp(fc::fkey[i].tname, "F2", 2) == 0 )
fc::fkey[i].string = CSI "235z"; // F12 function key
if ( std::strncmp(fc::fkey_cap_table[i].tname, "F2", 2) == 0 )
fc::fkey_cap_table[i].string = CSI "235z"; // F12 function key
if ( std::strncmp(fc::fkey[i].tname, "kh", 2) == 0 )
fc::fkey[i].string = CSI "214z"; // home key
if ( std::strncmp(fc::fkey_cap_table[i].tname, "kh", 2) == 0 )
fc::fkey_cap_table[i].string = CSI "214z"; // home key
if ( std::strncmp(fc::fkey[i].tname, "kI", 2) == 0 )
fc::fkey[i].string = CSI "247z"; // insert-character key
if ( std::strncmp(fc::fkey_cap_table[i].tname, "kI", 2) == 0 )
fc::fkey_cap_table[i].string = CSI "247z"; // insert-character key
if ( std::strncmp(fc::fkey[i].tname, "kN", 2) == 0 )
fc::fkey[i].string = CSI "222z"; // next-page key
if ( std::strncmp(fc::fkey_cap_table[i].tname, "kN", 2) == 0 )
fc::fkey_cap_table[i].string = CSI "222z"; // next-page key
if ( std::strncmp(fc::fkey[i].tname, "%7", 2) == 0 )
fc::fkey[i].string = CSI "194z"; // options key
if ( std::strncmp(fc::fkey_cap_table[i].tname, "%7", 2) == 0 )
fc::fkey_cap_table[i].string = CSI "194z"; // options key
if ( std::strncmp(fc::fkey[i].tname, "kP", 2) == 0 )
fc::fkey[i].string = CSI "216z"; // prev-page key
if ( std::strncmp(fc::fkey_cap_table[i].tname, "kP", 2) == 0 )
fc::fkey_cap_table[i].string = CSI "216z"; // prev-page key
if ( std::strncmp(fc::fkey[i].tname, "&5", 2) == 0 )
fc::fkey[i].string = CSI "193z"; // resume key
if ( std::strncmp(fc::fkey_cap_table[i].tname, "&5", 2) == 0 )
fc::fkey_cap_table[i].string = CSI "193z"; // resume key
if ( std::strncmp(fc::fkey[i].tname, "&8", 2) == 0 )
fc::fkey[i].string = CSI "195z"; // undo key
if ( std::strncmp(fc::fkey_cap_table[i].tname, "&8", 2) == 0 )
fc::fkey_cap_table[i].string = CSI "195z"; // undo key
if ( std::strncmp(fc::fkey[i].tname, "K2", 2) == 0 )
fc::fkey[i].string = CSI "218z"; // center of keypad
if ( std::strncmp(fc::fkey_cap_table[i].tname, "K2", 2) == 0 )
fc::fkey_cap_table[i].string = CSI "218z"; // center of keypad
if ( std::strncmp(fc::fkey[i].tname, "kDx", 3) == 0 )
fc::fkey[i].string = CSI "249z"; // keypad delete
if ( std::strncmp(fc::fkey_cap_table[i].tname, "kDx", 3) == 0 )
fc::fkey_cap_table[i].string = CSI "249z"; // keypad delete
if ( std::strncmp(fc::fkey[i].tname, "@8x", 3) == 0 )
fc::fkey[i].string = CSI "250z"; // enter/send key
if ( std::strncmp(fc::fkey_cap_table[i].tname, "@8x", 3) == 0 )
fc::fkey_cap_table[i].string = CSI "250z"; // enter/send key
if ( std::strncmp(fc::fkey[i].tname, "KP1", 3) == 0 )
fc::fkey[i].string = CSI "212z"; // keypad slash
if ( std::strncmp(fc::fkey_cap_table[i].tname, "KP1", 3) == 0 )
fc::fkey_cap_table[i].string = CSI "212z"; // keypad slash
if ( std::strncmp(fc::fkey[i].tname, "KP2", 3) == 0 )
fc::fkey[i].string = CSI "213z"; // keypad asterisk
if ( std::strncmp(fc::fkey_cap_table[i].tname, "KP2", 3) == 0 )
fc::fkey_cap_table[i].string = CSI "213z"; // keypad asterisk
if ( std::strncmp(fc::fkey[i].tname, "KP3", 3) == 0 )
fc::fkey[i].string = CSI "254z"; // keypad minus sign
if ( std::strncmp(fc::fkey_cap_table[i].tname, "KP3", 3) == 0 )
fc::fkey_cap_table[i].string = CSI "254z"; // keypad minus sign
if ( std::strncmp(fc::fkey[i].tname, "KP4", 3) == 0 )
fc::fkey[i].string = CSI "253z"; // keypad plus sign
if ( std::strncmp(fc::fkey_cap_table[i].tname, "KP4", 3) == 0 )
fc::fkey_cap_table[i].string = CSI "253z"; // keypad plus sign
}
}
@ -454,13 +454,13 @@ void FTermcapQuirks::screen()
const auto& term_detection = FTerm::getFTermDetection();
// Fallback if "Ic" is not found
if ( ! TCAP(fc::t_initialize_color) )
if ( ! TCAP(t_initialize_color) )
{
FTermcap::can_change_color_palette = true;
if ( term_detection->isTmuxTerm() )
{
TCAP(fc::t_initialize_color) = \
TCAP(t_initialize_color) = \
ESC "Ptmux;" ESC OSC "4;%p1%d;rgb:"
"%p2%{255}%*%{1000}%/%2.2X/"
"%p3%{255}%*%{1000}%/%2.2X/"
@ -468,7 +468,7 @@ void FTermcapQuirks::screen()
}
else
{
TCAP(fc::t_initialize_color) = \
TCAP(t_initialize_color) = \
ESC "P" OSC "4;%p1%d;rgb:"
"%p2%{255}%*%{1000}%/%2.2X/"
"%p3%{255}%*%{1000}%/%2.2X/"
@ -489,18 +489,18 @@ void FTermcapQuirks::general()
FTermcap::attr_without_color = 0;
// Fallback if "AF" is not found
if ( ! TCAP(fc::t_set_a_foreground) )
TCAP(fc::t_set_a_foreground) = CSI "3%p1%dm";
if ( ! TCAP(t_set_a_foreground) )
TCAP(t_set_a_foreground) = CSI "3%p1%dm";
// Fallback if "AB" is not found
if ( ! TCAP(fc::t_set_a_background) )
TCAP(fc::t_set_a_background) = CSI "4%p1%dm";
if ( ! TCAP(t_set_a_background) )
TCAP(t_set_a_background) = CSI "4%p1%dm";
// Fallback if "Ic" is not found
if ( ! TCAP(fc::t_initialize_color) )
if ( ! TCAP(t_initialize_color) )
{
FTermcap::can_change_color_palette = true;
TCAP(fc::t_initialize_color) = \
TCAP(t_initialize_color) = \
OSC "P%p1%x"
"%p2%{255}%*%{1000}%/%02x"
"%p3%{255}%*%{1000}%/%02x"
@ -508,37 +508,37 @@ void FTermcapQuirks::general()
}
// Fallback if "ti" is not found
if ( ! TCAP(fc::t_enter_ca_mode) )
TCAP(fc::t_enter_ca_mode) = ESC "7" CSI "?47h";
if ( ! TCAP(t_enter_ca_mode) )
TCAP(t_enter_ca_mode) = ESC "7" CSI "?47h";
// Fallback if "te" is not found
if ( ! TCAP(fc::t_exit_ca_mode) )
TCAP(fc::t_exit_ca_mode) = CSI "?47l" ESC "8" CSI "m";
if ( ! TCAP(t_exit_ca_mode) )
TCAP(t_exit_ca_mode) = CSI "?47l" ESC "8" CSI "m";
// Set ansi move if "cm" is not found
if ( ! TCAP(fc::t_cursor_address) )
TCAP(fc::t_cursor_address) = CSI "%i%p1%d;%p2%dH";
if ( ! TCAP(t_cursor_address) )
TCAP(t_cursor_address) = CSI "%i%p1%d;%p2%dH";
}
//----------------------------------------------------------------------
void FTermcapQuirks::ecma48()
{
// Test for standard ECMA-48 (ANSI X3.64) terminal
if ( ! TCAP(fc::t_exit_underline_mode)
|| std::strncmp(TCAP(fc::t_exit_underline_mode), CSI "24m", 5) != 0 )
if ( ! TCAP(t_exit_underline_mode)
|| std::strncmp(TCAP(t_exit_underline_mode), CSI "24m", 5) != 0 )
return;
// Seems to be a ECMA-48 (ANSI X3.64) compatible terminal
TCAP(fc::t_enter_dbl_underline_mode) = CSI "21m"; // Leaves single underlined too
TCAP(fc::t_exit_dbl_underline_mode) = CSI "24m";
TCAP(fc::t_exit_bold_mode) = CSI "22m"; // Exit dim, too
TCAP(fc::t_exit_dim_mode) = CSI "22m";
TCAP(fc::t_exit_underline_mode) = CSI "24m";
TCAP(fc::t_exit_blink_mode) = CSI "25m";
TCAP(fc::t_exit_reverse_mode) = CSI "27m";
TCAP(fc::t_exit_secure_mode) = CSI "28m";
TCAP(fc::t_enter_crossed_out_mode) = CSI "9m";
TCAP(fc::t_exit_crossed_out_mode) = CSI "29m";
TCAP(t_enter_dbl_underline_mode) = CSI "21m"; // Leaves single underlined too
TCAP(t_exit_dbl_underline_mode) = CSI "24m";
TCAP(t_exit_bold_mode) = CSI "22m"; // Exit dim, too
TCAP(t_exit_dim_mode) = CSI "22m";
TCAP(t_exit_underline_mode) = CSI "24m";
TCAP(t_exit_blink_mode) = CSI "25m";
TCAP(t_exit_reverse_mode) = CSI "27m";
TCAP(t_exit_secure_mode) = CSI "28m";
TCAP(t_enter_crossed_out_mode) = CSI "9m";
TCAP(t_exit_crossed_out_mode) = CSI "29m";
}
} // namespace finalcut

View File

@ -26,11 +26,11 @@
#include "final/ftermdetection.h"
#include "final/ftermdebugdata.h"
#if DEBUG
namespace finalcut
{
#if DEBUG
//----------------------------------------------------------------------
// class FTermDebugData
//----------------------------------------------------------------------
@ -80,7 +80,6 @@ int FTermDebugData::getFramebufferBpp()
}
#endif // defined(__linux__)
#endif // DEBUG
} // namespace finalcut
#endif // DEBUG

View File

@ -57,7 +57,6 @@ FTermDetection::secondaryDA FTermDetection::secondary_da{};
char FTermDetection::termtype[256]{};
char FTermDetection::ttytypename[256]{};
bool FTermDetection::decscusr_support{};
bool FTermDetection::terminal_detection{};
bool FTermDetection::color256{};
const FString* FTermDetection::answer_back{nullptr};
@ -546,9 +545,9 @@ const char* FTermDetection::determineMaxColor (const char current_termtype[])
&& ! isTeraTerm()
&& ! isLinuxTerm()
&& ! isNetBSDTerm()
&& ! getXTermColorName(0).isEmpty() )
&& ! getXTermColorName(FColor(0)).isEmpty() )
{
if ( ! getXTermColorName(255).isEmpty() )
if ( ! getXTermColorName(FColor(255)).isEmpty() )
{
color256 = true;
@ -557,11 +556,11 @@ const char* FTermDetection::determineMaxColor (const char current_termtype[])
else
new_termtype = "xterm-256color";
}
else if ( ! getXTermColorName(87).isEmpty() )
else if ( ! getXTermColorName(FColor(87)).isEmpty() )
{
new_termtype = "xterm-88color";
}
else if ( ! getXTermColorName(15).isEmpty() )
else if ( ! getXTermColorName(FColor(15)).isEmpty() )
{
new_termtype = "xterm-16color";
}
@ -581,7 +580,8 @@ FString FTermDetection::getXTermColorName (FColor color)
const int stdin_no = FTermios::getStdIn();
// get color
std::fprintf (stdout, OSC "4;%hu;?" BEL, color);
auto index = uInt16(color);
std::fprintf (stdout, OSC "4;%hu;?" BEL, index);
std::fflush (stdout);
FD_ZERO(&ifds);
FD_SET(stdin_no, &ifds);
@ -608,7 +608,7 @@ FString FTermDetection::getXTermColorName (FColor color)
}
while ( pos < temp.size() );
if ( pos > 4 && std::sscanf(temp.data(), parse, &color, buf.data()) == 2 )
if ( pos > 4 && std::sscanf(temp.data(), parse, &index, buf.data()) == 2 )
{
std::size_t n = std::strlen(buf.data());

View File

@ -36,7 +36,7 @@ namespace finalcut
// static class attributes
uInt FTermFreeBSD::bsd_alt_keymap{0};
FTermFreeBSD::CursorStyle FTermFreeBSD::cursor_style{fc::normal_cursor};
FTermFreeBSD::CursorStyle FTermFreeBSD::cursor_style{FreeBSDConsoleCursorStyle::Normal};
bool FTermFreeBSD::change_cursorstyle{true};
bool FTermFreeBSD::meta_sends_escape{true};
@ -136,7 +136,7 @@ void FTermFreeBSD::init()
if ( change_cursorstyle )
{
// Initialize FreeBSD console cursor
setCursorStyle (fc::destructive_cursor);
setCursorStyle (FreeBSDConsoleCursorStyle::Destructive);
}
}
@ -149,8 +149,8 @@ void FTermFreeBSD::initCharMap()
return;
for (auto&& entry : fc::character)
if ( entry[fc::PC] < 0x1c )
entry[fc::PC] = entry[fc::ASCII];
if ( entry.pc < 0x1c )
entry.pc = entry.ascii;
}
//----------------------------------------------------------------------
@ -164,7 +164,7 @@ void FTermFreeBSD::finish()
if ( meta_sends_escape )
resetFreeBSDAlt2Meta();
setFreeBSDCursorStyle (fc::normal_cursor);
setFreeBSDCursorStyle (FreeBSDConsoleCursorStyle::Normal);
}

View File

@ -62,7 +62,7 @@ FTermLinux::~FTermLinux() // destructor
// public methods of FTermLinux
//----------------------------------------------------------------------
fc::linuxConsoleCursorStyle FTermLinux::getCursorStyle() const
FTermLinux::CursorStyle FTermLinux::getCursorStyle() const
{
// Get the current set cursor style
@ -76,12 +76,12 @@ char* FTermLinux::getCursorStyleString()
static std::array<char, 16> buf{};
std::fill (std::begin(buf), std::end(buf), '\0');
std::snprintf (buf.data(), buf.size(), CSI "?%dc", getCursorStyle());
std::snprintf (buf.data(), buf.size(), CSI "?%dc", int(getCursorStyle()));
return buf.data();
}
//----------------------------------------------------------------------
bool FTermLinux::setCursorStyle (fc::linuxConsoleCursorStyle style)
bool FTermLinux::setCursorStyle (CursorStyle style)
{
// Set cursor style in linux console
@ -130,14 +130,17 @@ bool FTermLinux::setPalette (FColor, int, int, int)
#endif
//----------------------------------------------------------------------
bool FTermLinux::isLinuxConsole() const
bool FTermLinux::isLinuxConsole()
{
// Check if it's a Linux console
char arg{0};
const int fd_tty = FTerm::getTTYFileDescriptor();
int fd_tty = FTerm::getTTYFileDescriptor();
const auto& fsystem = FTerm::getFSystem();
if ( fd_tty < 0 ) // Undefined tty file descriptor
fd_tty = 0;
// Get keyboard type an compare
return ( fsystem->isTTY(fd_tty)
&& fsystem->ioctl(fd_tty, KDGKBTYPE, &arg) == 0
@ -155,6 +158,7 @@ void FTermLinux::init()
screen_font.data = nullptr;
fterm_data->supportShadowCharacter (true);
fterm_data->supportHalfBlockCharacter (true);
initKeyMap();
#if defined(ISA_SYSCTL_SUPPORT)
getVGAPalette();
@ -177,7 +181,7 @@ void FTermLinux::init()
FTermcap::max_color = 8;
#endif
// Underline cursor
setCursorStyle (fc::underscore_cursor);
setCursorStyle (LinuxConsoleCursorStyle::Underscore);
// Framebuffer color depth in bits per pixel
framebuffer_bpp = getFramebuffer_bpp();
@ -196,7 +200,7 @@ void FTermLinux::init()
std::abort();
}
}
//----------------------------------------------------------------------
void FTermLinux::initCharMap() const
{
@ -209,12 +213,12 @@ void FTermLinux::initCharMap() const
{
for (auto&& entry : fc::character)
{
const auto ucs = wchar_t(entry[fc::UTF8]);
const auto ucs = entry.unicode;
const sInt16 fontpos = getFontPos(ucs);
// Fix for a non-cp437 Linux console with PC charset encoding
if ( fontpos > 255 || fontpos == NOT_FOUND )
entry[fc::PC] = entry[fc::ASCII];
entry.pc = entry.ascii;
// Character substitutions for missing characters
if ( fontpos == NOT_FOUND )
@ -244,7 +248,7 @@ void FTermLinux::finish()
#if defined(ISA_SYSCTL_SUPPORT)
setBlinkAsIntensity (false);
#endif
setLinuxCursorStyle (fc::default_cursor);
setLinuxCursorStyle (LinuxConsoleCursorStyle::Default);
}
}
@ -443,42 +447,13 @@ FKey FTermLinux::modifierKeyCorrection (const FKey& key_id)
{
// Get the current modifier key state
const ModifierKey& m = getModifierKey();
const Pair pair{getModifierKey(), key_id};
const auto iter = key_map.find(pair);
if ( ! (m.shift || m.ctrl || m.alt) )
{
if ( iter == key_map.cend() ) // Not found
return key_id;
}
else if ( m.shift && ! m.ctrl && ! m.alt )
{
return shiftKeyCorrection(key_id);
}
else if ( ! m.shift && m.ctrl && ! m.alt )
{
return ctrlKeyCorrection(key_id);
}
else if ( ! m.shift && ! m.ctrl && m.alt )
{
return altKeyCorrection(key_id);
}
else if ( m.shift && m.ctrl && ! m.alt )
{
return shiftCtrlKeyCorrection(key_id);
}
else if ( m.shift && ! m.ctrl && m.alt )
{
return shiftAltKeyCorrection(key_id);
}
else if ( ! m.shift && m.ctrl && m.alt )
{
return ctrlAltKeyCorrection(key_id);
}
else if ( m.shift && m.ctrl && m.alt )
{
return shiftCtrlAltKeyCorrection(key_id);
}
return key_id;
else // Found
return key_map[pair];
}
@ -831,7 +806,7 @@ inline void FTermLinux::setAttributeMode (uChar data) const
}
//----------------------------------------------------------------------
int FTermLinux::setBlinkAsIntensity (bool enable)
int FTermLinux::setBlinkAsIntensity (bool enable) const
{
// Uses blink-bit as background intensity.
// That permits 16 colors for background
@ -867,7 +842,7 @@ int FTermLinux::setBlinkAsIntensity (bool enable)
}
//----------------------------------------------------------------------
bool FTermLinux::has9BitCharacters()
bool FTermLinux::has9BitCharacters() const
{
// Are 9-bit wide characters used?
@ -938,9 +913,9 @@ bool FTermLinux::setVGAPalette (FColor index, int r, int g, int b)
&& g >= 0 && g < 256
&& b >= 0 && b < 256 )
{
cmap.color[index].red = uChar(r);
cmap.color[index].green = uChar(g);
cmap.color[index].blue = uChar(b);
cmap.color[uInt16(index)].red = uChar(r);
cmap.color[uInt16(index)].green = uChar(g);
cmap.color[uInt16(index)].blue = uChar(b);
}
const auto& fsystem = FTerm::getFSystem();
@ -991,305 +966,186 @@ bool FTermLinux::resetVGAPalette()
#endif // defined(ISA_SYSCTL_SUPPORT)
//----------------------------------------------------------------------
FKey FTermLinux::shiftKeyCorrection (const FKey& key_id) const
void FTermLinux::initKeyMap()
{
switch ( key_id )
{
case fc::Fkey_up:
return fc::Fkey_sr; // Shift+Up
case fc::Fkey_down:
return fc::Fkey_sf; // Shift+Down
case fc::Fkey_left:
return fc::Fkey_sleft; // Shift+Left
case fc::Fkey_right:
return fc::Fkey_sright; // Shift+Right
case fc::Fkey_ic:
return fc::Fkey_sic; // Shift+Ins
case fc::Fkey_dc:
return fc::Fkey_sdc; // Shift+Del
case fc::Fkey_home:
return fc::Fkey_shome; // Shift+Home
case fc::Fkey_end:
return fc::Fkey_send; // Shift+End
case fc::Fkey_ppage:
return fc::Fkey_sprevious; // Shift+PgUp
case fc::Fkey_npage:
return fc::Fkey_snext; // Shift+PgDn
default:
return key_id;
}
keyCorrection();
shiftKeyCorrection();
ctrlKeyCorrection();
altKeyCorrection();
shiftCtrlKeyCorrection();
shiftAltKeyCorrection();
ctrlAltKeyCorrection();
shiftCtrlAltKeyCorrection();
}
//----------------------------------------------------------------------
FKey FTermLinux::ctrlKeyCorrection (const FKey& key_id) const
inline void FTermLinux::keyCorrection()
{
switch ( key_id )
{
case fc::Fkey_up:
return fc::Fckey_up; // Ctrl+Up
case fc::Fkey_down:
return fc::Fckey_down; // Ctrl+Down
case fc::Fkey_left:
return fc::Fckey_left; // Ctrl+Left
case fc::Fkey_right:
return fc::Fckey_right; // Ctrl+Right
case fc::Fkey_ic:
return fc::Fckey_ic; // Ctrl+Ins
case fc::Fkey_dc:
return fc::Fckey_dc; // Ctrl+Del
case fc::Fkey_home:
return fc::Fckey_home; // Ctrl+Home
case fc::Fkey_end:
return fc::Fckey_end; // Ctrl+End
case fc::Fkey_ppage:
return fc::Fckey_ppage; // Ctrl+PgUp
case fc::Fkey_npage:
return fc::Fckey_npage; // Ctrl+PgDn
default:
return key_id;
}
ModifierKey m{};
std::memset (&m, 0x00, sizeof(m));
key_map[{m, FKey::Up}] = FKey::Up; // Up
key_map[{m, FKey::Down}] = FKey::Down; // Down
key_map[{m, FKey::Left}] = FKey::Left; // Left
key_map[{m, FKey::Right}] = FKey::Right; // Right
key_map[{m, FKey::Insert}] = FKey::Insert; // Ins
key_map[{m, FKey::Del_char}] = FKey::Del_char; // Del
key_map[{m, FKey::Home}] = FKey::Home; // Home
key_map[{m, FKey::End}] = FKey::End; // End
key_map[{m, FKey::Page_up}] = FKey::Page_up; // PgUp
key_map[{m, FKey::Page_down}] = FKey::Page_down; // PgDn
}
//----------------------------------------------------------------------
FKey FTermLinux::altKeyCorrection (const FKey& key_id) const
inline void FTermLinux::shiftKeyCorrection()
{
switch ( key_id )
{
case fc::Fkey_up:
return fc::Fmkey_up; // Meta+Up
case fc::Fkey_down:
return fc::Fmkey_down; // Meta+Down
case fc::Fkey_left:
return fc::Fmkey_left; // Meta+Left
case fc::Fkey_right:
return fc::Fmkey_right; // Meta+Right
case fc::Fkey_ic:
return fc::Fmkey_ic; // Meta+Ins
case fc::Fkey_dc:
return fc::Fmkey_dc; // Meta+Del
case fc::Fkey_home:
return fc::Fmkey_home; // Meta+Home
case fc::Fkey_end:
return fc::Fmkey_end; // Meta+End
case fc::Fkey_ppage:
return fc::Fmkey_ppage; // Meta+PgUp
case fc::Fkey_npage:
return fc::Fmkey_npage; // Meta+PgDn
default:
return key_id;
}
ModifierKey m{};
std::memset (&m, 0x00, sizeof(m));
m.shift = 1;
key_map[{m, FKey::Up}] = FKey::Shift_up; // Shift+Up
key_map[{m, FKey::Down}] = FKey::Shift_down; // Shift+Down
key_map[{m, FKey::Left}] = FKey::Shift_left; // Shift+Left
key_map[{m, FKey::Right}] = FKey::Shift_right; // Shift+Right
key_map[{m, FKey::Insert}] = FKey::Shift_insert; // Shift+Ins
key_map[{m, FKey::Del_char}] = FKey::Shift_del_char; // Shift+Del
key_map[{m, FKey::Home}] = FKey::Shift_home; // Shift+Home
key_map[{m, FKey::End}] = FKey::Shift_end; // Shift+End
key_map[{m, FKey::Page_up}] = FKey::Shift_page_up; // Shift+PgUp
key_map[{m, FKey::Page_down}] = FKey::Shift_page_down; // Shift+PgDn
}
//----------------------------------------------------------------------
FKey FTermLinux::shiftCtrlKeyCorrection (const FKey& key_id) const
inline void FTermLinux::ctrlKeyCorrection()
{
switch ( key_id )
{
case fc::Fkey_up:
return fc::Fckey_sup; // Shift+Ctrl+Up
case fc::Fkey_down:
return fc::Fckey_sdown; // Shift+Ctrl+Down
case fc::Fkey_left:
return fc::Fckey_sleft; // Shift+Ctrl+Left
case fc::Fkey_right:
return fc::Fckey_sright; // Shift+Ctrl+Right
case fc::Fkey_ic:
return fc::Fckey_sic; // Shift+Ctrl+Ins
case fc::Fkey_dc:
return fc::Fckey_sdc; // Shift+Ctrl+Del
case fc::Fkey_home:
return fc::Fckey_shome; // Shift+Ctrl+Home
case fc::Fkey_end:
return fc::Fckey_send; // Shift+Ctrl+End
case fc::Fkey_ppage:
return fc::Fckey_sppage; // Shift+Ctrl+PgUp
case fc::Fkey_npage:
return fc::Fckey_snpage; // Shift+Ctrl+PgDn
default:
return key_id;
}
ModifierKey m{};
std::memset (&m, 0x00, sizeof(m));
m.ctrl = 1;
key_map[{m, FKey::Up}] = FKey::Ctrl_up; // Ctrl+Up
key_map[{m, FKey::Down}] = FKey::Ctrl_down; // Ctrl+Down
key_map[{m, FKey::Left}] = FKey::Ctrl_left; // Ctrl+Left
key_map[{m, FKey::Right}] = FKey::Ctrl_right; // Ctrl+Right
key_map[{m, FKey::Insert}] = FKey::Ctrl_insert; // Ctrl+Ins
key_map[{m, FKey::Del_char}] = FKey::Ctrl_del_char; // Ctrl+Del
key_map[{m, FKey::Home}] = FKey::Ctrl_home; // Ctrl+Home
key_map[{m, FKey::End}] = FKey::Ctrl_end; // Ctrl+End
key_map[{m, FKey::Page_up}] = FKey::Ctrl_page_up; // Ctrl+PgUp
key_map[{m, FKey::Page_down}] = FKey::Ctrl_page_down; // Ctrl+PgDn
}
//----------------------------------------------------------------------
FKey FTermLinux::shiftAltKeyCorrection (const FKey& key_id) const
inline void FTermLinux::altKeyCorrection()
{
switch ( key_id )
{
case fc::Fkey_up:
return fc::Fmkey_sup; // Shift+Meta+Up
case fc::Fkey_down:
return fc::Fmkey_sdown; // Shift+Meta+Down
case fc::Fkey_left:
return fc::Fmkey_sleft; // Shift+Meta+Left
case fc::Fkey_right:
return fc::Fmkey_sright; // Shift+Meta+Right
case fc::Fkey_ic:
return fc::Fmkey_sic; // Shift+Meta+Ins
case fc::Fkey_dc:
return fc::Fmkey_sdc; // Shift+Meta+Del
case fc::Fkey_home:
return fc::Fmkey_shome; // Shift+Meta+Home
case fc::Fkey_end:
return fc::Fmkey_send; // Shift+Meta+End
case fc::Fkey_ppage:
return fc::Fmkey_sppage; // Shift+Meta+PgUp
case fc::Fkey_npage:
return fc::Fmkey_snpage; // Shift+Meta+PgDn
default:
return key_id;
}
ModifierKey m{};
std::memset (&m, 0x00, sizeof(m));
m.alt = 1;
key_map[{m, FKey::Up}] = FKey::Meta_up; // Meta+Up
key_map[{m, FKey::Down}] = FKey::Meta_down; // Meta+Down
key_map[{m, FKey::Left}] = FKey::Meta_left; // Meta+Left
key_map[{m, FKey::Right}] = FKey::Meta_right; // Meta+Right
key_map[{m, FKey::Insert}] = FKey::Meta_insert; // Meta+Ins
key_map[{m, FKey::Del_char}] = FKey::Meta_del_char; // Meta+Del
key_map[{m, FKey::Home}] = FKey::Meta_home; // Meta+Home
key_map[{m, FKey::End}] = FKey::Meta_end; // Meta+End
key_map[{m, FKey::Page_up}] = FKey::Meta_page_up; // Meta+PgUp
key_map[{m, FKey::Page_down}] = FKey::Meta_page_down; // Meta+PgDn
}
//----------------------------------------------------------------------
FKey FTermLinux::ctrlAltKeyCorrection (const FKey& key_id) const
inline void FTermLinux::shiftCtrlKeyCorrection()
{
switch ( key_id )
{
case fc::Fkey_up:
return fc::Fcmkey_up; // Ctrl+Meta+Up
case fc::Fkey_down:
return fc::Fcmkey_down; // Ctrl+Meta+Down
case fc::Fkey_left:
return fc::Fcmkey_left; // Ctrl+Meta+Left
case fc::Fkey_right:
return fc::Fcmkey_right; // Ctrl+Meta+Right
case fc::Fkey_ic:
return fc::Fcmkey_ic; // Ctrl+Meta+Ins
case fc::Fkey_dc:
return fc::Fcmkey_dc; // Ctrl+Meta+Del
case fc::Fkey_home:
return fc::Fcmkey_home; // Ctrl+Meta+Home
case fc::Fkey_end:
return fc::Fcmkey_end; // Ctrl+Meta+End
case fc::Fkey_ppage:
return fc::Fcmkey_ppage; // Ctrl+Meta+PgUp
case fc::Fkey_npage:
return fc::Fcmkey_npage; // Ctrl+Meta+PgDn
default:
return key_id;
}
ModifierKey m{};
std::memset (&m, 0x00, sizeof(m));
m.shift = 1;
m.ctrl = 1;
key_map[{m, FKey::Up}] = FKey::Shift_Ctrl_up; // Shift+Ctrl+Up
key_map[{m, FKey::Down}] = FKey::Shift_Ctrl_down; // Shift+Ctrl+Down
key_map[{m, FKey::Left}] = FKey::Shift_Ctrl_left; // Shift+Ctrl+Left
key_map[{m, FKey::Right}] = FKey::Shift_Ctrl_right; // Shift+Ctrl+Right
key_map[{m, FKey::Insert}] = FKey::Shift_Ctrl_insert; // Shift+Ctrl+Ins
key_map[{m, FKey::Del_char}] = FKey::Shift_Ctrl_del_char; // Shift+Ctrl+Del
key_map[{m, FKey::Home}] = FKey::Shift_Ctrl_home; // Shift+Ctrl+Home
key_map[{m, FKey::End}] = FKey::Shift_Ctrl_end; // Shift+Ctrl+End
key_map[{m, FKey::Page_up}] = FKey::Shift_Ctrl_page_up; // Shift+Ctrl+PgUp
key_map[{m, FKey::Page_down}] = FKey::Shift_Ctrl_page_down; // Shift+Ctrl+PgDn
}
//----------------------------------------------------------------------
FKey FTermLinux::shiftCtrlAltKeyCorrection (const FKey& key_id) const
inline void FTermLinux::shiftAltKeyCorrection()
{
switch ( key_id )
{
case fc::Fkey_up:
return fc::Fcmkey_sup; // Shift+Ctrl+Meta+Up
ModifierKey m{};
std::memset (&m, 0x00, sizeof(m));
m.shift = 1;
m.alt = 1;
key_map[{m, FKey::Up}] = FKey::Shift_Meta_up; // Shift+Meta+Up
key_map[{m, FKey::Down}] = FKey::Shift_Meta_down; // Shift+Meta+Down
key_map[{m, FKey::Left}] = FKey::Shift_Meta_left; // Shift+Meta+Left
key_map[{m, FKey::Right}] = FKey::Shift_Meta_right; // Shift+Meta+Right
key_map[{m, FKey::Insert}] = FKey::Shift_Meta_insert; // Shift+Meta+Ins
key_map[{m, FKey::Del_char}] = FKey::Shift_Meta_del_char; // Shift+Meta+Del
key_map[{m, FKey::Home}] = FKey::Shift_Meta_home; // Shift+Meta+Home
key_map[{m, FKey::End}] = FKey::Shift_Meta_end; // Shift+Meta+End
key_map[{m, FKey::Page_up}] = FKey::Shift_Meta_page_up; // Shift+Meta+PgUp
key_map[{m, FKey::Page_down}] = FKey::Shift_Meta_page_down; // Shift+Meta+PgDn
}
case fc::Fkey_down:
return fc::Fcmkey_sdown; // Shift+Ctrl+Meta+Down
//----------------------------------------------------------------------
inline void FTermLinux::ctrlAltKeyCorrection()
{
ModifierKey m{};
std::memset (&m, 0x00, sizeof(m));
m.ctrl = 1;
m.alt = 1;
key_map[{m, FKey::Up}] = FKey::Ctrl_Meta_up; // Ctrl+Meta+Up
key_map[{m, FKey::Down}] = FKey::Ctrl_Meta_down; // Ctrl+Meta+Down
key_map[{m, FKey::Left}] = FKey::Ctrl_Meta_left; // Ctrl+Meta+Left
key_map[{m, FKey::Right}] = FKey::Ctrl_Meta_right; // Ctrl+Meta+Right
key_map[{m, FKey::Insert}] = FKey::Ctrl_Meta_insert; // Ctrl+Meta+Ins
key_map[{m, FKey::Del_char}] = FKey::Ctrl_Meta_del_char; // Ctrl+Meta+Del
key_map[{m, FKey::Home}] = FKey::Ctrl_Meta_home; // Ctrl+Meta+Home
key_map[{m, FKey::End}] = FKey::Ctrl_Meta_end; // Ctrl+Meta+End
key_map[{m, FKey::Page_up}] = FKey::Ctrl_Meta_page_up; // Ctrl+Meta+PgUp
key_map[{m, FKey::Page_down}] = FKey::Ctrl_Meta_page_down; // Ctrl+Meta+PgDn
}
case fc::Fkey_left:
return fc::Fcmkey_sleft; // Shift+Ctrl+Meta+Left
case fc::Fkey_right:
return fc::Fcmkey_sright; // Shift+Ctrl+Meta+Right
case fc::Fkey_ic:
return fc::Fcmkey_sic; // Shift+Ctrl+Meta+Ins
case fc::Fkey_dc:
return fc::Fcmkey_sdc; // Shift+Ctrl+Meta+Del
case fc::Fkey_home:
return fc::Fcmkey_shome; // Shift+Ctrl+Meta+Home
case fc::Fkey_end:
return fc::Fcmkey_send; // Shift+Ctrl+Meta+End
case fc::Fkey_ppage:
return fc::Fcmkey_sppage; // Shift+Ctrl+Meta+PgUp
case fc::Fkey_npage:
return fc::Fcmkey_snpage; // Shift+Ctrl+Meta+PgDn
default:
return key_id;
}
//----------------------------------------------------------------------
inline void FTermLinux::shiftCtrlAltKeyCorrection()
{
ModifierKey m{};
std::memset (&m, 0x00, sizeof(m));
m.shift = 1;
m.ctrl = 1;
m.alt = 1;
key_map[{m, FKey::Up}] = FKey::Shift_Ctrl_Meta_up; // Shift+Ctrl+Meta+Up
key_map[{m, FKey::Down}] = FKey::Shift_Ctrl_Meta_down; // Shift+Ctrl+Meta+Down
key_map[{m, FKey::Left}] = FKey::Shift_Ctrl_Meta_left; // Shift+Ctrl+Meta+Left
key_map[{m, FKey::Right}] = FKey::Shift_Ctrl_Meta_right; // Shift+Ctrl+Meta+Right
key_map[{m, FKey::Insert}] = FKey::Shift_Ctrl_Meta_insert; // Shift+Ctrl+Meta+Ins
key_map[{m, FKey::Del_char}] = FKey::Shift_Ctrl_Meta_del_char; // Shift+Ctrl+Meta+Del
key_map[{m, FKey::Home}] = FKey::Shift_Ctrl_Meta_home; // Shift+Ctrl+Meta+Home
key_map[{m, FKey::End}] = FKey::Shift_Ctrl_Meta_end; // Shift+Ctrl+Meta+End
key_map[{m, FKey::Page_up}] = FKey::Shift_Ctrl_Meta_page_up; // Shift+Ctrl+Meta+PgUp
key_map[{m, FKey::Page_down}] = FKey::Shift_Ctrl_Meta_page_down; // Shift+Ctrl+Meta+PgDn
}
//----------------------------------------------------------------------
inline void FTermLinux::initSpecialCharacter() const
{
const auto& fterm_data = FTerm::getFTermData();
const wchar_t c1 = fc::UpperHalfBlock;
const wchar_t c2 = fc::LowerHalfBlock;
const wchar_t c3 = fc::FullBlock;
const auto c1 = wchar_t(UniChar::UpperHalfBlock);
const auto c2 = wchar_t(UniChar::LowerHalfBlock);
const auto c3 = wchar_t(UniChar::FullBlock);
if ( FTerm::charEncode(c1, fc::PC) == FTerm::charEncode(c1, fc::ASCII)
|| FTerm::charEncode(c2, fc::PC) == FTerm::charEncode(c2, fc::ASCII)
|| FTerm::charEncode(c3, fc::PC) == FTerm::charEncode(c3, fc::ASCII) )
if ( FTerm::charEncode(c1, Encoding::PC) == FTerm::charEncode(c1, Encoding::ASCII)
|| FTerm::charEncode(c2, Encoding::PC) == FTerm::charEncode(c2, Encoding::ASCII)
|| FTerm::charEncode(c3, Encoding::PC) == FTerm::charEncode(c3, Encoding::ASCII) )
{
fterm_data->supportShadowCharacter (false);
}
const wchar_t c4 = fc::RightHalfBlock;
const wchar_t c5 = fc::LeftHalfBlock;
const auto c4 = wchar_t(UniChar::RightHalfBlock);
const auto c5 = wchar_t(UniChar::LeftHalfBlock);
if ( FTerm::charEncode(c4, fc::PC) == FTerm::charEncode(c4, fc::ASCII)
|| FTerm::charEncode(c5, fc::PC) == FTerm::charEncode(c5, fc::ASCII) )
if ( FTerm::charEncode(c4, Encoding::PC) == FTerm::charEncode(c4, Encoding::ASCII)
|| FTerm::charEncode(c5, Encoding::PC) == FTerm::charEncode(c5, Encoding::ASCII) )
{
fterm_data->supportHalfBlockCharacter (false);
}

View File

@ -52,7 +52,7 @@ bool FTermXTerminal::mouse_support{false};
// public methods of FTermXTerminal
//----------------------------------------------------------------------
void FTermXTerminal::setCursorStyle (fc::xtermCursorStyle style)
void FTermXTerminal::setCursorStyle (XTermCursorStyle style)
{
// Set the xterm cursor style
@ -321,7 +321,7 @@ void FTermXTerminal::setXTermCursorStyle()
if ( term_detection->isKdeTerminal() )
return;
if ( TCAP(fc::t_cursor_style)
if ( TCAP(t_cursor_style)
|| term_detection->isXTerminal()
|| term_detection->isCygwinTerminal()
|| term_detection->isMinttyTerm()

View File

@ -333,7 +333,7 @@ void FTextView::clear()
//----------------------------------------------------------------------
void FTextView::onKeyPress (FKeyEvent* ev)
{
const auto idx = int(ev->key());
const auto idx = ev->key();
if ( key_map.find(idx) != key_map.end() )
{
@ -345,7 +345,7 @@ void FTextView::onKeyPress (FKeyEvent* ev)
//----------------------------------------------------------------------
void FTextView::onMouseDown (FMouseEvent* ev)
{
if ( ev->getButton() != fc::LeftButton )
if ( ev->getButton() != MouseButton::Left )
return;
if ( ! hasFocus() )
@ -371,21 +371,13 @@ void FTextView::onMouseDown (FMouseEvent* ev)
&& dialog->isResizeable()
&& ! dialog->isZoomed() )
{
const int b = ev->getButton();
const auto b = ev->getButton();
const auto& tp = ev->getTermPos();
const auto& p = parent->termToWidgetPos(tp);
parent->setFocus();
try
{
const auto& _ev = \
std::make_shared<FMouseEvent>(fc::MouseDown_Event, p, tp, b);
FApplication::sendEvent (parent, _ev.get());
}
catch (const std::bad_alloc&)
{
badAllocOutput ("FMouseEvent");
}
const auto& _ev = \
std::make_shared<FMouseEvent>(Event::MouseDown, p, tp, b);
FApplication::sendEvent (parent, _ev.get());
}
}
@ -400,21 +392,13 @@ void FTextView::onMouseUp (FMouseEvent* ev)
if ( dialog->isResizeable() && ! dialog->isZoomed() )
{
const int b = ev->getButton();
const auto b = ev->getButton();
const auto& tp = ev->getTermPos();
const auto& p = parent->termToWidgetPos(tp);
parent->setFocus();
try
{
const auto& _ev = \
std::make_shared<FMouseEvent>(fc::MouseUp_Event, p, tp, b);
FApplication::sendEvent (parent, _ev.get());
}
catch (const std::bad_alloc&)
{
badAllocOutput ("FMouseEvent");
}
const auto& _ev = \
std::make_shared<FMouseEvent>(Event::MouseUp, p, tp, b);
FApplication::sendEvent (parent, _ev.get());
}
}
@ -433,21 +417,13 @@ void FTextView::onMouseMove (FMouseEvent* ev)
if ( dialog->isResizeable() && ! dialog->isZoomed() )
{
const int b = ev->getButton();
const auto b = ev->getButton();
const auto& tp = ev->getTermPos();
const auto& p = parent->termToWidgetPos(tp);
parent->setFocus();
try
{
const auto& _ev = \
std::make_shared<FMouseEvent>(fc::MouseMove_Event, p, tp, b);
FApplication::sendEvent (parent, _ev.get());
}
catch (const std::bad_alloc&)
{
badAllocOutput ("FMouseEvent");
}
const auto& _ev = \
std::make_shared<FMouseEvent>(Event::MouseMove, p, tp, b);
FApplication::sendEvent (parent, _ev.get());
}
}
}
@ -456,20 +432,12 @@ void FTextView::onMouseMove (FMouseEvent* ev)
void FTextView::onWheel (FWheelEvent* ev)
{
static constexpr int distance = 4;
const MouseWheel wheel = ev->getWheel();
switch ( ev->getWheel() )
{
case fc::WheelUp:
scrollBy (0, -distance);
break;
case fc::WheelDown:
scrollBy (0, distance);
break;
default:
break;
}
if ( wheel == MouseWheel::Up )
scrollBy (0, -distance);
else if ( wheel == MouseWheel::Down )
scrollBy (0, distance);
if ( isShown() )
drawText();
@ -574,8 +542,8 @@ std::size_t FTextView::getTextWidth() const
//----------------------------------------------------------------------
void FTextView::init()
{
initScrollbar (vbar, fc::vertical, this, &FTextView::cb_vbarChange);
initScrollbar (hbar, fc::horizontal, this, &FTextView::cb_hbarChange);
initScrollbar (vbar, Orientation::Vertical, this, &FTextView::cb_vbarChange);
initScrollbar (hbar, Orientation::Horizontal, this, &FTextView::cb_hbarChange);
resetColors();
nf_offset = FTerm::isNewFont() ? 1 : 0;
setTopPadding(1);
@ -588,14 +556,14 @@ void FTextView::init()
//----------------------------------------------------------------------
inline void FTextView::mapKeyFunctions()
{
key_map[fc::Fkey_up] = [this] { scrollBy (0, -1); };
key_map[fc::Fkey_down] = [this] { scrollBy (0, 1); };
key_map[fc::Fkey_left] = [this] { scrollBy (-1, 0); };
key_map[fc::Fkey_right] = [this] { scrollBy (1, 0); };
key_map[fc::Fkey_ppage] = [this] { scrollBy (0, -int(getTextHeight())); };
key_map[fc::Fkey_npage] = [this] { scrollBy (0, int(getTextHeight())); };
key_map[fc::Fkey_home] = [this] { scrollToBegin(); };
key_map[fc::Fkey_end] = [this] { scrollToEnd(); };
key_map[FKey::Up] = [this] { scrollBy (0, -1); };
key_map[FKey::Down] = [this] { scrollBy (0, 1); };
key_map[FKey::Left] = [this] { scrollBy (-1, 0); };
key_map[FKey::Right] = [this] { scrollBy (1, 0); };
key_map[FKey::Page_up] = [this] { scrollBy (0, -int(getTextHeight())); };
key_map[FKey::Page_down] = [this] { scrollBy (0, int(getTextHeight())); };
key_map[FKey::Home] = [this] { scrollToBegin(); };
key_map[FKey::End] = [this] { scrollToEnd(); };
}
//----------------------------------------------------------------------
@ -722,7 +690,7 @@ inline bool FTextView::isPrintable (wchar_t ch) const
{
// Check for printable characters
const bool utf8 = ( FTerm::getEncoding() == fc::UTF8 ) ? true : false;
const bool utf8 = ( FTerm::getEncoding() == Encoding::UTF8 ) ? true : false;
if ( (utf8 && std::iswprint(std::wint_t(ch)))
|| (!utf8 && std::isprint(char(ch))) )
@ -761,51 +729,51 @@ void FTextView::changeOnResize() const
//----------------------------------------------------------------------
void FTextView::cb_vbarChange (const FWidget*)
{
const FScrollbar::SType scrollType = vbar->getScrollType();
const FScrollbar::ScrollType scrollType = vbar->getScrollType();
static constexpr int wheel_distance = 4;
int distance{1};
assert ( scrollType == FScrollbar::SType::noScroll
|| scrollType == FScrollbar::SType::scrollJump
|| scrollType == FScrollbar::SType::scrollStepBackward
|| scrollType == FScrollbar::SType::scrollStepForward
|| scrollType == FScrollbar::SType::scrollPageBackward
|| scrollType == FScrollbar::SType::scrollPageForward
|| scrollType == FScrollbar::SType::scrollWheelUp
|| scrollType == FScrollbar::SType::scrollWheelDown );
assert ( scrollType == FScrollbar::ScrollType::None
|| scrollType == FScrollbar::ScrollType::Jump
|| scrollType == FScrollbar::ScrollType::StepBackward
|| scrollType == FScrollbar::ScrollType::StepForward
|| scrollType == FScrollbar::ScrollType::PageBackward
|| scrollType == FScrollbar::ScrollType::PageForward
|| scrollType == FScrollbar::ScrollType::WheelUp
|| scrollType == FScrollbar::ScrollType::WheelDown );
if ( scrollType >= FScrollbar::SType::scrollStepBackward )
if ( scrollType >= FScrollbar::ScrollType::StepBackward )
update_scrollbar = true;
else
update_scrollbar = false;
switch ( scrollType )
{
case FScrollbar::SType::noScroll:
case FScrollbar::ScrollType::None:
break;
case FScrollbar::SType::scrollPageBackward:
case FScrollbar::ScrollType::PageBackward:
distance = int(getClientHeight());
// fall through
case FScrollbar::SType::scrollStepBackward:
case FScrollbar::ScrollType::StepBackward:
scrollBy (0, -distance);
break;
case FScrollbar::SType::scrollPageForward:
case FScrollbar::ScrollType::PageForward:
distance = int(getClientHeight());
// fall through
case FScrollbar::SType::scrollStepForward:
case FScrollbar::ScrollType::StepForward:
scrollBy (0, distance);
break;
case FScrollbar::SType::scrollJump:
case FScrollbar::ScrollType::Jump:
scrollToY (vbar->getValue());
break;
case FScrollbar::SType::scrollWheelUp:
case FScrollbar::ScrollType::WheelUp:
scrollBy (0, -wheel_distance);
break;
case FScrollbar::SType::scrollWheelDown:
case FScrollbar::ScrollType::WheelDown:
scrollBy (0, wheel_distance);
break;
}
@ -816,51 +784,51 @@ void FTextView::cb_vbarChange (const FWidget*)
//----------------------------------------------------------------------
void FTextView::cb_hbarChange (const FWidget*)
{
const FScrollbar::SType scrollType = hbar->getScrollType();
const FScrollbar::ScrollType scrollType = hbar->getScrollType();
static constexpr int wheel_distance = 4;
int distance{1};
assert ( scrollType == FScrollbar::SType::noScroll
|| scrollType == FScrollbar::SType::scrollJump
|| scrollType == FScrollbar::SType::scrollStepBackward
|| scrollType == FScrollbar::SType::scrollStepForward
|| scrollType == FScrollbar::SType::scrollPageBackward
|| scrollType == FScrollbar::SType::scrollPageForward
|| scrollType == FScrollbar::SType::scrollWheelUp
|| scrollType == FScrollbar::SType::scrollWheelDown );
assert ( scrollType == FScrollbar::ScrollType::None
|| scrollType == FScrollbar::ScrollType::Jump
|| scrollType == FScrollbar::ScrollType::StepBackward
|| scrollType == FScrollbar::ScrollType::StepForward
|| scrollType == FScrollbar::ScrollType::PageBackward
|| scrollType == FScrollbar::ScrollType::PageForward
|| scrollType == FScrollbar::ScrollType::WheelUp
|| scrollType == FScrollbar::ScrollType::WheelDown );
if ( scrollType >= FScrollbar::SType::scrollStepBackward )
if ( scrollType >= FScrollbar::ScrollType::StepBackward )
update_scrollbar = true;
else
update_scrollbar = false;
switch ( scrollType )
{
case FScrollbar::SType::noScroll:
case FScrollbar::ScrollType::None:
break;
case FScrollbar::SType::scrollPageBackward:
case FScrollbar::ScrollType::PageBackward:
distance = int(getClientWidth());
// fall through
case FScrollbar::SType::scrollStepBackward:
case FScrollbar::ScrollType::StepBackward:
scrollBy (-distance, 0);
break;
case FScrollbar::SType::scrollPageForward:
case FScrollbar::ScrollType::PageForward:
distance = int(getClientWidth());
// fall through
case FScrollbar::SType::scrollStepForward:
case FScrollbar::ScrollType::StepForward:
scrollBy (distance, 0);
break;
case FScrollbar::SType::scrollJump:
case FScrollbar::ScrollType::Jump:
scrollToX (hbar->getValue());
break;
case FScrollbar::SType::scrollWheelUp:
case FScrollbar::ScrollType::WheelUp:
scrollBy (-wheel_distance, 0);
break;
case FScrollbar::SType::scrollWheelDown:
case FScrollbar::ScrollType::WheelDown:
scrollBy (wheel_distance, 0);
break;
}

View File

@ -186,7 +186,7 @@ bool FToggleButton::setChecked (bool enable)
void FToggleButton::setText (const FString& txt)
{
text.setString(txt);
std::size_t hotkey_mark = ( getHotkey(text) ) ? 1 : 0;
std::size_t hotkey_mark = ( getHotkey(text) != FKey::None ) ? 1 : 0;
std::size_t column_width = getColumnWidth(text);
setWidth(button_width + column_width - hotkey_mark);
@ -207,7 +207,7 @@ void FToggleButton::hide()
//----------------------------------------------------------------------
void FToggleButton::onMouseDown (FMouseEvent* ev)
{
if ( ev->getButton() != fc::LeftButton )
if ( ev->getButton() != MouseButton::Left )
return;
if ( hasFocus() )
@ -228,7 +228,7 @@ void FToggleButton::onMouseDown (FMouseEvent* ev)
//----------------------------------------------------------------------
void FToggleButton::onMouseUp (FMouseEvent* ev)
{
if ( ev->getButton() != fc::LeftButton )
if ( ev->getButton() != MouseButton::Left )
return;
if ( ! getTermGeometry().contains(ev->getTermPos()) )
@ -325,23 +325,23 @@ void FToggleButton::onFocusOut (FFocusEvent* out_ev)
focus_inside_group = true;
out_ev->ignore();
if ( out_ev->getFocusType() == fc::FocusNextWidget )
if ( out_ev->getFocusType() == FocusTypes::NextWidget )
getGroup()->focusNextChild();
if ( out_ev->getFocusType() == fc::FocusPreviousWidget )
if ( out_ev->getFocusType() == FocusTypes::PreviousWidget )
getGroup()->focusPrevChild();
redraw();
}
else if ( this == getGroup()->getLastButton()
&& out_ev->getFocusType() == fc::FocusNextWidget )
&& out_ev->getFocusType() == FocusTypes::NextWidget )
{
out_ev->ignore();
getGroup()->focusNextChild();
redraw();
}
else if ( this == getGroup()->getFirstButton()
&& out_ev->getFocusType() == fc::FocusPreviousWidget )
&& out_ev->getFocusType() == FocusTypes::PreviousWidget )
{
out_ev->ignore();
getGroup()->focusPrevChild();
@ -423,46 +423,40 @@ void FToggleButton::onKeyPress (FKeyEvent* ev)
if ( ! isEnabled() )
return;
const FKey key = ev->key();
const auto key = ev->key();
switch ( key )
if ( key == FKey::Return
|| key == FKey::Enter
|| key == FKey::Space )
{
case fc::Fkey_return:
case fc::Fkey_enter:
case fc::Fkey_space:
if ( isRadioButton() )
if ( isRadioButton() )
{
if ( ! checked )
{
if ( ! checked )
{
checked = true;
processToggle();
}
}
else
{
checked = ! checked;
checked = true;
processToggle();
}
processClick();
ev->accept();
break;
}
else
{
checked = ! checked;
processToggle();
}
case fc::Fkey_down:
case fc::Fkey_right:
focus_inside_group = true;
focusNextChild();
ev->accept();
break;
case fc::Fkey_up:
case fc::Fkey_left:
focus_inside_group = true;
focusPrevChild();
ev->accept();
break;
default:
break;
processClick();
ev->accept();
}
else if ( key == FKey::Down || key == FKey::Right )
{
focus_inside_group = true;
focusNextChild();
ev->accept();
}
else if ( key == FKey::Up || key == FKey::Left )
{
focus_inside_group = true;
focusPrevChild();
ev->accept();
}
if ( ev->isAccepted() )
@ -524,7 +518,7 @@ void FToggleButton::drawText (const FString& label_text, std::size_t hotkeypos)
//----------------------------------------------------------------------
void FToggleButton::correctSize (FSize& size) const
{
const std::size_t hotkey_mark = ( getHotkey(text) ) ? 1 : 0;
const std::size_t hotkey_mark = ( getHotkey(text) != FKey::None ) ? 1 : 0;
const std::size_t column_width = getColumnWidth(text);
const std::size_t min_width = button_width + column_width - hotkey_mark;

View File

@ -201,10 +201,10 @@ FColor FVTerm::rgb2ColorIndex (uInt8 r, uInt8 g, uInt8 b) const
{
// Converts a 24-bit RGB color to a 256-color compatible approximation
const FColor ri = (((r * 5) + 127) / 255) * 36;
const FColor gi = (((g * 5) + 127) / 255) * 6;
const FColor bi = (((b * 5) + 127) / 255);
return 16 + ri + gi + bi;
const uInt16 ri = (((r * 5) + 127) / 255) * 36;
const uInt16 gi = (((g * 5) + 127) / 255) * 6;
const uInt16 bi = (((b * 5) + 127) / 255);
return FColor(16 + ri + gi + bi);
}
//----------------------------------------------------------------------
@ -229,7 +229,7 @@ void FVTerm::setNonBlockingRead (bool enable)
}
//----------------------------------------------------------------------
void FVTerm::clearArea (int fillchar)
void FVTerm::clearArea (wchar_t fillchar)
{
clearArea (vwin, fillchar);
}
@ -274,7 +274,7 @@ bool FVTerm::updateTerminal() const
// Check if terminal updates were stopped, application is stopping,
// VTerm has no changes, or the drawing is not completed
if ( no_terminal_updates || FApplication::isQuit()
|| ! isFlushTimeout()
|| ! (isFlushTimeout() || force_terminal_update)
|| ! (hasPendingUpdates(vterm) && draw_completed) )
{
return false;
@ -531,37 +531,37 @@ void FVTerm::print (const FPoint& p)
//----------------------------------------------------------------------
void FVTerm::print (const FStyle& style)
{
FAttribute attr = style.getStyle();
Style attr = style.getStyle();
if ( attr == 0 )
if ( attr == Style::None )
setNormal();
else if ( (attr & fc::Bold) != 0 )
else if ( (attr & Style::Bold) != Style::None )
setBold();
else if ( (attr & fc::Dim) != 0 )
else if ( (attr & Style::Dim) != Style::None )
setDim();
else if ( (attr & fc::Italic) != 0 )
else if ( (attr & Style::Italic) != Style::None )
setItalic();
else if ( (attr & fc::Underline) != 0 )
else if ( (attr & Style::Underline) != Style::None )
setUnderline();
else if ( (attr & fc::Blink) != 0 )
else if ( (attr & Style::Blink) != Style::None )
setBlink();
else if ( (attr & fc::Reverse) != 0 )
else if ( (attr & Style::Reverse) != Style::None )
setReverse();
else if ( (attr & fc::Standout) != 0 )
else if ( (attr & Style::Standout) != Style::None )
setStandout();
else if ( (attr & fc::Invisible) != 0 )
else if ( (attr & Style::Invisible) != Style::None )
setInvisible();
else if ( (attr & fc::Protected) != 0 )
else if ( (attr & Style::Protected) != Style::None )
setProtected();
else if ( (attr & fc::CrossedOut) != 0 )
else if ( (attr & Style::CrossedOut) != Style::None )
setCrossedOut();
else if ( (attr & fc::DoubleUnderline) != 0 )
else if ( (attr & Style::DoubleUnderline) != Style::None )
setDoubleUnderline();
else if ( (attr & fc::Transparent) != 0 )
else if ( (attr & Style::Transparent) != Style::None )
setTransparent();
else if ( (attr & fc::ColorOverlay) != 0 )
else if ( (attr & Style::ColorOverlay) != Style::None )
setColorOverlay();
else if ( (attr & fc::InheritBackground) != 0 )
else if ( (attr & Style::InheritBackground) != Style::None )
setInheritBackground();
}
@ -804,7 +804,7 @@ bool FVTerm::updateVTermCursor (const FTermArea* area) const
if ( isInsideArea (FPoint{cx, cy}, area)
&& isInsideTerminal (FPoint{x, y})
&& isCovered (FPoint{x, y}, area) == CoveredState::non_covered )
&& isCovered (FPoint{x, y}, area) == CoveredState::None )
{
vterm->input_cursor_x = x;
vterm->input_cursor_y = y;
@ -1107,7 +1107,7 @@ void FVTerm::scrollAreaForward (FTermArea* area) const
area->changes[y_max].xmax = uInt(area->width - 1);
area->has_changes = true;
if ( area == vdesktop && TCAP(fc::t_scroll_forward) )
if ( area == vdesktop && TCAP(t_scroll_forward) )
{
setTermXY (0, vdesktop->height);
FTerm::scrollTermForward();
@ -1159,7 +1159,7 @@ void FVTerm::scrollAreaReverse (FTermArea* area) const
area->changes[0].xmax = uInt(area->width - 1);
area->has_changes = true;
if ( area == vdesktop && TCAP(fc::t_scroll_reverse) )
if ( area == vdesktop && TCAP(t_scroll_reverse) )
{
setTermXY (0, 0);
FTerm::scrollTermReverse();
@ -1175,7 +1175,7 @@ void FVTerm::scrollAreaReverse (FTermArea* area) const
}
//----------------------------------------------------------------------
void FVTerm::clearArea (FTermArea* area, int fillchar) const
void FVTerm::clearArea (FTermArea* area, wchar_t fillchar) const
{
// Clear the area with the current attributes
@ -1297,8 +1297,8 @@ inline void FVTerm::resetTextAreaToDefault ( const FTermArea* area
FLineChanges unchanged;
default_char.ch[0] = ' ';
default_char.fg_color = fc::Default;
default_char.bg_color = fc::Default;
default_char.fg_color = FColor::Default;
default_char.bg_color = FColor::Default;
default_char.attr.byte[0] = 0;
default_char.attr.byte[1] = 0;
default_char.attr.byte[2] = 0;
@ -1369,9 +1369,9 @@ FVTerm::CoveredState FVTerm::isCovered ( const FPoint& pos
// Determines the covered state for the given position
if ( ! area )
return CoveredState::non_covered;
return CoveredState::None;
auto is_covered = CoveredState::non_covered;
auto is_covered = CoveredState::None;
if ( FWidget::getWindowList() && ! FWidget::getWindowList()->empty() )
{
@ -1399,11 +1399,11 @@ FVTerm::CoveredState FVTerm::isCovered ( const FPoint& pos
if ( tmp->attr.bit.color_overlay )
{
is_covered = CoveredState::half_covered;
is_covered = CoveredState::Half;
}
else if ( ! tmp->attr.bit.transparent )
{
is_covered = CoveredState::fully_covered;
is_covered = CoveredState::Full;
break;
}
}
@ -1431,12 +1431,12 @@ inline void FVTerm::updateOverlappedColor ( const FChar& area_char
nc.attr.bit.reverse = false;
nc.attr.bit.standout = false;
if ( nc.ch[0] == fc::LowerHalfBlock
|| nc.ch[0] == fc::UpperHalfBlock
|| nc.ch[0] == fc::LeftHalfBlock
|| nc.ch[0] == fc::RightHalfBlock
|| nc.ch[0] == fc::MediumShade
|| nc.ch[0] == fc::FullBlock )
if ( nc.ch[0] == UniChar::LowerHalfBlock
|| nc.ch[0] == UniChar::UpperHalfBlock
|| nc.ch[0] == UniChar::LeftHalfBlock
|| nc.ch[0] == UniChar::RightHalfBlock
|| nc.ch[0] == UniChar::MediumShade
|| nc.ch[0] == UniChar::FullBlock )
nc.ch[0] = ' ';
nc.attr.bit.no_changes = bool(vterm_char.attr.bit.printed && vterm_char == nc);
@ -1466,12 +1466,12 @@ inline void FVTerm::updateShadedCharacter ( const FChar& area_char
cover_char.attr.bit.reverse = false;
cover_char.attr.bit.standout = false;
if ( cover_char.ch[0] == fc::LowerHalfBlock
|| cover_char.ch[0] == fc::UpperHalfBlock
|| cover_char.ch[0] == fc::LeftHalfBlock
|| cover_char.ch[0] == fc::RightHalfBlock
|| cover_char.ch[0] == fc::MediumShade
|| cover_char.ch[0] == fc::FullBlock )
if ( cover_char.ch[0] == UniChar::LowerHalfBlock
|| cover_char.ch[0] == UniChar::UpperHalfBlock
|| cover_char.ch[0] == UniChar::LeftHalfBlock
|| cover_char.ch[0] == UniChar::RightHalfBlock
|| cover_char.ch[0] == UniChar::MediumShade
|| cover_char.ch[0] == UniChar::FullBlock )
cover_char.ch[0] = ' ';
cover_char.attr.bit.no_changes = \
@ -1525,10 +1525,10 @@ bool FVTerm::updateVTermCharacter ( const FTermArea* area
// Get covered state
const auto is_covered = isCovered(terminal_pos, area);
if ( is_covered == CoveredState::fully_covered )
if ( is_covered == CoveredState::Full )
return false;
if ( is_covered == CoveredState::half_covered )
if ( is_covered == CoveredState::Half )
{
// Overlapped character
auto oc = getOverlappedCharacter (terminal_pos, area);
@ -1705,12 +1705,12 @@ FChar FVTerm::generateCharacter (const FPoint& pos)
s_ch.attr.bit.reverse = false;
s_ch.attr.bit.standout = false;
if ( s_ch.ch[0] == fc::LowerHalfBlock
|| s_ch.ch[0] == fc::UpperHalfBlock
|| s_ch.ch[0] == fc::LeftHalfBlock
|| s_ch.ch[0] == fc::RightHalfBlock
|| s_ch.ch[0] == fc::MediumShade
|| s_ch.ch[0] == fc::FullBlock )
if ( s_ch.ch[0] == UniChar::LowerHalfBlock
|| s_ch.ch[0] == UniChar::UpperHalfBlock
|| s_ch.ch[0] == UniChar::LeftHalfBlock
|| s_ch.ch[0] == UniChar::RightHalfBlock
|| s_ch.ch[0] == UniChar::MediumShade
|| s_ch.ch[0] == UniChar::FullBlock )
s_ch.ch[0] = ' ';
sc = &s_ch;
@ -1732,7 +1732,7 @@ FChar FVTerm::generateCharacter (const FPoint& pos)
}
//----------------------------------------------------------------------
FChar FVTerm::getCharacter ( character_type char_type
FChar FVTerm::getCharacter ( CharacterType char_type
, const FPoint& pos
, const FTermArea* area )
{
@ -1763,7 +1763,7 @@ FChar FVTerm::getCharacter ( character_type char_type
// char_type can be "overlapped_character"
// or "covered_character"
if ( char_type == covered_character )
if ( char_type == CharacterType::Covered )
significant_char = bool(layer >= FWindow::getWindowLayer(win_obj));
else
significant_char = bool(layer < FWindow::getWindowLayer(win_obj));
@ -1783,7 +1783,7 @@ FChar FVTerm::getCharacter ( character_type char_type
if ( geometry.contains(x, y) )
getAreaCharacter (FPoint{x, y}, win, cc);
}
else if ( char_type == covered_character )
else if ( char_type == CharacterType::Covered )
break;
}
@ -1794,14 +1794,14 @@ FChar FVTerm::getCharacter ( character_type char_type
inline FChar FVTerm::getCoveredCharacter (const FPoint& pos, const FTermArea* area)
{
// Gets the covered character for a given position
return getCharacter (covered_character, pos, area);
return getCharacter (CharacterType::Covered, pos, area);
}
//----------------------------------------------------------------------
inline FChar FVTerm::getOverlappedCharacter (const FPoint& pos, const FTermArea* area)
{
// Gets the overlapped character for a given position
return getCharacter (overlapped_character, pos, area);
return getCharacter (CharacterType::Overlapped, pos, area);
}
//----------------------------------------------------------------------
@ -1832,8 +1832,8 @@ void FVTerm::init()
// term_attribute stores the current state of the terminal
term_attribute.ch = {{ L'\0' }};
term_attribute.fg_color = fc::Default;
term_attribute.bg_color = fc::Default;
term_attribute.fg_color = FColor::Default;
term_attribute.bg_color = FColor::Default;
term_attribute.attr.byte[0] = 0;
term_attribute.attr.byte[1] = 0;
term_attribute.attr.byte[2] = 0;
@ -1945,12 +1945,12 @@ void FVTerm::putAreaCharacter ( const FPoint& pos, const FTermArea* area
ch.attr.bit.reverse = false;
ch.attr.bit.standout = false;
if ( ch.ch[0] == fc::LowerHalfBlock
|| ch.ch[0] == fc::UpperHalfBlock
|| ch.ch[0] == fc::LeftHalfBlock
|| ch.ch[0] == fc::RightHalfBlock
|| ch.ch[0] == fc::MediumShade
|| ch.ch[0] == fc::FullBlock )
if ( ch.ch[0] == UniChar::LowerHalfBlock
|| ch.ch[0] == UniChar::UpperHalfBlock
|| ch.ch[0] == UniChar::LeftHalfBlock
|| ch.ch[0] == UniChar::RightHalfBlock
|| ch.ch[0] == UniChar::MediumShade
|| ch.ch[0] == UniChar::FullBlock )
ch.ch[0] = ' ';
std::memcpy (&vterm_char, &ch, sizeof(vterm_char));
@ -2010,9 +2010,9 @@ bool FVTerm::clearTerm (int fillchar) const
{
// Clear the real terminal and put cursor at home
const auto& cl = TCAP(fc::t_clear_screen);
const auto& cd = TCAP(fc::t_clr_eos);
const auto& cb = TCAP(fc::t_clr_eol);
const auto& cl = TCAP(t_clear_screen);
const auto& cd = TCAP(t_clr_eos);
const auto& cb = TCAP(t_clr_eol);
const bool ut = FTermcap::background_color_erase;
const bool normal = FTerm::isNormal (next_attribute);
appendAttributes (next_attribute);
@ -2113,7 +2113,7 @@ bool FVTerm::canClearToEOL (uInt xmin, uInt y)
// => clear to end of line
auto& vt = vterm;
const auto& ce = TCAP(fc::t_clr_eol);
const auto& ce = TCAP(t_clr_eol);
const auto& min_char = vt->data[y * uInt(vt->width) + xmin];
if ( ce && min_char.ch[0] == ' ' )
@ -2148,7 +2148,7 @@ bool FVTerm::canClearLeadingWS (uInt& xmin, uInt y)
// => clear from xmin to beginning of line
auto& vt = vterm;
const auto& cb = TCAP(fc::t_clr_bol);
const auto& cb = TCAP(t_clr_bol);
const auto& first_char = vt->data[y * uInt(vt->width)];
if ( cb && first_char.ch[0] == ' ' )
@ -2186,7 +2186,7 @@ bool FVTerm::canClearTrailingWS (uInt& xmax, uInt y)
// => clear from xmax to end of line
auto& vt = vterm;
const auto& ce = TCAP(fc::t_clr_eol);
const auto& ce = TCAP(t_clr_eol);
const auto& last_char = vt->data[(y + 1) * uInt(vt->width) - 1];
if ( ce && last_char.ch[0] == ' ' )
@ -2258,8 +2258,8 @@ void FVTerm::printRange ( uInt xmin, uInt xmax, uInt y
for (uInt x = xmin; x <= xmax; x++)
{
auto& vt = vterm;
const auto& ec = TCAP(fc::t_erase_chars);
const auto& rp = TCAP(fc::t_repeat_char);
const auto& ec = TCAP(t_erase_chars);
const auto& rp = TCAP(t_repeat_char);
auto& print_char = vt->data[y * uInt(vt->width) + x];
print_char.attr.bit.printed = true;
replaceNonPrintableFullwidth (x, print_char);
@ -2271,10 +2271,10 @@ void FVTerm::printRange ( uInt xmin, uInt xmax, uInt y
// Erase character
if ( ec && print_char.ch[0] == ' ' )
{
exit_state erase_state = \
PrintState erase_state = \
eraseCharacters(x, xmax, y, draw_trailing_ws);
if ( erase_state == line_completely_printed )
if ( erase_state == PrintState::LineCompletelyPrinted )
break;
}
else if ( rp ) // Repeat one character n-fold
@ -2298,14 +2298,14 @@ inline void FVTerm::replaceNonPrintableFullwidth ( uInt x
if ( x == 0 && isFullWidthPaddingChar(print_char) )
{
print_char.ch[0] = fc::SingleLeftAngleQuotationMark; //
print_char.ch[0] = wchar_t(UniChar::SingleLeftAngleQuotationMark); //
print_char.ch[1] = L'\0';
print_char.attr.bit.fullwidth_padding = false;
}
else if ( x == uInt(vterm->width - 1)
&& isFullWidthChar(print_char) )
{
print_char.ch[0] = fc::SingleRightAngleQuotationMark; //
print_char.ch[0] = wchar_t(UniChar::SingleRightAngleQuotationMark); //
print_char.ch[1] = L'\0';
print_char.attr.bit.char_width = 1;
}
@ -2361,7 +2361,7 @@ void FVTerm::printFullWidthCharacter ( uInt& x, uInt y
{
// Print ellipses for the 1st full-width character column
appendAttributes (print_char);
appendOutputBuffer (fc::HorizontalEllipsis);
appendOutputBuffer (int(UniChar::HorizontalEllipsis));
term_pos->x_ref()++;
markAsPrinted (x, y);
@ -2370,7 +2370,7 @@ void FVTerm::printFullWidthCharacter ( uInt& x, uInt y
// Print ellipses for the 2nd full-width character column
x++;
appendAttributes (next_char);
appendOutputBuffer (fc::HorizontalEllipsis);
appendOutputBuffer (int(UniChar::HorizontalEllipsis));
term_pos->x_ref()++;
markAsPrinted (x, y);
}
@ -2392,8 +2392,8 @@ void FVTerm::printFullWidthPaddingCharacter ( uInt& x, uInt y
&& isFullWidthPaddingChar(print_char) )
{
// Move cursor one character to the left
const auto& le = TCAP(fc::t_cursor_left);
const auto& LE = TCAP(fc::t_parm_left_cursor);
const auto& le = TCAP(t_cursor_left);
const auto& LE = TCAP(t_parm_left_cursor);
if ( le )
appendOutputBuffer (le);
@ -2416,7 +2416,7 @@ void FVTerm::printFullWidthPaddingCharacter ( uInt& x, uInt y
{
// Print ellipses for the 1st full-width character column
appendAttributes (print_char);
appendOutputBuffer (fc::HorizontalEllipsis);
appendOutputBuffer (int(UniChar::HorizontalEllipsis));
term_pos->x_ref()++;
markAsPrinted (x, y);
}
@ -2432,8 +2432,8 @@ void FVTerm::printHalfCovertFullWidthCharacter ( uInt& x, uInt y
if ( isFullWidthChar(prev_char) && ! isFullWidthPaddingChar(print_char) )
{
// Move cursor one character to the left
const auto& le = TCAP(fc::t_cursor_left);
const auto& LE = TCAP(fc::t_parm_left_cursor);
const auto& le = TCAP(t_cursor_left);
const auto& LE = TCAP(t_parm_left_cursor);
if ( le )
appendOutputBuffer (le);
@ -2446,7 +2446,7 @@ void FVTerm::printHalfCovertFullWidthCharacter ( uInt& x, uInt y
x--;
term_pos->x_ref()--;
appendAttributes (prev_char);
appendOutputBuffer (fc::HorizontalEllipsis);
appendOutputBuffer (int(UniChar::HorizontalEllipsis));
term_pos->x_ref()++;
markAsPrinted (x, y);
x++;
@ -2471,20 +2471,19 @@ inline void FVTerm::skipPaddingCharacter ( uInt& x, uInt y
}
//----------------------------------------------------------------------
FVTerm::exit_state FVTerm::eraseCharacters ( uInt& x, uInt xmax, uInt y
, bool draw_trailing_ws ) const
FVTerm::PrintState FVTerm::eraseCharacters ( uInt& x, uInt xmax, uInt y
, bool draw_trailing_ws ) const
{
// Erase a number of characters to draw simple whitespaces
const auto& vt = vterm;
const auto& ec = TCAP(fc::t_erase_chars);
const auto& ec = TCAP(t_erase_chars);
auto& print_char = vt->data[y * uInt(vt->width) + x];
if ( ! ec || print_char.ch[0] != ' ' )
return not_used;
return PrintState::NothingPrinted;
uInt whitespace{1};
const bool normal = FTerm::isNormal(print_char);
for (uInt i = x + 1; i <= xmax; i++)
{
@ -2505,6 +2504,7 @@ FVTerm::exit_state FVTerm::eraseCharacters ( uInt& x, uInt xmax, uInt y
{
const uInt start_pos = x;
const bool& ut = FTermcap::background_color_erase;
const bool normal = FTerm::isNormal(print_char);
if ( whitespace > erase_char_length + cursor_address_length
&& (ut || normal) )
@ -2515,7 +2515,7 @@ FVTerm::exit_state FVTerm::eraseCharacters ( uInt& x, uInt xmax, uInt y
if ( x + whitespace - 1 < xmax || draw_trailing_ws )
setTermXY (int(x + whitespace), int(y));
else
return line_completely_printed;
return PrintState::LineCompletelyPrinted;
x = x + whitespace - 1;
}
@ -2533,20 +2533,20 @@ FVTerm::exit_state FVTerm::eraseCharacters ( uInt& x, uInt xmax, uInt y
markAsPrinted (start_pos, x, y);
}
return used;
return PrintState::WhitespacesPrinted;
}
//----------------------------------------------------------------------
FVTerm::exit_state FVTerm::repeatCharacter (uInt& x, uInt xmax, uInt y) const
FVTerm::PrintState FVTerm::repeatCharacter (uInt& x, uInt xmax, uInt y) const
{
// Repeat one character n-fold
const auto& vt = vterm;
const auto& rp = TCAP(fc::t_repeat_char);
const auto& rp = TCAP(t_repeat_char);
auto& print_char = vt->data[y * uInt(vt->width) + x];
if ( ! rp )
return not_used;
return PrintState::NothingPrinted;
uInt repetitions{1};
@ -2593,7 +2593,7 @@ FVTerm::exit_state FVTerm::repeatCharacter (uInt& x, uInt xmax, uInt y) const
markAsPrinted (start_pos, x, y);
}
return used;
return PrintState::RepeatCharacterPrinted;
}
//----------------------------------------------------------------------
@ -2717,7 +2717,7 @@ void FVTerm::printPaddingCharacter (FTermArea* area, const FChar& term_char)
// Copy character to padding character
std::memcpy (&pc, &term_char, sizeof(pc));
if ( FTerm::getEncoding() == fc::UTF8 )
if ( FTerm::getEncoding() == Encoding::UTF8 )
{
pc.ch = {{ L'\0' }};
pc.attr.bit.fullwidth_padding = true;
@ -2749,7 +2749,7 @@ bool FVTerm::updateTerminalLine (uInt y) const
ret = true;
bool draw_leading_ws = false;
bool draw_trailing_ws = false;
const auto& ce = TCAP(fc::t_clr_eol);
const auto& ce = TCAP(t_clr_eol);
// Clear rest of line
bool is_eol_clean = canClearToEOL (xmin, y);
@ -2776,7 +2776,7 @@ bool FVTerm::updateTerminalLine (uInt y) const
{
if ( draw_leading_ws )
{
const auto& cb = TCAP(fc::t_clr_bol);
const auto& cb = TCAP(t_clr_bol);
auto& first_char = vt->data[y * uInt(vt->width)];
appendAttributes (first_char);
appendOutputBuffer (cb);
@ -2904,9 +2904,9 @@ inline void FVTerm::newFontChanges (FChar& next_char)
if ( ! FTerm::isNewFont() )
return;
if ( next_char.ch[0] == fc::LowerHalfBlock )
if ( next_char.ch[0] == UniChar::LowerHalfBlock )
{
next_char.ch[0] = fc::UpperHalfBlock;
next_char.ch[0] = wchar_t(UniChar::UpperHalfBlock);
next_char.attr.bit.reverse = true;
}
else if ( isReverseNewFontchar(next_char.ch[0]) )
@ -2919,7 +2919,7 @@ inline void FVTerm::charsetChanges (FChar& next_char)
const wchar_t& ch = next_char.ch[0];
next_char.encoded_char[0] = ch;
if ( FTerm::getEncoding() == fc::UTF8 )
if ( FTerm::getEncoding() == Encoding::UTF8 )
return;
const wchar_t ch_enc = FTerm::charEncode(ch);
@ -2929,15 +2929,15 @@ inline void FVTerm::charsetChanges (FChar& next_char)
if ( ch_enc == 0 )
{
next_char.encoded_char[0] = wchar_t(FTerm::charEncode(ch, fc::ASCII));
next_char.encoded_char[0] = wchar_t(FTerm::charEncode(ch, Encoding::ASCII));
return;
}
next_char.encoded_char[0] = ch_enc;
if ( FTerm::getEncoding() == fc::VT100 )
if ( FTerm::getEncoding() == Encoding::VT100 )
next_char.attr.bit.alt_charset = true;
else if ( FTerm::getEncoding() == fc::PC )
else if ( FTerm::getEncoding() == Encoding::PC )
{
next_char.attr.bit.pc_charset = true;
@ -2947,7 +2947,7 @@ inline void FVTerm::charsetChanges (FChar& next_char)
if ( FTerm::isXTerminal() && ch_enc < 0x20 ) // Character 0x00..0x1f
{
if ( FTerm::hasUTF8() )
next_char.encoded_char[0] = int(FTerm::charEncode(ch, fc::ASCII));
next_char.encoded_char[0] = int(FTerm::charEncode(ch, Encoding::ASCII));
else
{
next_char.encoded_char[0] += 0x5f;
@ -2995,8 +2995,8 @@ inline void FVTerm::appendAttributes (FChar& next_attr) const
//----------------------------------------------------------------------
void FVTerm::appendLowerRight (FChar& last_char) const
{
const auto& SA = TCAP(fc::t_enter_am_mode);
const auto& RA = TCAP(fc::t_exit_am_mode);
const auto& SA = TCAP(t_enter_am_mode);
const auto& RA = TCAP(t_exit_am_mode);
if ( ! FTermcap::automatic_right_margin )
{
@ -3010,11 +3010,11 @@ void FVTerm::appendLowerRight (FChar& last_char) const
}
else
{
const auto& IC = TCAP(fc::t_parm_ich);
const auto& im = TCAP(fc::t_enter_insert_mode);
const auto& ei = TCAP(fc::t_exit_insert_mode);
const auto& ip = TCAP(fc::t_insert_padding);
const auto& ic = TCAP(fc::t_insert_character);
const auto& IC = TCAP(t_parm_ich);
const auto& im = TCAP(t_enter_insert_mode);
const auto& ei = TCAP(t_exit_insert_mode);
const auto& ip = TCAP(t_insert_padding);
const auto& ic = TCAP(t_insert_character);
const int x = int(FTerm::getColumnNumber()) - 2;
const int y = int(FTerm::getLineNumber()) - 1;

View File

@ -225,25 +225,25 @@ FWidget* FWidget::getLastFocusableWidget (FObjectList list)
}
//----------------------------------------------------------------------
std::vector<bool>& FWidget::doubleFlatLine_ref (fc::sides side)
std::vector<bool>& FWidget::doubleFlatLine_ref (Side side)
{
assert ( side == fc::top
|| side == fc::right
|| side == fc::bottom
|| side == fc::left );
assert ( side == Side::Top
|| side == Side::Right
|| side == Side::Bottom
|| side == Side::Left );
switch ( side )
{
case fc::top:
case Side::Top:
return double_flatline_mask.top;
case fc::right:
case Side::Right:
return double_flatline_mask.right;
case fc::bottom:
case Side::Bottom:
return double_flatline_mask.bottom;
case fc::left:
case Side::Left:
return double_flatline_mask.left;
}
@ -548,7 +548,12 @@ void FWidget::setBottomPadding (int bottom, bool adjust)
if ( isRootWidget() )
{
auto r = internal::var::root_widget;
r->wclient_offset.setY2 (int(r->getHeight()) - 1 - r->padding.bottom);
auto root_height = int(r->getHeight());
auto root_pb = r->padding.bottom;
if ( root_height > 1 + root_pb )
r->wclient_offset.setY2 (root_height - 1 - root_pb);
adjustSizeGlobal();
}
else
@ -569,7 +574,12 @@ void FWidget::setRightPadding (int right, bool adjust)
if ( isRootWidget() )
{
auto r = internal::var::root_widget;
r->wclient_offset.setX2 (int(r->getWidth()) - 1 - r->padding.right);
auto root_width = int(r->getWidth());
auto root_pr = r->padding.right;
if ( root_width > 1 + root_pr )
r->wclient_offset.setX2 (root_width - 1 - root_pr);
adjustSizeGlobal();
}
else
@ -686,33 +696,33 @@ void FWidget::setPrintPos (const FPoint& pos)
}
//----------------------------------------------------------------------
void FWidget::setDoubleFlatLine (fc::sides side, bool bit)
void FWidget::setDoubleFlatLine (Side side, bool bit)
{
uLong length{};
assert ( side == fc::top
|| side == fc::right
|| side == fc::bottom
|| side == fc::left );
assert ( side == Side::Top
|| side == Side::Right
|| side == Side::Bottom
|| side == Side::Left );
switch ( side )
{
case fc::top:
case Side::Top:
length = double_flatline_mask.top.size();
double_flatline_mask.top.assign(length, bit);
break;
case fc::right:
case Side::Right:
length = double_flatline_mask.right.size();
double_flatline_mask.right.assign(length, bit);
break;
case fc::bottom:
case Side::Bottom:
length = double_flatline_mask.bottom.size();
double_flatline_mask.bottom.assign(length, bit);
break;
case fc::left:
case Side::Left:
length = double_flatline_mask.left.size();
double_flatline_mask.left.assign(length, bit);
break;
@ -720,12 +730,12 @@ void FWidget::setDoubleFlatLine (fc::sides side, bool bit)
}
//----------------------------------------------------------------------
void FWidget::setDoubleFlatLine (fc::sides side, int pos, bool bit)
void FWidget::setDoubleFlatLine (Side side, int pos, bool bit)
{
assert ( side == fc::top
|| side == fc::right
|| side == fc::bottom
|| side == fc::left );
assert ( side == Side::Top
|| side == Side::Right
|| side == Side::Bottom
|| side == Side::Left );
assert ( pos >= 1 );
@ -734,7 +744,7 @@ void FWidget::setDoubleFlatLine (fc::sides side, int pos, bool bit)
switch ( side )
{
case fc::top:
case Side::Top:
length = double_flatline_mask.top.size();
if ( index < length )
@ -742,7 +752,7 @@ void FWidget::setDoubleFlatLine (fc::sides side, int pos, bool bit)
break;
case fc::right:
case Side::Right:
length = double_flatline_mask.right.size();
if ( index < length )
@ -750,7 +760,7 @@ void FWidget::setDoubleFlatLine (fc::sides side, int pos, bool bit)
break;
case fc::bottom:
case Side::Bottom:
length = double_flatline_mask.bottom.size();
if ( index < length )
@ -758,7 +768,7 @@ void FWidget::setDoubleFlatLine (fc::sides side, int pos, bool bit)
break;
case fc::left:
case Side::Left:
length = double_flatline_mask.left.size();
if ( index < length )
@ -823,7 +833,7 @@ bool FWidget::close()
{
// Sends a close event and quits the application on acceptance
FCloseEvent ev(fc::Close_Event);
FCloseEvent ev(Event::Close);
FApplication::sendEvent(this, &ev);
if ( ev.isAccepted() )
@ -923,7 +933,7 @@ void FWidget::resize()
if ( isRootWidget() )
{
const FRect old_term_geometry {getTermGeometry()};
detectTermSize();
determineDesktopSize();
FRect term_geometry {getTermGeometry()};
term_geometry.move (-1, -1);
@ -985,7 +995,7 @@ void FWidget::show()
show_root_widget = nullptr;
}
FShowEvent show_ev (fc::Show_Event);
FShowEvent show_ev (Event::Show);
FApplication::sendEvent(this, &show_ev);
}
@ -1015,7 +1025,7 @@ void FWidget::hide()
FWidget::setFocusWidget(getParentWidget());
}
FHideEvent hide_ev (fc::Hide_Event);
FHideEvent hide_ev (Event::Hide);
FApplication::sendEvent(this, &hide_ev);
}
}
@ -1428,7 +1438,7 @@ bool FWidget::focusNextChild()
|| ! next->isShown()
|| next->isWindowWidget() );
bool accpt = changeFocus (next, parent, fc::FocusNextWidget);
bool accpt = changeFocus (next, parent, FocusTypes::NextWidget);
if ( ! accpt )
return false;
@ -1489,7 +1499,7 @@ bool FWidget::focusPrevChild()
|| ! prev->isShown()
|| prev->isWindowWidget() );
const bool accpt = changeFocus (prev, parent, fc::FocusPreviousWidget);
const bool accpt = changeFocus (prev, parent, FocusTypes::PreviousWidget);
if ( ! accpt )
return false;
@ -1504,84 +1514,83 @@ bool FWidget::focusPrevChild()
//----------------------------------------------------------------------
bool FWidget::event (FEvent* ev)
{
switch ( uInt(ev->getType()) )
if ( ev->getType() == Event::KeyPress )
{
case fc::KeyPress_Event:
KeyPressEvent (static_cast<FKeyEvent*>(ev));
break;
case fc::KeyUp_Event:
onKeyUp (static_cast<FKeyEvent*>(ev));
break;
case fc::KeyDown_Event:
KeyDownEvent (static_cast<FKeyEvent*>(ev));
break;
case fc::MouseDown_Event:
emitCallback("mouse-press");
onMouseDown (static_cast<FMouseEvent*>(ev));
break;
case fc::MouseUp_Event:
emitCallback("mouse-release");
onMouseUp (static_cast<FMouseEvent*>(ev));
break;
case fc::MouseDoubleClick_Event:
onMouseDoubleClick (static_cast<FMouseEvent*>(ev));
break;
case fc::MouseWheel_Event:
emitWheelCallback(static_cast<FWheelEvent*>(ev));
onWheel (static_cast<FWheelEvent*>(ev));
break;
case fc::MouseMove_Event:
emitCallback("mouse-move");
onMouseMove (static_cast<FMouseEvent*>(ev));
break;
case fc::FocusIn_Event:
emitCallback("focus-in");
onFocusIn (static_cast<FFocusEvent*>(ev));
break;
case fc::FocusOut_Event:
emitCallback("focus-out");
onFocusOut (static_cast<FFocusEvent*>(ev));
break;
case fc::ChildFocusIn_Event:
onChildFocusIn (static_cast<FFocusEvent*>(ev));
break;
case fc::ChildFocusOut_Event:
onChildFocusOut (static_cast<FFocusEvent*>(ev));
break;
case fc::Accelerator_Event:
onAccel (static_cast<FAccelEvent*>(ev));
break;
case fc::Resize_Event:
onResize (static_cast<FResizeEvent*>(ev));
break;
case fc::Show_Event:
onShow (static_cast<FShowEvent*>(ev));
break;
case fc::Hide_Event:
onHide (static_cast<FHideEvent*>(ev));
break;
case fc::Close_Event:
onClose (static_cast<FCloseEvent*>(ev));
break;
default:
return FObject::event(ev);
KeyPressEvent (static_cast<FKeyEvent*>(ev));
}
else if ( ev->getType() == Event::KeyUp )
{
onKeyUp (static_cast<FKeyEvent*>(ev));
}
else if ( ev->getType() == Event::KeyDown )
{
KeyDownEvent (static_cast<FKeyEvent*>(ev));
}
else if ( ev->getType() == Event::MouseDown )
{
emitCallback("mouse-press");
onMouseDown (static_cast<FMouseEvent*>(ev));
}
else if ( ev->getType() == Event::MouseUp )
{
emitCallback("mouse-release");
onMouseUp (static_cast<FMouseEvent*>(ev));
}
else if ( ev->getType() == Event::MouseDoubleClick )
{
onMouseDoubleClick (static_cast<FMouseEvent*>(ev));
}
else if ( ev->getType() == Event::MouseWheel )
{
emitWheelCallback(static_cast<FWheelEvent*>(ev));
onWheel (static_cast<FWheelEvent*>(ev));
}
else if ( ev->getType() == Event::MouseMove )
{
emitCallback("mouse-move");
onMouseMove (static_cast<FMouseEvent*>(ev));
}
else if ( ev->getType() == Event::FocusIn )
{
emitCallback("focus-in");
onFocusIn (static_cast<FFocusEvent*>(ev));
}
else if ( ev->getType() == Event::FocusOut )
{
emitCallback("focus-out");
onFocusOut (static_cast<FFocusEvent*>(ev));
}
else if ( ev->getType() == Event::ChildFocusIn )
{
onChildFocusIn (static_cast<FFocusEvent*>(ev));
}
else if ( ev->getType() == Event::ChildFocusOut )
{
onChildFocusOut (static_cast<FFocusEvent*>(ev));
}
else if ( ev->getType() == Event::Accelerator )
{
onAccel (static_cast<FAccelEvent*>(ev));
}
else if ( ev->getType() == Event::Resize )
{
onResize (static_cast<FResizeEvent*>(ev));
}
else if ( ev->getType() == Event::Show )
{
onShow (static_cast<FShowEvent*>(ev));
}
else if ( ev->getType() == Event::Hide )
{
onHide (static_cast<FHideEvent*>(ev));
}
else if ( ev->getType() == Event::Close )
{
onClose (static_cast<FCloseEvent*>(ev));
}
else
{
return FObject::event(ev);
}
return true;
@ -1889,11 +1898,11 @@ void FWidget::KeyDownEvent (FKeyEvent* kev)
//----------------------------------------------------------------------
void FWidget::emitWheelCallback (const FWheelEvent* ev) const
{
const int wheel = ev->getWheel();
const MouseWheel wheel = ev->getWheel();
if ( wheel == fc::WheelUp )
if ( wheel == MouseWheel::Up )
emitCallback("mouse-wheel-up");
else if ( wheel == fc::WheelDown )
else if ( wheel == MouseWheel::Down )
emitCallback("mouse-wheel-down");
}
@ -1924,13 +1933,13 @@ void FWidget::setWindowFocus (bool enable)
//----------------------------------------------------------------------
bool FWidget::changeFocus ( FWidget* follower, FWidget* parent
, fc::FocusTypes ft )
, FocusTypes ft )
{
FFocusEvent out (fc::FocusOut_Event);
FFocusEvent out (Event::FocusOut);
out.setFocusType(ft);
FApplication::sendEvent(this, &out);
FFocusEvent cfo (fc::ChildFocusOut_Event);
FFocusEvent cfo (Event::ChildFocusOut);
cfo.setFocusType(ft);
cfo.ignore();
FApplication::sendEvent(parent, &cfo);
@ -1944,10 +1953,10 @@ bool FWidget::changeFocus ( FWidget* follower, FWidget* parent
return false;
follower->setFocus();
FFocusEvent cfi (fc::ChildFocusIn_Event);
FFocusEvent cfi (Event::ChildFocusIn);
FApplication::sendEvent(parent, &cfi);
FFocusEvent in (fc::FocusIn_Event);
FFocusEvent in (Event::FocusIn);
in.setFocusType(ft);
FApplication::sendEvent(follower, &in);
@ -1974,8 +1983,8 @@ void FWidget::drawWindows() const
// redraw windows
FChar default_char{};
default_char.ch[0] = ' ';
default_char.fg_color = fc::Black;
default_char.bg_color = fc::Black;
default_char.fg_color = FColor::Black;
default_char.bg_color = FColor::Black;
default_char.attr.byte[0] = 0;
default_char.attr.byte[1] = 0;

View File

@ -33,9 +33,9 @@ namespace finalcut
//----------------------------------------------------------------------
bool isFocusNextKey (const FKey key)
{
if ( key == fc::Fkey_tab
|| key == fc::Fkey_right
|| key == fc::Fkey_down )
if ( key == FKey::Tab
|| key == FKey::Right
|| key == FKey::Down )
return true;
return false;
@ -44,9 +44,9 @@ bool isFocusNextKey (const FKey key)
//----------------------------------------------------------------------
bool isFocusPrevKey (const FKey key)
{
if ( key == fc::Fkey_btab
|| key == fc::Fkey_left
|| key == fc::Fkey_up )
if ( key == FKey::Back_tab
|| key == FKey::Left
|| key == FKey::Up )
return true;
return false;
@ -65,7 +65,7 @@ FKey getHotkey (const FString& text)
// e.g. "E&xit" returns 'x'
if ( text.isEmpty() )
return 0;
return FKey::None;
std::size_t i{0};
const std::size_t length = text.getLength();
@ -82,13 +82,13 @@ FKey getHotkey (const FString& text)
}
catch (const std::out_of_range&)
{
return 0;
return FKey::None;
}
i++;
}
return 0;
return FKey::None;
}
//----------------------------------------------------------------------
@ -126,14 +126,14 @@ void setHotkeyViaString (FWidget* w, const FString& text)
if ( hotkey > 0xff00 && hotkey < 0xff5f ) // full-width character
hotkey -= 0xfee0;
if ( hotkey )
if ( hotkey != FKey::None )
{
if ( std::isalpha(int(hotkey)) || std::isdigit(int(hotkey)) )
{
w->addAccelerator (FKey(std::tolower(int(hotkey))));
w->addAccelerator (FKey(std::toupper(int(hotkey))));
// Meta + hotkey
w->addAccelerator (fc::Fmkey_meta + FKey(std::tolower(int(hotkey))));
w->addAccelerator (FKey::Meta_offset + FKey(std::tolower(int(hotkey))));
}
else
w->addAccelerator (hotkey);
@ -148,8 +148,8 @@ void drawShadow (FWidget* w)
if ( FTerm::isMonochron() && ! w->flags.trans_shadow )
return;
if ( (FTerm::getEncoding() == fc::VT100 && ! w->flags.trans_shadow)
|| (FTerm::getEncoding() == fc::ASCII && ! w->flags.trans_shadow) )
if ( (FTerm::getEncoding() == Encoding::VT100 && ! w->flags.trans_shadow)
|| (FTerm::getEncoding() == Encoding::ASCII && ! w->flags.trans_shadow) )
{
clearShadow(w);
return;
@ -169,26 +169,26 @@ void drawTransparentShadow (FWidget* w)
const std::size_t width = w->getWidth();
const std::size_t height = w->getHeight();
const auto& wc = FWidget::getColorTheme();
w->print() << FStyle {fc::Transparent}
w->print() << FStyle {Style::Transparent}
<< FPoint {int(width) + 1, 1}
<< " "
<< FStyle {fc::Reset}
<< FStyle {Style::None}
<< FColorPair {wc->shadow_bg, wc->shadow_fg}
<< FStyle {fc::ColorOverlay};
<< FStyle {Style::ColorOverlay};
for (std::size_t y{1}; y < height; y++)
{
w->print() << FPoint{int(width) + 1, int(y) + 1} << " ";
}
w->print() << FStyle {fc::Reset} << FStyle {fc::Transparent}
w->print() << FStyle {Style::None} << FStyle {Style::Transparent}
<< FPoint {1, int(height) + 1}
<< " "
<< FStyle {fc::Reset}
<< FStyle {Style::None}
<< FColorPair {wc->shadow_bg, wc->shadow_fg}
<< FStyle {fc::ColorOverlay}
<< FStyle {Style::ColorOverlay}
<< FString {width, L' '}
<< FStyle {fc::Reset};
<< FStyle {Style::None};
if ( FTerm::isMonochron() )
w->setReverse(false);
@ -210,31 +210,31 @@ void drawBlockShadow (FWidget* w)
if ( w->isWindowWidget() )
{
w->print() << FColorPair {wc->shadow_fg, wc->shadow_bg}
<< FStyle {fc::InheritBackground}; // current background color will be ignored
<< FStyle {Style::InheritBackground}; // current background color will be ignored
}
else if ( auto p = w->getParentWidget() )
w->print() << FColorPair {wc->shadow_fg, p->getBackgroundColor()};
w->print (fc::LowerHalfBlock); // ▄
w->print (UniChar::LowerHalfBlock); // ▄
if ( w->isWindowWidget() )
w->print() << FStyle {fc::InheritBackground};
w->print() << FStyle {Style::InheritBackground};
for (std::size_t y{1}; y < height; y++)
{
w->print() << FPoint {int(width) + 1, int(y) + 1}
<< fc::FullBlock; // █
<< UniChar::FullBlock; // █
}
w->print() << FPoint {2, int(height) + 1};
if ( w->isWindowWidget() )
w->print() << FStyle {fc::InheritBackground};
w->print() << FStyle {Style::InheritBackground};
w->print() << FString{width, fc::UpperHalfBlock}; // ▀
w->print() << FString{width, UniChar::UpperHalfBlock}; // ▀
if ( w->isWindowWidget() )
w->print() << FStyle {fc::Reset};
w->print() << FStyle {Style::None};
}
//----------------------------------------------------------------------
@ -250,7 +250,7 @@ void clearShadow (FWidget* w)
if ( w->isWindowWidget() )
{
w->print() << FColorPair {wc->shadow_fg, wc->shadow_bg}
<< FStyle {fc::InheritBackground}; // current background color will be ignored
<< FStyle {Style::InheritBackground}; // current background color will be ignored
}
else if ( auto p = w->getParentWidget() )
w->print() << FColorPair {wc->shadow_fg, p->getBackgroundColor()};
@ -271,7 +271,7 @@ void clearShadow (FWidget* w)
}
if ( w->isWindowWidget() )
w->print() << FStyle {fc::Reset};
w->print() << FStyle {Style::None};
}
//----------------------------------------------------------------------
@ -295,19 +295,19 @@ void drawFlatBorder (FWidget* w)
if ( w->double_flatline_mask.left[uLong(y)] )
// left+right line (on left side)
w->print (fc::NF_rev_border_line_right_and_left);
w->print (UniChar::NF_rev_border_line_right_and_left);
else
// right line (on left side)
w->print (fc::NF_rev_border_line_right);
w->print (UniChar::NF_rev_border_line_right);
w->print() << FPoint {int(width) + 1, int(y) + 1};
if ( w->double_flatline_mask.right[y] )
// left+right line (on right side)
w->print (fc::NF_rev_border_line_right_and_left);
w->print (UniChar::NF_rev_border_line_right_and_left);
else
// left line (on right side)
w->print (fc::NF_border_line_left);
w->print (UniChar::NF_border_line_left);
}
w->print() << FPoint {1, 0};
@ -316,10 +316,10 @@ void drawFlatBorder (FWidget* w)
{
if ( w->double_flatline_mask.top[x] )
// top+bottom line (at top)
w->print (fc::NF_border_line_up_and_down);
w->print (UniChar::NF_border_line_up_and_down);
else
// bottom line (at top)
w->print (fc::NF_border_line_bottom);
w->print (UniChar::NF_border_line_bottom);
}
w->print() << FPoint {1, int(height) + 1};
@ -328,10 +328,10 @@ void drawFlatBorder (FWidget* w)
{
if ( w->double_flatline_mask.bottom[x] )
// top+bottom line (at bottom)
w->print (fc::NF_border_line_up_and_down);
w->print (UniChar::NF_border_line_up_and_down);
else
// top line (at bottom)
w->print (fc::NF_border_line_upper);
w->print (UniChar::NF_border_line_upper);
}
}
@ -356,7 +356,7 @@ void clearFlatBorder (FWidget* w)
w->print() << FPoint {0, int(y) + 1};
if ( w->double_flatline_mask.left[y] )
w->print (fc::NF_border_line_left);
w->print (UniChar::NF_border_line_left);
else
w->print (' ');
@ -364,7 +364,7 @@ void clearFlatBorder (FWidget* w)
w->print() << FPoint {int(width) + 1, int(y) + 1};
if ( w->double_flatline_mask.right[y] )
w->print (fc::NF_rev_border_line_right);
w->print (UniChar::NF_rev_border_line_right);
else
w->print (' ');
}
@ -375,7 +375,7 @@ void clearFlatBorder (FWidget* w)
for (std::size_t x{0}; x < width; x++)
{
if ( w->double_flatline_mask.top[x] )
w->print (fc::NF_border_line_upper);
w->print (UniChar::NF_border_line_upper);
else
w->print (' ');
}
@ -386,7 +386,7 @@ void clearFlatBorder (FWidget* w)
for (std::size_t x{0}; x < width; x++)
{
if ( w->double_flatline_mask.bottom[x] )
w->print (fc::NF_border_line_bottom);
w->print (UniChar::NF_border_line_bottom);
else
w->print (' ');
}
@ -447,22 +447,22 @@ inline void drawBox (FWidget* w, const FRect& r)
return;
w->print() << r.getUpperLeftPos()
<< fc::BoxDrawingsDownAndRight // ┌
<< FString{r.getWidth() - 2, fc::BoxDrawingsHorizontal} // ─
<< fc::BoxDrawingsDownAndLeft; // ┐
<< UniChar::BoxDrawingsDownAndRight // ┌
<< FString{r.getWidth() - 2, UniChar::BoxDrawingsHorizontal} // ─
<< UniChar::BoxDrawingsDownAndLeft; // ┐
for (auto y = r.getY1() + 1; y < r.getY2(); y++)
{
w->print() << FPoint{r.getX1(), y}
<< fc::BoxDrawingsVertical // │
<< UniChar::BoxDrawingsVertical // │
<< FPoint{r.getX2(), y}
<< fc::BoxDrawingsVertical; // │
<< UniChar::BoxDrawingsVertical; // │
}
w->print() << r.getLowerLeftPos()
<< fc::BoxDrawingsUpAndRight // └
<< FString{r.getWidth() - 2, fc::BoxDrawingsHorizontal} // ─
<< fc::BoxDrawingsUpAndLeft; // ┘
<< UniChar::BoxDrawingsUpAndRight // └
<< FString{r.getWidth() - 2, UniChar::BoxDrawingsHorizontal} // ─
<< UniChar::BoxDrawingsUpAndLeft; // ┘
}
//----------------------------------------------------------------------
@ -471,44 +471,44 @@ inline void drawNewFontBox (FWidget* w, const FRect& r)
// Use new graphical font characters to draw a border
w->print() << r.getUpperLeftPos()
<< fc::NF_border_corner_middle_upper_left // ┌
<< FString{r.getWidth() - 2, fc::NF_border_line_horizontal} // ─
<< fc::NF_border_corner_middle_upper_right; // ┐
<< UniChar::NF_border_corner_middle_upper_left // ┌
<< FString{r.getWidth() - 2, UniChar::NF_border_line_horizontal} // ─
<< UniChar::NF_border_corner_middle_upper_right; // ┐
for (auto y = r.getY1() + 1; y < r.getY2(); y++)
{
w->print() << FPoint{r.getX1(), y}
<< fc::NF_border_line_vertical // │
<< UniChar::NF_border_line_vertical // │
<< FPoint{r.getX2(), y}
<< fc::NF_border_line_vertical; // │
<< UniChar::NF_border_line_vertical; // │
}
w->print() << r.getLowerLeftPos()
<< fc::NF_border_corner_middle_lower_left // └
<< FString{r.getWidth() - 2, fc::NF_border_line_horizontal} // ─
<< fc::NF_border_corner_middle_lower_right; // ┘
<< UniChar::NF_border_corner_middle_lower_left // └
<< FString{r.getWidth() - 2, UniChar::NF_border_line_horizontal} // ─
<< UniChar::NF_border_corner_middle_lower_right; // ┘
}
//----------------------------------------------------------------------
inline void drawNewFontListBox (FWidget* w, const FRect& r)
{
w->print() << r.getUpperLeftPos()
<< fc::NF_border_line_middle_left_down // ┌
<< FString{r.getWidth() - 2, fc::NF_border_line_horizontal} // ─
<< fc::NF_border_line_left_down; // ╷
<< UniChar::NF_border_line_middle_left_down // ┌
<< FString{r.getWidth() - 2, UniChar::NF_border_line_horizontal} // ─
<< UniChar::NF_border_line_left_down; // ╷
for (auto y = r.getY1() + 1; y < r.getY2(); y++)
{
w->print() << FPoint{r.getX1(), y}
<< fc::NF_border_line_left // border left ⎸
<< UniChar::NF_border_line_left // border left ⎸
<< FPoint{r.getX2(), y}
<< fc::NF_border_line_left; // border left ⎸
<< UniChar::NF_border_line_left; // border left ⎸
}
w->print() << r.getLowerLeftPos()
<< fc::NF_border_line_middle_right_up // └
<< FString{r.getWidth() - 2, fc::NF_border_line_horizontal} // ─
<< fc::NF_border_line_left_up; // ╵
<< UniChar::NF_border_line_middle_right_up // └
<< FString{r.getWidth() - 2, UniChar::NF_border_line_horizontal} // ─
<< UniChar::NF_border_line_left_up; // ╵
}
} // namespace finalcut

View File

@ -55,92 +55,92 @@ default8ColorTheme::~default8ColorTheme() noexcept = default;
//----------------------------------------------------------------------
void default8ColorTheme::setColorTheme()
{
term_fg = fc::Black;
term_bg = fc::Blue;
list_fg = fc::Black;
list_bg = fc::LightGray;
selected_list_fg = fc::Blue;
selected_list_bg = fc::LightGray;
dialog_fg = fc::Black;
dialog_resize_fg = fc::Red;
dialog_emphasis_fg = fc::Blue;
dialog_bg = fc::LightGray;
error_box_fg = fc::Black;
error_box_emphasis_fg = fc::Red;
error_box_bg = fc::LightGray;
tooltip_fg = fc::Black;
tooltip_bg = fc::Cyan;
shadow_fg = fc::Black;
shadow_bg = fc::LightGray; // only for transparent shadow
current_element_focus_fg = fc::LightGray;
current_element_focus_bg = fc::Red;
current_element_fg = fc::LightGray;
current_element_bg = fc::Blue;
current_inc_search_element_fg = fc::Brown;
selected_current_element_focus_fg = fc::Blue;
selected_current_element_focus_bg = fc::Red;
selected_current_element_fg = fc::Cyan;
selected_current_element_bg = fc::Blue;
label_fg = fc::Black;
label_bg = fc::LightGray;
label_inactive_fg = fc::Cyan;
label_inactive_bg = fc::LightGray;
label_hotkey_fg = fc::Red;
label_hotkey_bg = fc::LightGray;
label_emphasis_fg = fc::Blue;
label_ellipsis_fg = fc::Black;
inputfield_active_focus_fg = fc::LightGray;
inputfield_active_focus_bg = fc::Blue;
inputfield_active_fg = fc::Black;
inputfield_active_bg = fc::Cyan;
inputfield_inactive_fg = fc::Black;
inputfield_inactive_bg = fc::LightGray;
toggle_button_active_focus_fg = fc::Black;
toggle_button_active_focus_bg = fc::Cyan;
toggle_button_active_fg = fc::Black;
toggle_button_active_bg = fc::LightGray;
toggle_button_inactive_fg = fc::Cyan;
toggle_button_inactive_bg = fc::LightGray;
button_active_focus_fg = fc::LightGray;
button_active_focus_bg = fc::Red;
button_active_fg = fc::LightGray;
button_active_bg = fc::Blue;
button_inactive_fg = fc::Black;
button_inactive_bg = fc::Blue;
button_hotkey_fg = fc::LightGray;
titlebar_active_fg = fc::LightGray;
titlebar_active_bg = fc::Red;
titlebar_inactive_fg = fc::Black;
titlebar_inactive_bg = fc::LightGray;
titlebar_button_fg = fc::Black;
titlebar_button_bg = fc::LightGray;
titlebar_button_focus_fg = fc::LightGray;
titlebar_button_focus_bg = fc::Black;
menu_active_focus_fg = fc::LightGray;
menu_active_focus_bg = fc::Blue;
menu_active_fg = fc::Black;
menu_active_bg = fc::LightGray;
menu_inactive_fg = fc::Cyan;
menu_inactive_bg = fc::LightGray;
menu_hotkey_fg = fc::Red;
menu_hotkey_bg = fc::LightGray;
statusbar_fg = fc::Black;
statusbar_bg = fc::LightGray;
statusbar_hotkey_fg = fc::Red;
statusbar_hotkey_bg = fc::LightGray;
statusbar_separator_fg = fc::Black;
statusbar_active_fg = fc::LightGray;
statusbar_active_bg = fc::Black;
statusbar_active_hotkey_fg = fc::Red;
statusbar_active_hotkey_bg = fc::Black;
scrollbar_fg = fc::Black;
scrollbar_bg = fc::LightGray;
scrollbar_button_fg = fc::Black;
scrollbar_button_bg = fc::LightGray;
scrollbar_button_inactive_fg = fc::Cyan;
scrollbar_button_inactive_bg = fc::LightGray;
progressbar_fg = fc::Blue;
progressbar_bg = fc::LightGray;
term_fg = FColor::Black;
term_bg = FColor::Blue;
list_fg = FColor::Black;
list_bg = FColor::LightGray;
selected_list_fg = FColor::Blue;
selected_list_bg = FColor::LightGray;
dialog_fg = FColor::Black;
dialog_resize_fg = FColor::Red;
dialog_emphasis_fg = FColor::Blue;
dialog_bg = FColor::LightGray;
error_box_fg = FColor::Black;
error_box_emphasis_fg = FColor::Red;
error_box_bg = FColor::LightGray;
tooltip_fg = FColor::Black;
tooltip_bg = FColor::Cyan;
shadow_fg = FColor::Black;
shadow_bg = FColor::LightGray; // only for transparent shadow
current_element_focus_fg = FColor::LightGray;
current_element_focus_bg = FColor::Red;
current_element_fg = FColor::LightGray;
current_element_bg = FColor::Blue;
current_inc_search_element_fg = FColor::Brown;
selected_current_element_focus_fg = FColor::Blue;
selected_current_element_focus_bg = FColor::Red;
selected_current_element_fg = FColor::Cyan;
selected_current_element_bg = FColor::Blue;
label_fg = FColor::Black;
label_bg = FColor::LightGray;
label_inactive_fg = FColor::Cyan;
label_inactive_bg = FColor::LightGray;
label_hotkey_fg = FColor::Red;
label_hotkey_bg = FColor::LightGray;
label_emphasis_fg = FColor::Blue;
label_ellipsis_fg = FColor::Black;
inputfield_active_focus_fg = FColor::LightGray;
inputfield_active_focus_bg = FColor::Blue;
inputfield_active_fg = FColor::Black;
inputfield_active_bg = FColor::Cyan;
inputfield_inactive_fg = FColor::Black;
inputfield_inactive_bg = FColor::LightGray;
toggle_button_active_focus_fg = FColor::Black;
toggle_button_active_focus_bg = FColor::Cyan;
toggle_button_active_fg = FColor::Black;
toggle_button_active_bg = FColor::LightGray;
toggle_button_inactive_fg = FColor::Cyan;
toggle_button_inactive_bg = FColor::LightGray;
button_active_focus_fg = FColor::LightGray;
button_active_focus_bg = FColor::Red;
button_active_fg = FColor::LightGray;
button_active_bg = FColor::Blue;
button_inactive_fg = FColor::Black;
button_inactive_bg = FColor::Blue;
button_hotkey_fg = FColor::LightGray;
titlebar_active_fg = FColor::LightGray;
titlebar_active_bg = FColor::Red;
titlebar_inactive_fg = FColor::Black;
titlebar_inactive_bg = FColor::LightGray;
titlebar_button_fg = FColor::Black;
titlebar_button_bg = FColor::LightGray;
titlebar_button_focus_fg = FColor::LightGray;
titlebar_button_focus_bg = FColor::Black;
menu_active_focus_fg = FColor::LightGray;
menu_active_focus_bg = FColor::Blue;
menu_active_fg = FColor::Black;
menu_active_bg = FColor::LightGray;
menu_inactive_fg = FColor::Cyan;
menu_inactive_bg = FColor::LightGray;
menu_hotkey_fg = FColor::Red;
menu_hotkey_bg = FColor::LightGray;
statusbar_fg = FColor::Black;
statusbar_bg = FColor::LightGray;
statusbar_hotkey_fg = FColor::Red;
statusbar_hotkey_bg = FColor::LightGray;
statusbar_separator_fg = FColor::Black;
statusbar_active_fg = FColor::LightGray;
statusbar_active_bg = FColor::Black;
statusbar_active_hotkey_fg = FColor::Red;
statusbar_active_hotkey_bg = FColor::Black;
scrollbar_fg = FColor::Black;
scrollbar_bg = FColor::LightGray;
scrollbar_button_fg = FColor::Black;
scrollbar_button_bg = FColor::LightGray;
scrollbar_button_inactive_fg = FColor::Cyan;
scrollbar_button_inactive_bg = FColor::LightGray;
progressbar_fg = FColor::Blue;
progressbar_bg = FColor::LightGray;
}
@ -163,95 +163,95 @@ default16ColorTheme::~default16ColorTheme() noexcept = default;
//----------------------------------------------------------------------
void default16ColorTheme::setColorTheme()
{
term_fg = fc::Black;
term_bg = fc::LightBlue;
list_fg = fc::Black;
list_bg = fc::White;
selected_list_fg = fc::Cyan;
selected_list_bg = fc::White;
dialog_fg = fc::Black;
dialog_resize_fg = fc::Cyan;
dialog_emphasis_fg = fc::Blue;
dialog_bg = fc::White;
error_box_fg = fc::White;
error_box_emphasis_fg = fc::Yellow;
error_box_bg = fc::LightRed;
tooltip_fg = fc::Black;
tooltip_bg = fc::Yellow;
shadow_fg = fc::Black;
shadow_bg = fc::LightGray; // only for transparent shadow
current_element_focus_fg = fc::White;
current_element_focus_bg = fc::Blue;
current_element_fg = fc::LightGray;
current_element_bg = fc::Blue;
current_inc_search_element_fg = fc::LightRed;
selected_current_element_focus_fg = fc::LightCyan;
selected_current_element_focus_bg = fc::Blue;
selected_current_element_fg = fc::LightBlue;
selected_current_element_bg = fc::Blue;
label_fg = fc::Black;
label_bg = fc::White;
label_inactive_fg = fc::LightGray;
label_inactive_bg = fc::White;
label_hotkey_fg = fc::Red;
label_hotkey_bg = fc::White;
label_emphasis_fg = fc::Blue;
label_ellipsis_fg = fc::DarkGray;
inputfield_active_focus_fg = fc::White;
inputfield_active_focus_bg = fc::Cyan;
inputfield_active_fg = fc::Black;
inputfield_active_bg = fc::LightGray;
inputfield_inactive_fg = fc::DarkGray;
inputfield_inactive_bg = fc::LightGray;
toggle_button_active_focus_fg = fc::White;
toggle_button_active_focus_bg = fc::Cyan;
toggle_button_active_fg = fc::Black;
toggle_button_active_bg = fc::White;
toggle_button_inactive_fg = fc::LightGray;
toggle_button_inactive_bg = fc::White;
button_active_focus_fg = fc::LightGray;
button_active_focus_bg = fc::Blue;
button_active_fg = fc::LightGray;
button_active_bg = fc::DarkGray;
button_inactive_fg = fc::DarkGray;
button_inactive_bg = fc::LightGray;
button_hotkey_fg = fc::White;
titlebar_active_fg = fc::White;
titlebar_active_bg = fc::Blue;
titlebar_inactive_fg = fc::LightGray;
titlebar_inactive_bg = fc::DarkGray;
titlebar_button_fg = fc::DarkGray;
titlebar_button_bg = fc::LightGray;
titlebar_button_focus_fg = fc::LightGray;
titlebar_button_focus_bg = fc::Black;
menu_active_focus_fg = fc::White;
menu_active_focus_bg = fc::Blue;
menu_active_fg = fc::Black;
menu_active_bg = fc::White;
menu_inactive_fg = fc::LightGray;
menu_inactive_bg = fc::White;
menu_hotkey_fg = fc::Red;
menu_hotkey_bg = fc::White;
statusbar_fg = fc::White;
statusbar_bg = fc::Blue;
statusbar_hotkey_fg = fc::LightRed;
statusbar_hotkey_bg = fc::Blue;
statusbar_separator_fg = fc::Black;
statusbar_active_fg = fc::Blue;
statusbar_active_bg = fc::White;
statusbar_active_hotkey_fg = fc::DarkGray;
statusbar_active_hotkey_bg = fc::White;
scrollbar_fg = fc::DarkGray;
scrollbar_bg = fc::LightBlue;
scrollbar_button_fg = fc::Black;
scrollbar_button_bg = fc::LightGray;
scrollbar_button_inactive_fg = fc::DarkGray;
scrollbar_button_inactive_bg = fc::LightGray;
progressbar_fg = fc::DarkGray;
progressbar_bg = fc::LightBlue;
term_fg = FColor::Black;
term_bg = FColor::LightBlue;
list_fg = FColor::Black;
list_bg = FColor::White;
selected_list_fg = FColor::Cyan;
selected_list_bg = FColor::White;
dialog_fg = FColor::Black;
dialog_resize_fg = FColor::Cyan;
dialog_emphasis_fg = FColor::Blue;
dialog_bg = FColor::White;
error_box_fg = FColor::White;
error_box_emphasis_fg = FColor::Yellow;
error_box_bg = FColor::LightRed;
tooltip_fg = FColor::Black;
tooltip_bg = FColor::Yellow;
shadow_fg = FColor::Black;
shadow_bg = FColor::LightGray; // only for transparent shadow
current_element_focus_fg = FColor::White;
current_element_focus_bg = FColor::Blue;
current_element_fg = FColor::LightGray;
current_element_bg = FColor::Blue;
current_inc_search_element_fg = FColor::LightRed;
selected_current_element_focus_fg = FColor::LightCyan;
selected_current_element_focus_bg = FColor::Blue;
selected_current_element_fg = FColor::LightBlue;
selected_current_element_bg = FColor::Blue;
label_fg = FColor::Black;
label_bg = FColor::White;
label_inactive_fg = FColor::LightGray;
label_inactive_bg = FColor::White;
label_hotkey_fg = FColor::Red;
label_hotkey_bg = FColor::White;
label_emphasis_fg = FColor::Blue;
label_ellipsis_fg = FColor::DarkGray;
inputfield_active_focus_fg = FColor::White;
inputfield_active_focus_bg = FColor::Cyan;
inputfield_active_fg = FColor::Black;
inputfield_active_bg = FColor::LightGray;
inputfield_inactive_fg = FColor::DarkGray;
inputfield_inactive_bg = FColor::LightGray;
toggle_button_active_focus_fg = FColor::White;
toggle_button_active_focus_bg = FColor::Cyan;
toggle_button_active_fg = FColor::Black;
toggle_button_active_bg = FColor::White;
toggle_button_inactive_fg = FColor::LightGray;
toggle_button_inactive_bg = FColor::White;
button_active_focus_fg = FColor::LightGray;
button_active_focus_bg = FColor::Blue;
button_active_fg = FColor::LightGray;
button_active_bg = FColor::DarkGray;
button_inactive_fg = FColor::DarkGray;
button_inactive_bg = FColor::LightGray;
button_hotkey_fg = FColor::White;
titlebar_active_fg = FColor::White;
titlebar_active_bg = FColor::Blue;
titlebar_inactive_fg = FColor::LightGray;
titlebar_inactive_bg = FColor::DarkGray;
titlebar_button_fg = FColor::DarkGray;
titlebar_button_bg = FColor::LightGray;
titlebar_button_focus_fg = FColor::LightGray;
titlebar_button_focus_bg = FColor::Black;
menu_active_focus_fg = FColor::White;
menu_active_focus_bg = FColor::Blue;
menu_active_fg = FColor::Black;
menu_active_bg = FColor::White;
menu_inactive_fg = FColor::LightGray;
menu_inactive_bg = FColor::White;
menu_hotkey_fg = FColor::Red;
menu_hotkey_bg = FColor::White;
statusbar_fg = FColor::White;
statusbar_bg = FColor::Blue;
statusbar_hotkey_fg = FColor::LightRed;
statusbar_hotkey_bg = FColor::Blue;
statusbar_separator_fg = FColor::Black;
statusbar_active_fg = FColor::Blue;
statusbar_active_bg = FColor::White;
statusbar_active_hotkey_fg = FColor::DarkGray;
statusbar_active_hotkey_bg = FColor::White;
scrollbar_fg = FColor::DarkGray;
scrollbar_bg = FColor::LightBlue;
scrollbar_button_fg = FColor::Black;
scrollbar_button_bg = FColor::LightGray;
scrollbar_button_inactive_fg = FColor::DarkGray;
scrollbar_button_inactive_bg = FColor::LightGray;
progressbar_fg = FColor::DarkGray;
progressbar_bg = FColor::LightBlue;
if ( ! FTerm::canChangeColorPalette() && FTerm::getMaxColor() > 16 )
term_bg = fc::SkyBlue2;
term_bg = FColor::SkyBlue2;
}
//----------------------------------------------------------------------
@ -273,92 +273,92 @@ default8ColorDarkTheme::~default8ColorDarkTheme() noexcept = default;
//----------------------------------------------------------------------
void default8ColorDarkTheme::setColorTheme()
{
term_fg = fc::LightGray;
term_bg = fc::Cyan;
list_fg = fc::Black;
list_bg = fc::LightGray;
selected_list_fg = fc::Cyan;
selected_list_bg = fc::LightGray;
dialog_fg = fc::Black;
dialog_resize_fg = fc::Blue;
dialog_emphasis_fg = fc::Blue;
dialog_bg = fc::LightGray;
error_box_fg = fc::LightGray;
error_box_emphasis_fg = fc::Black;
error_box_bg = fc::Red;
tooltip_fg = fc::LightGray;
tooltip_bg = fc::Black;
shadow_fg = fc::Black;
shadow_bg = fc::LightGray; // only for transparent shadow
current_element_focus_fg = fc::LightGray;
current_element_focus_bg = fc::Cyan;
current_element_fg = fc::Black;
current_element_bg = fc::Cyan;
current_inc_search_element_fg = fc::Red;
selected_current_element_focus_fg = fc::Cyan;
selected_current_element_focus_bg = fc::Cyan;
selected_current_element_fg = fc::Blue;
selected_current_element_bg = fc::Cyan;
label_fg = fc::Black;
label_bg = fc::LightGray;
label_inactive_fg = fc::Cyan;
label_inactive_bg = fc::LightGray;
label_hotkey_fg = fc::Red;
label_hotkey_bg = fc::LightGray;
label_emphasis_fg = fc::Blue;
label_ellipsis_fg = fc::Cyan;
inputfield_active_focus_fg = fc::LightGray;
inputfield_active_focus_bg = fc::Cyan;
inputfield_active_fg = fc::LightGray;
inputfield_active_bg = fc::Cyan;
inputfield_inactive_fg = fc::Cyan;
inputfield_inactive_bg = fc::LightGray;
toggle_button_active_focus_fg = fc::LightGray;
toggle_button_active_focus_bg = fc::Cyan;
toggle_button_active_fg = fc::Black;
toggle_button_active_bg = fc::LightGray;
toggle_button_inactive_fg = fc::Cyan;
toggle_button_inactive_bg = fc::LightGray;
button_active_focus_fg = fc::LightGray;
button_active_focus_bg = fc::Cyan;
button_active_fg = fc::LightGray;
button_active_bg = fc::Black;
button_inactive_fg = fc::Black;
button_inactive_bg = fc::Cyan;
button_hotkey_fg = fc::LightGray;
titlebar_active_fg = fc::LightGray;
titlebar_active_bg = fc::Black;
titlebar_inactive_fg = fc::Black;
titlebar_inactive_bg = fc::LightGray;
titlebar_button_fg = fc::Black;
titlebar_button_bg = fc::LightGray;
titlebar_button_focus_fg = fc::LightGray;
titlebar_button_focus_bg = fc::Black;
menu_active_focus_fg = fc::LightGray;
menu_active_focus_bg = fc::Blue;
menu_active_fg = fc::LightGray;
menu_active_bg = fc::Black;
menu_inactive_fg = fc::LightGray;
menu_inactive_bg = fc::Black;
menu_hotkey_fg = fc::Red;
menu_hotkey_bg = fc::Black;
statusbar_fg = fc::LightGray;
statusbar_bg = fc::Black;
statusbar_hotkey_fg = fc::Red;
statusbar_hotkey_bg = fc::Black;
statusbar_separator_fg = fc::LightGray;
statusbar_active_fg = fc::LightGray;
statusbar_active_bg = fc::Blue;
statusbar_active_hotkey_fg = fc::Red;
statusbar_active_hotkey_bg = fc::Blue;
scrollbar_fg = fc::Cyan;
scrollbar_bg = fc::LightGray;
scrollbar_button_fg = fc::Black;
scrollbar_button_bg = fc::LightGray;
scrollbar_button_inactive_fg = fc::Cyan;
scrollbar_button_inactive_bg = fc::LightGray;
progressbar_fg = fc::Cyan;
progressbar_bg = fc::LightGray;
term_fg = FColor::LightGray;
term_bg = FColor::Cyan;
list_fg = FColor::Black;
list_bg = FColor::LightGray;
selected_list_fg = FColor::Cyan;
selected_list_bg = FColor::LightGray;
dialog_fg = FColor::Black;
dialog_resize_fg = FColor::Blue;
dialog_emphasis_fg = FColor::Blue;
dialog_bg = FColor::LightGray;
error_box_fg = FColor::LightGray;
error_box_emphasis_fg = FColor::Black;
error_box_bg = FColor::Red;
tooltip_fg = FColor::LightGray;
tooltip_bg = FColor::Black;
shadow_fg = FColor::Black;
shadow_bg = FColor::LightGray; // only for transparent shadow
current_element_focus_fg = FColor::LightGray;
current_element_focus_bg = FColor::Cyan;
current_element_fg = FColor::Black;
current_element_bg = FColor::Cyan;
current_inc_search_element_fg = FColor::Red;
selected_current_element_focus_fg = FColor::Cyan;
selected_current_element_focus_bg = FColor::Cyan;
selected_current_element_fg = FColor::Blue;
selected_current_element_bg = FColor::Cyan;
label_fg = FColor::Black;
label_bg = FColor::LightGray;
label_inactive_fg = FColor::Cyan;
label_inactive_bg = FColor::LightGray;
label_hotkey_fg = FColor::Red;
label_hotkey_bg = FColor::LightGray;
label_emphasis_fg = FColor::Blue;
label_ellipsis_fg = FColor::Cyan;
inputfield_active_focus_fg = FColor::LightGray;
inputfield_active_focus_bg = FColor::Cyan;
inputfield_active_fg = FColor::LightGray;
inputfield_active_bg = FColor::Cyan;
inputfield_inactive_fg = FColor::Cyan;
inputfield_inactive_bg = FColor::LightGray;
toggle_button_active_focus_fg = FColor::LightGray;
toggle_button_active_focus_bg = FColor::Cyan;
toggle_button_active_fg = FColor::Black;
toggle_button_active_bg = FColor::LightGray;
toggle_button_inactive_fg = FColor::Cyan;
toggle_button_inactive_bg = FColor::LightGray;
button_active_focus_fg = FColor::LightGray;
button_active_focus_bg = FColor::Cyan;
button_active_fg = FColor::LightGray;
button_active_bg = FColor::Black;
button_inactive_fg = FColor::Black;
button_inactive_bg = FColor::Cyan;
button_hotkey_fg = FColor::LightGray;
titlebar_active_fg = FColor::LightGray;
titlebar_active_bg = FColor::Black;
titlebar_inactive_fg = FColor::Black;
titlebar_inactive_bg = FColor::LightGray;
titlebar_button_fg = FColor::Black;
titlebar_button_bg = FColor::LightGray;
titlebar_button_focus_fg = FColor::LightGray;
titlebar_button_focus_bg = FColor::Black;
menu_active_focus_fg = FColor::LightGray;
menu_active_focus_bg = FColor::Blue;
menu_active_fg = FColor::LightGray;
menu_active_bg = FColor::Black;
menu_inactive_fg = FColor::LightGray;
menu_inactive_bg = FColor::Black;
menu_hotkey_fg = FColor::Red;
menu_hotkey_bg = FColor::Black;
statusbar_fg = FColor::LightGray;
statusbar_bg = FColor::Black;
statusbar_hotkey_fg = FColor::Red;
statusbar_hotkey_bg = FColor::Black;
statusbar_separator_fg = FColor::LightGray;
statusbar_active_fg = FColor::LightGray;
statusbar_active_bg = FColor::Blue;
statusbar_active_hotkey_fg = FColor::Red;
statusbar_active_hotkey_bg = FColor::Blue;
scrollbar_fg = FColor::Cyan;
scrollbar_bg = FColor::LightGray;
scrollbar_button_fg = FColor::Black;
scrollbar_button_bg = FColor::LightGray;
scrollbar_button_inactive_fg = FColor::Cyan;
scrollbar_button_inactive_bg = FColor::LightGray;
progressbar_fg = FColor::Cyan;
progressbar_bg = FColor::LightGray;
}
@ -381,92 +381,92 @@ default16ColorDarkTheme::~default16ColorDarkTheme() noexcept = default;
//----------------------------------------------------------------------
void default16ColorDarkTheme::setColorTheme()
{
term_fg = fc::White;
term_bg = fc::Cyan;
list_fg = fc::Black;
list_bg = fc::LightGray;
selected_list_fg = fc::Red;
selected_list_bg = fc::LightGray;
dialog_fg = fc::Black;
dialog_resize_fg = fc::LightBlue;
dialog_emphasis_fg = fc::Blue;
dialog_bg = fc::LightGray;
error_box_fg = fc::White;
error_box_emphasis_fg = fc::Yellow;
error_box_bg = fc::Red;
tooltip_fg = fc::White;
tooltip_bg = fc::Black;
shadow_fg = fc::Black;
shadow_bg = fc::LightGray; // only for transparent shadow
current_element_focus_fg = fc::White;
current_element_focus_bg = fc::Cyan;
current_element_fg = fc::LightBlue;
current_element_bg = fc::Cyan;
current_inc_search_element_fg = fc::LightRed;
selected_current_element_focus_fg = fc::LightRed;
selected_current_element_focus_bg = fc::Cyan;
selected_current_element_fg = fc::Red;
selected_current_element_bg = fc::Cyan;
label_fg = fc::Black;
label_bg = fc::LightGray;
label_inactive_fg = fc::DarkGray;
label_inactive_bg = fc::LightGray;
label_hotkey_fg = fc::Red;
label_hotkey_bg = fc::LightGray;
label_emphasis_fg = fc::Blue;
label_ellipsis_fg = fc::DarkGray;
inputfield_active_focus_fg = fc::White;
inputfield_active_focus_bg = fc::Cyan;
inputfield_active_fg = fc::White;
inputfield_active_bg = fc::DarkGray;
inputfield_inactive_fg = fc::DarkGray;
inputfield_inactive_bg = fc::LightGray;
toggle_button_active_focus_fg = fc::White;
toggle_button_active_focus_bg = fc::Cyan;
toggle_button_active_fg = fc::Black;
toggle_button_active_bg = fc::LightGray;
toggle_button_inactive_fg = fc::DarkGray;
toggle_button_inactive_bg = fc::LightGray;
button_active_focus_fg = fc::LightGray;
button_active_focus_bg = fc::Cyan;
button_active_fg = fc::LightGray;
button_active_bg = fc::DarkGray;
button_inactive_fg = fc::DarkGray;
button_inactive_bg = fc::LightBlue;
button_hotkey_fg = fc::White;
titlebar_active_fg = fc::White;
titlebar_active_bg = fc::DarkGray;
titlebar_inactive_fg = fc::DarkGray;
titlebar_inactive_bg = fc::LightBlue;
titlebar_button_fg = fc::DarkGray;
titlebar_button_bg = fc::LightBlue;
titlebar_button_focus_fg = fc::LightGray;
titlebar_button_focus_bg = fc::Black;
menu_active_focus_fg = fc::White;
menu_active_focus_bg = fc::Blue;
menu_active_fg = fc::White;
menu_active_bg = fc::DarkGray;
menu_inactive_fg = fc::LightGray;
menu_inactive_bg = fc::DarkGray;
menu_hotkey_fg = fc::LightRed;
menu_hotkey_bg = fc::DarkGray;
statusbar_fg = fc::White;
statusbar_bg = fc::DarkGray;
statusbar_hotkey_fg = fc::LightRed;
statusbar_hotkey_bg = fc::DarkGray;
statusbar_separator_fg = fc::LightGray;
statusbar_active_fg = fc::White;
statusbar_active_bg = fc::Blue;
statusbar_active_hotkey_fg = fc::LightRed;
statusbar_active_hotkey_bg = fc::Blue;
scrollbar_fg = fc::DarkGray;
scrollbar_bg = fc::LightBlue;
scrollbar_button_fg = fc::Black;
scrollbar_button_bg = fc::LightBlue;
scrollbar_button_inactive_fg = fc::DarkGray;
scrollbar_button_inactive_bg = fc::LightGray;
progressbar_fg = fc::DarkGray;
progressbar_bg = fc::LightBlue;
term_fg = FColor::White;
term_bg = FColor::Cyan;
list_fg = FColor::Black;
list_bg = FColor::LightGray;
selected_list_fg = FColor::Red;
selected_list_bg = FColor::LightGray;
dialog_fg = FColor::Black;
dialog_resize_fg = FColor::LightBlue;
dialog_emphasis_fg = FColor::Blue;
dialog_bg = FColor::LightGray;
error_box_fg = FColor::White;
error_box_emphasis_fg = FColor::Yellow;
error_box_bg = FColor::Red;
tooltip_fg = FColor::White;
tooltip_bg = FColor::Black;
shadow_fg = FColor::Black;
shadow_bg = FColor::LightGray; // only for transparent shadow
current_element_focus_fg = FColor::White;
current_element_focus_bg = FColor::Cyan;
current_element_fg = FColor::LightBlue;
current_element_bg = FColor::Cyan;
current_inc_search_element_fg = FColor::LightRed;
selected_current_element_focus_fg = FColor::LightRed;
selected_current_element_focus_bg = FColor::Cyan;
selected_current_element_fg = FColor::Red;
selected_current_element_bg = FColor::Cyan;
label_fg = FColor::Black;
label_bg = FColor::LightGray;
label_inactive_fg = FColor::DarkGray;
label_inactive_bg = FColor::LightGray;
label_hotkey_fg = FColor::Red;
label_hotkey_bg = FColor::LightGray;
label_emphasis_fg = FColor::Blue;
label_ellipsis_fg = FColor::DarkGray;
inputfield_active_focus_fg = FColor::White;
inputfield_active_focus_bg = FColor::Cyan;
inputfield_active_fg = FColor::White;
inputfield_active_bg = FColor::DarkGray;
inputfield_inactive_fg = FColor::DarkGray;
inputfield_inactive_bg = FColor::LightGray;
toggle_button_active_focus_fg = FColor::White;
toggle_button_active_focus_bg = FColor::Cyan;
toggle_button_active_fg = FColor::Black;
toggle_button_active_bg = FColor::LightGray;
toggle_button_inactive_fg = FColor::DarkGray;
toggle_button_inactive_bg = FColor::LightGray;
button_active_focus_fg = FColor::LightGray;
button_active_focus_bg = FColor::Cyan;
button_active_fg = FColor::LightGray;
button_active_bg = FColor::DarkGray;
button_inactive_fg = FColor::DarkGray;
button_inactive_bg = FColor::LightBlue;
button_hotkey_fg = FColor::White;
titlebar_active_fg = FColor::White;
titlebar_active_bg = FColor::DarkGray;
titlebar_inactive_fg = FColor::DarkGray;
titlebar_inactive_bg = FColor::LightBlue;
titlebar_button_fg = FColor::DarkGray;
titlebar_button_bg = FColor::LightBlue;
titlebar_button_focus_fg = FColor::LightGray;
titlebar_button_focus_bg = FColor::Black;
menu_active_focus_fg = FColor::White;
menu_active_focus_bg = FColor::Blue;
menu_active_fg = FColor::White;
menu_active_bg = FColor::DarkGray;
menu_inactive_fg = FColor::LightGray;
menu_inactive_bg = FColor::DarkGray;
menu_hotkey_fg = FColor::LightRed;
menu_hotkey_bg = FColor::DarkGray;
statusbar_fg = FColor::White;
statusbar_bg = FColor::DarkGray;
statusbar_hotkey_fg = FColor::LightRed;
statusbar_hotkey_bg = FColor::DarkGray;
statusbar_separator_fg = FColor::LightGray;
statusbar_active_fg = FColor::White;
statusbar_active_bg = FColor::Blue;
statusbar_active_hotkey_fg = FColor::LightRed;
statusbar_active_hotkey_bg = FColor::Blue;
scrollbar_fg = FColor::DarkGray;
scrollbar_bg = FColor::LightBlue;
scrollbar_button_fg = FColor::Black;
scrollbar_button_bg = FColor::LightBlue;
scrollbar_button_inactive_fg = FColor::DarkGray;
scrollbar_button_inactive_bg = FColor::LightGray;
progressbar_fg = FColor::DarkGray;
progressbar_bg = FColor::LightBlue;
}
} // namespace finalcut

View File

@ -117,7 +117,7 @@ void FWindow::setActiveWindow (FWindow* window)
if ( ! window->isWindowActive() )
{
window->activateWindow();
FEvent ev(fc::WindowActive_Event);
FEvent ev(Event::WindowActive);
FApplication::sendEvent(window, &ev);
}
}
@ -128,7 +128,7 @@ void FWindow::setActiveWindow (FWindow* window)
if ( w->isWindowActive() )
{
w->deactivateWindow();
FEvent ev(fc::WindowInactive_Event);
FEvent ev(Event::WindowInactive);
FApplication::sendEvent(win, &ev);
}
}
@ -243,22 +243,22 @@ void FWindow::drawBorder()
{
const FRect r{FPoint{1, 1}, getSize()};
print() << r.getUpperLeftPos()
<< fc::NF_border_corner_upper_left // ⎡
<< FString{r.getWidth() - 2, fc::NF_border_line_upper} // ¯
<< fc::NF_rev_border_corner_upper_right; // ⎤
<< UniChar::NF_border_corner_upper_left // ⎡
<< FString{r.getWidth() - 2, UniChar::NF_border_line_upper} // ¯
<< UniChar::NF_rev_border_corner_upper_right; // ⎤
for (auto y = r.getY1() + 1; y < r.getY2(); y++)
{
print() << FPoint{r.getX1(), y}
<< fc::NF_border_line_left // border left ⎸
<< UniChar::NF_border_line_left // border left ⎸
<< FPoint{r.getX2(), y}
<< fc::NF_rev_border_line_right; // border right⎹
<< UniChar::NF_rev_border_line_right; // border right⎹
}
print() << r.getLowerLeftPos()
<< fc::NF_border_corner_lower_left // ⎣
<< FString{r.getWidth() - 2, fc::NF_border_line_bottom} // _
<< fc::NF_rev_border_corner_lower_right; // ⎦
<< UniChar::NF_border_corner_lower_left // ⎣
<< FString{r.getWidth() - 2, UniChar::NF_border_line_bottom} // _
<< UniChar::NF_rev_border_corner_lower_right; // ⎦
}
else
{
@ -597,7 +597,7 @@ bool FWindow::raiseWindow (FWidget* obj)
{
getWindowList()->erase (iter);
getWindowList()->push_back (obj);
FEvent ev(fc::WindowRaised_Event);
FEvent ev(Event::WindowRaised);
FApplication::sendEvent(obj, &ev);
processAlwaysOnTop();
return true;
@ -637,7 +637,7 @@ bool FWindow::lowerWindow (FWidget* obj)
{
getWindowList()->erase (iter);
getWindowList()->insert (getWindowList()->begin(), obj);
FEvent ev(fc::WindowLowered_Event);
FEvent ev(Event::WindowLowered);
FApplication::sendEvent(obj, &ev);
return true;
}
@ -792,27 +792,24 @@ void FWindow::adjustSize()
//----------------------------------------------------------------------
bool FWindow::event (FEvent* ev)
{
switch ( uInt(ev->getType()) )
if ( ev->getType() == Event::WindowActive )
{
case fc::WindowActive_Event:
onWindowActive (ev);
break;
case fc::WindowInactive_Event:
onWindowInactive (ev);
break;
case fc::WindowRaised_Event:
onWindowRaised (ev);
break;
case fc::WindowLowered_Event:
onWindowLowered (ev);
break;
default:
return FWidget::event(ev);
onWindowActive (ev);
}
else if ( ev->getType() == Event::WindowInactive )
{
onWindowInactive (ev);
}
else if ( ev->getType() == Event::WindowRaised )
{
onWindowRaised (ev);
}
else if ( ev->getType() == Event::WindowLowered )
{
onWindowLowered (ev);
}
else
return FWidget::event(ev);
return true;
}

View File

@ -205,19 +205,19 @@ class FApplication : public FWidget
void sendMouseMoveEvent ( const FMouseData&
, const FPoint&
, const FPoint&
, int ) const;
, MouseButton ) const;
void sendMouseLeftClickEvent ( const FMouseData&
, const FPoint&
, const FPoint&
, int ) const;
, MouseButton ) const;
void sendMouseRightClickEvent ( const FMouseData&
, const FPoint&
, const FPoint&
, int ) const;
, MouseButton ) const;
void sendMouseMiddleClickEvent ( const FMouseData&
, const FPoint&
, const FPoint&
, int ) const;
, MouseButton ) const;
void sendWheelEvent ( const FMouseData&
, const FPoint&
, const FPoint& ) const;

View File

@ -157,14 +157,14 @@ class FButton : public FWidget
bool active_focus{false};
bool click_animation{true};
int click_time{150};
int space_char{int(' ')};
FColor button_fg{fc::Default};
FColor button_bg{fc::Default};
FColor button_hotkey_fg{fc::Default};
FColor button_focus_fg{fc::Default};
FColor button_focus_bg{fc::Default};
FColor button_inactive_fg{fc::Default};
FColor button_inactive_bg{fc::Default};
wchar_t space_char{L' '};
FColor button_fg{FColor::Default};
FColor button_bg{FColor::Default};
FColor button_hotkey_fg{FColor::Default};
FColor button_focus_fg{FColor::Default};
FColor button_focus_bg{FColor::Default};
FColor button_inactive_fg{FColor::Default};
FColor button_inactive_bg{FColor::Default};
std::size_t hotkeypos{NOT_SET};
std::size_t indent{0};
std::size_t center_offset{0};

File diff suppressed because it is too large Load Diff

View File

@ -38,8 +38,31 @@ namespace finalcut
namespace fc
{
extern std::array<std::array<uInt, fc::NUM_OF_ENCODINGS>, 115> character;
extern const std::array<std::array<int, 2>, 39> dec_special_graphics;
// Unicode fallback table for VT100, PC, and ASCII
struct CharEncodeMap
{
wchar_t unicode;
wchar_t vt100;
wchar_t pc;
wchar_t ascii;
};
extern std::array<CharEncodeMap, 115> character;
inline wchar_t& getCharacter (CharEncodeMap& char_enc, const Encoding& enc)
{
const auto array = reinterpret_cast<wchar_t*>(&char_enc);
return array[std::size_t(enc)];
}
// vt100 <-> utf-8
struct DECSpecialGraphics
{
VT100Key key;
UniChar unicode;
};
extern const std::array<DECSpecialGraphics, 39> dec_special_graphics;
extern const std::array<std::array<wchar_t, 2>, 256> cp437_ucs;
extern const std::array<std::array<wchar_t, 2>, 227> halfwidth_fullwidth;

View File

@ -50,7 +50,7 @@ class FColorPair
{
public:
// Constructors
explicit FColorPair (FColor fg = fc::Default, FColor bg = fc::Default)
explicit FColorPair (FColor fg = FColor::Default, FColor bg = FColor::Default)
: fg_color{fg}
, bg_color{bg}
{ }
@ -62,7 +62,7 @@ class FColorPair
~FColorPair() = default;
// copy assignment operator (=)
FColorPair& operator = (const FColorPair& pair) = default;
FColorPair& operator = (const FColorPair&) = default;
// Accessor
FString getClassName() const

View File

@ -164,6 +164,9 @@ class FDialog : public FWindow
bool mouse_over_menu;
};
// Using-declaration
using KeyMap = std::unordered_map<FKey, std::function<void()>>;
// Constant
static constexpr std::size_t MENU_BTN = 3;
static constexpr bool PRINT_WIN_NUMBER = false; // Only for debug
@ -174,6 +177,7 @@ class FDialog : public FWindow
void initMoveSizeMenuItem (FMenu*);
void initZoomMenuItem (FMenu*);
void initCloseMenuItem (FMenu*);
void mapKeyFunctions();
void drawBorder() override;
void drawTitleBar();
void drawBarButton();
@ -231,6 +235,7 @@ class FDialog : public FWindow
FMenuItem* zoom_item{nullptr};
FMenuItem* close_item{nullptr};
FToolTip* tooltip{nullptr};
KeyMap key_map{};
// Friend function from FMenu
friend void FMenu::hideSuperMenus() const;

View File

@ -102,14 +102,14 @@ class FEvent // event base class
{
public:
FEvent() = default;
explicit FEvent(fc::events);
fc::events getType() const;
explicit FEvent(Event);
Event getType() const;
bool isQueued() const;
bool wasSent() const;
private:
// Data members
fc::events t{fc::None_Event};
Event t{Event::None};
bool queued{false};
bool send{false};
@ -126,7 +126,7 @@ class FKeyEvent : public FEvent // keyboard event
{
public:
FKeyEvent() = default;
FKeyEvent (fc::events, FKey);
FKeyEvent (Event, FKey);
~FKeyEvent() = default;
FKey key() const;
@ -135,7 +135,7 @@ class FKeyEvent : public FEvent // keyboard event
void ignore();
private:
FKey k{0};
FKey k{FKey::None};
bool accpt{false};
};
@ -148,8 +148,8 @@ class FMouseEvent : public FEvent // mouse event
{
public:
FMouseEvent() = default;
FMouseEvent (fc::events, const FPoint&, const FPoint&, int);
FMouseEvent (fc::events, const FPoint&, int);
FMouseEvent (Event, const FPoint&, const FPoint&, MouseButton);
FMouseEvent (Event, const FPoint&, MouseButton);
~FMouseEvent() = default;
const FPoint& getPos() const;
@ -158,12 +158,12 @@ class FMouseEvent : public FEvent // mouse event
int getY() const;
int getTermX() const;
int getTermY() const;
int getButton() const;
MouseButton getButton() const;
private:
FPoint p{};
FPoint tp{};
int b{};
FPoint p{};
FPoint tp{};
MouseButton b{};
};
@ -175,8 +175,8 @@ class FWheelEvent : public FEvent // wheel event
{
public:
FWheelEvent() = default;
FWheelEvent (fc::events, const FPoint&, int);
FWheelEvent (fc::events, const FPoint&, const FPoint&, int);
FWheelEvent (Event, const FPoint&, MouseWheel);
FWheelEvent (Event, const FPoint&, const FPoint&, MouseWheel);
~FWheelEvent() = default;
const FPoint& getPos() const;
@ -185,12 +185,12 @@ class FWheelEvent : public FEvent // wheel event
int getY() const;
int getTermX() const;
int getTermY() const;
int getWheel() const;
MouseWheel getWheel() const;
private:
FPoint p{};
FPoint tp{};
int w{};
FPoint p{};
FPoint tp{};
MouseWheel w{MouseWheel::None};
};
@ -202,20 +202,20 @@ class FFocusEvent : public FEvent // focus event
{
public:
FFocusEvent() = default;
explicit FFocusEvent (fc::events);
explicit FFocusEvent (Event);
~FFocusEvent() = default;
bool gotFocus() const;
bool lostFocus() const;
fc::FocusTypes getFocusType() const;
void setFocusType(fc::FocusTypes);
FocusTypes getFocusType() const;
void setFocusType (FocusTypes);
bool isAccepted() const;
void accept();
void ignore();
private:
bool accpt{true};
fc::FocusTypes focus_type{fc::FocusDefiniteWidget};
FocusTypes focus_type{FocusTypes::DefiniteWidget};
};
@ -228,7 +228,7 @@ class FAccelEvent : public FEvent // focus event
{
public:
FAccelEvent() = default;
FAccelEvent (fc::events, FWidget*);
FAccelEvent (Event, FWidget*);
FAccelEvent (const FAccelEvent&) = delete;
~FAccelEvent() = default;
FAccelEvent& operator = (const FAccelEvent&) = delete;
@ -252,7 +252,7 @@ class FResizeEvent : public FEvent // resize event
{
public:
FResizeEvent() = default;
explicit FResizeEvent (fc::events);
explicit FResizeEvent (Event);
~FResizeEvent() = default;
bool isAccepted() const;
@ -272,7 +272,7 @@ class FShowEvent : public FEvent // show event
{
public:
FShowEvent() = default;
explicit FShowEvent (fc::events);
explicit FShowEvent (Event);
~FShowEvent() = default;
};
@ -285,7 +285,7 @@ class FHideEvent : public FEvent // hide event
{
public:
FHideEvent() = default;
explicit FHideEvent (fc::events);
explicit FHideEvent (Event);
~FHideEvent() = default;
};
@ -298,7 +298,7 @@ class FCloseEvent : public FEvent // close event
{
public:
FCloseEvent() = default;
explicit FCloseEvent(fc::events);
explicit FCloseEvent(Event);
~FCloseEvent() = default;
bool isAccepted() const;
@ -318,7 +318,7 @@ class FTimerEvent : public FEvent // timer event
{
public:
FTimerEvent() = default;
FTimerEvent (fc::events, int);
FTimerEvent (Event, int);
~FTimerEvent() = default;
int getTimerId() const;
@ -339,7 +339,7 @@ class FUserEvent : public FEvent // user event
// Disable copy constructor
FUserEvent (const FUserEvent&) = delete;
FUserEvent (fc::events, int);
FUserEvent (Event, int);
~FUserEvent() = default;

View File

@ -34,11 +34,34 @@
namespace finalcut
{
enum class FKey : uInt32; // forward declaration
namespace fc
{
extern std::array<FKeyMap, 188> fkey;
extern const std::array<FMetakeyMap, 232> fmetakey;
struct FKeyCapMap
{
FKey num;
const char* string;
char tname[4];
};
extern std::array<FKeyCapMap, 188> fkey_cap_table;
struct FKeyMap
{
FKey num;
char string[8];
};
extern const std::array<FKeyMap, 232> fkey_table;
struct FKeyName
{
FKey num;
char string[26];
};
extern const std::array<FKeyName, 388> fkeyname;
} // namespace fc

View File

@ -115,6 +115,7 @@ class FKeyboard final
// Mutators
template <typename T>
void setTermcapMap (const T&);
void setTermcapMap();
static void setKeypressTimeout (const uInt64);
static void setReadBlockingTime (const uInt64);
static void setNonBlockingInputSupport (bool);
@ -145,7 +146,7 @@ class FKeyboard final
private:
// Using-declaration
using FKeyMapPtr = std::shared_ptr<decltype(fc::fkey)>;
using FKeyMapPtr = std::shared_ptr<decltype(fc::fkey_cap_table)>;
// Constants
static constexpr FKey NOT_SET = static_cast<FKey>(-1);
@ -154,7 +155,7 @@ class FKeyboard final
// Accessors
FKey getMouseProtocolKey() const;
FKey getTermcapKey();
FKey getMetaKey();
FKey getKnownKey();
FKey getSingleKey();
// Inquiry
@ -186,8 +187,8 @@ class FKeyboard final
static bool non_blocking_input_support;
FKeyMapPtr key_map{};
std::queue<FKey> fkey_queue{};
FKey fkey{0};
FKey key{0};
FKey fkey{FKey::None};
FKey key{FKey::None};
char read_character{};
char fifo_buf[FIFO_BUF_SIZE]{'\0'};
int fifo_offset{0};
@ -230,6 +231,13 @@ template <typename T>
inline void FKeyboard::setTermcapMap (const T& keymap)
{ key_map = std::make_shared<T>(keymap); }
//----------------------------------------------------------------------
inline void FKeyboard::setTermcapMap ()
{
using type = decltype(fc::fkey_cap_table);
key_map = std::make_shared<type>(fc::fkey_cap_table);
}
//----------------------------------------------------------------------
inline void FKeyboard::setKeypressTimeout (const uInt64 timeout)
{ key_timeout = timeout; }

View File

@ -82,19 +82,19 @@ class FLabel : public FWidget
FLabel& operator = (const FString&);
template <typename typeT>
FLabel& operator << (const typeT&);
FLabel& operator << (fc::SpecialCharacter);
FLabel& operator << (UniChar);
FLabel& operator << (const wchar_t);
const FLabel& operator >> (FString&) const;
// Accessors
FString getClassName() const override;
FWidget* getAccelWidget();
fc::text_alignment getAlignment() const;
Align getAlignment() const;
FString& getText();
// Mutators
void setAccelWidget (FWidget* = nullptr);
void setAlignment (fc::text_alignment);
void setAlignment (Align);
bool setEmphasis (bool);
bool setEmphasis();
bool unsetEmphasis();
@ -142,12 +142,12 @@ class FLabel : public FWidget
FStringList multiline_text{};
FString text{};
FWidget* accel_widget{nullptr};
fc::text_alignment alignment{fc::alignLeft};
Align alignment{Align::Left};
std::size_t align_offset{0};
std::size_t hotkeypos{NOT_SET};
std::size_t column_width{0};
FColor emphasis_color{fc::Default};
FColor ellipsis_color{fc::Default};
FColor emphasis_color{FColor::Default};
FColor ellipsis_color{FColor::Default};
bool multiline{false};
bool emphasis{false};
bool reverse_mode{false};
@ -173,7 +173,7 @@ inline FWidget* FLabel::getAccelWidget ()
{ return accel_widget; }
//----------------------------------------------------------------------
inline fc::text_alignment FLabel::getAlignment() const
inline Align FLabel::getAlignment() const
{ return alignment; }
//----------------------------------------------------------------------

View File

@ -71,14 +71,14 @@ class FLineEdit : public FWidget
// Enumerations
enum class LabelOrientation
{
above = 0,
left = 1
Above = 0,
Left = 1
};
enum class InputType
{
textfield = 0,
password = 1
Textfield = 0,
Password = 1
};
// Constructor
@ -98,7 +98,7 @@ class FLineEdit : public FWidget
FLineEdit& operator = (const FString&);
template <typename typeT>
FLineEdit& operator << (const typeT&);
FLineEdit& operator << (fc::SpecialCharacter);
FLineEdit& operator << (UniChar);
FLineEdit& operator << (const wchar_t);
const FLineEdit& operator >> (FString&) const;
@ -165,20 +165,14 @@ class FLineEdit : public FWidget
private:
// Using-declaration
using offsetPair = std::pair<std::size_t, std::size_t>;
// Enumeration
enum dragScroll
{
noScroll = 0,
scrollLeft = 1,
scrollRight = 2
};
using KeyMap = std::unordered_map<FKey, std::function<void()>>;
// Constants
static constexpr auto NOT_SET = static_cast<std::size_t>(-1);
// Methods
void init();
void mapKeyFunctions();
bool hasHotkey() const;
void draw() override;
void drawInputField();
@ -210,9 +204,10 @@ class FLineEdit : public FWidget
FLabel* label{};
FWidget* label_associated_widget{this};
std::wstring input_filter{};
dragScroll drag_scroll{FLineEdit::noScroll};
LabelOrientation label_orientation{LabelOrientation::left};
InputType input_type{InputType::textfield};
KeyMap key_map{};
DragScrollMode drag_scroll{DragScrollMode::None};
LabelOrientation label_orientation{LabelOrientation::Left};
InputType input_type{InputType::Textfield};
int scroll_repeat{100};
bool scroll_timer{false};
bool insert_mode{true};

View File

@ -108,7 +108,7 @@ class FListBoxItem
// Data members
FString text{};
FDataAccessPtr data_pointer{};
fc::brackets_type brackets{fc::NoBrackets};
BracketType brackets{BracketType::None};
bool selected{false};
// Friend classes
@ -208,7 +208,7 @@ class FListBox : public FWidget
void selectItem (FListBoxItems::iterator) const;
void unselectItem (std::size_t);
void unselectItem (FListBoxItems::iterator) const;
void showInsideBrackets (const std::size_t, fc::brackets_type);
void showInsideBrackets (const std::size_t, BracketType);
void showNoBrackets (std::size_t);
void showNoBrackets (FListBoxItems::iterator) const;
void setSize (const FSize&, bool = true) override;
@ -244,13 +244,13 @@ class FListBox : public FWidget
template <typename T
, typename DT = std::nullptr_t>
void insert ( const std::initializer_list<T>& list
, fc::brackets_type = fc::NoBrackets
, BracketType = BracketType::None
, bool = false
, DT&& = DT() );
template <typename ItemT
, typename DT = std::nullptr_t>
void insert ( const ItemT&
, fc::brackets_type = fc::NoBrackets
, BracketType = BracketType::None
, bool = false
, DT&& = DT() );
void remove (std::size_t);
@ -275,16 +275,16 @@ class FListBox : public FWidget
private:
// Using-declaration
using KeyMap = std::unordered_map<int, std::function<void()>>;
using KeyMapResult = std::unordered_map<int, std::function<bool()>>;
using KeyMap = std::unordered_map<FKey, std::function<void()>>;
using KeyMapResult = std::unordered_map<FKey, std::function<bool()>>;
using LazyInsert = std::function<void(FListBoxItem&, FDataAccess*, std::size_t)>;
// Enumeration
enum convert_type
enum class ConvertType
{
no_convert = 0,
direct_convert = 1,
lazy_convert = 2
None = 0,
Direct = 1,
Lazy = 2
};
// Accessors
@ -304,8 +304,8 @@ class FListBox : public FWidget
void drawHeadline();
void drawList();
void drawListLine (int, FListBoxItems::iterator, bool);
void printLeftBracket (fc::brackets_type);
void printRightBracket (fc::brackets_type);
void printLeftBracket (BracketType);
void printRightBracket (BracketType);
void drawListBracketsLine (int, FListBoxItems::iterator, bool);
void setLineAttributes (int, bool, bool, bool&);
void unsetAttributes() const;
@ -319,8 +319,8 @@ class FListBox : public FWidget
void wheelDown (int);
bool dragScrollUp();
bool dragScrollDown();
void dragUp (int);
void dragDown (int);
void dragUp (MouseButton);
void dragDown (MouseButton);
void stopDragScroll();
void prevListItem (int);
void nextListItem (int);
@ -365,8 +365,8 @@ class FListBox : public FWidget
FString inc_search{};
KeyMap key_map{};
KeyMapResult key_map_result{};
convert_type conv_type{FListBox::no_convert};
fc::dragScroll drag_scroll{fc::noScroll};
ConvertType conv_type{ConvertType::None};
DragScrollMode drag_scroll{DragScrollMode::None};
int scroll_repeat{100};
int scroll_distance{1};
int last_current{-1};
@ -410,7 +410,7 @@ inline FListBox::FListBox ( Iterator first
while ( first != last )
{
insert(convert(first), fc::NoBrackets, false, &(*first));
insert(convert(first), BracketType::None, false, &(*first));
++first;
}
}
@ -491,11 +491,11 @@ inline void FListBox::unselectItem (FListBoxItems::iterator iter) const
//----------------------------------------------------------------------
inline void FListBox::showNoBrackets (std::size_t index)
{ index2iterator(index - 1)->brackets = fc::NoBrackets; }
{ index2iterator(index - 1)->brackets = BracketType::None; }
//----------------------------------------------------------------------
inline void FListBox::showNoBrackets (FListBoxItems::iterator iter) const
{ iter->brackets = fc::NoBrackets; }
{ iter->brackets = BracketType::None; }
//----------------------------------------------------------------------
inline void FListBox::setMultiSelection (bool enable)
@ -527,11 +527,11 @@ inline bool FListBox::isMultiSelection() const
//----------------------------------------------------------------------
inline bool FListBox::hasBrackets(std::size_t index) const
{ return bool(index2iterator(index - 1)->brackets > 0); }
{ return bool(index2iterator(index - 1)->brackets != BracketType::None); }
//----------------------------------------------------------------------
inline bool FListBox::hasBrackets(FListBoxItems::iterator iter) const
{ return bool(iter->brackets > 0); }
{ return bool(iter->brackets != BracketType::None); }
//----------------------------------------------------------------------
inline void FListBox::reserve (std::size_t new_cap)
@ -544,11 +544,11 @@ inline void FListBox::insert ( Iterator first
, Iterator last
, const InsertConverter& convert )
{
conv_type = direct_convert;
conv_type = ConvertType::Direct;
while ( first != last )
{
insert (convert(first), fc::NoBrackets, false, &(*first));
insert (convert(first), BracketType::None, false, &(*first));
++first;
}
}
@ -558,7 +558,7 @@ template <typename Container
, typename LazyConverter>
void FListBox::insert (const Container& container, const LazyConverter& converter)
{
conv_type = lazy_convert;
conv_type = ConvertType::Lazy;
source_container = makeFData(container);
lazy_inserter = converter;
const std::size_t size = container.size();
@ -581,7 +581,7 @@ void FListBox::insert (Container* container, const LazyConverter& converter)
template <typename T
, typename DT>
void FListBox::insert ( const std::initializer_list<T>& list
, fc::brackets_type b
, BracketType b
, bool s
, DT&& d )
{
@ -598,7 +598,7 @@ void FListBox::insert ( const std::initializer_list<T>& list
template <typename ItemT
, typename DT>
void FListBox::insert ( const ItemT& item
, fc::brackets_type b
, BracketType b
, bool s
, DT&& d )
{

View File

@ -315,10 +315,10 @@ class FListView : public FWidget
// Accessors
FString getClassName() const override;
std::size_t getCount() const;
fc::text_alignment getColumnAlignment (int) const;
Align getColumnAlignment (int) const;
FString getColumnText (int) const;
fc::sorting_type getColumnSortType (int) const;
fc::sorting_order getSortOrder() const;
SortType getColumnSortType (int) const;
SortOrder getSortOrder() const;
int getSortColumn() const;
FListViewItem* getCurrentItem();
@ -326,12 +326,10 @@ class FListView : public FWidget
void setSize (const FSize&, bool = true) override;
void setGeometry ( const FPoint&, const FSize&
, bool = true ) override;
void setColumnAlignment (int, fc::text_alignment);
void setColumnAlignment (int, Align);
void setColumnText (int, const FString&);
void setColumnSortType (int, fc::sorting_type \
= fc::by_name);
void setColumnSort (int, fc::sorting_order \
= fc::ascending);
void setColumnSortType (int, SortType = SortType::Name);
void setColumnSort (int, SortOrder = SortOrder::Ascending);
template <typename Compare>
void setUserAscendingCompare (Compare);
template <typename Compare>
@ -407,10 +405,10 @@ class FListView : public FWidget
struct Header; // forward declaration
// Using-declaration
using KeyMap = std::unordered_map<int, std::function<void()>>;
using KeyMapResult = std::unordered_map<int, std::function<bool()>>;
using KeyMap = std::unordered_map<FKey, std::function<void()>>;
using KeyMapResult = std::unordered_map<FKey, std::function<bool()>>;
using HeaderItems = std::vector<Header>;
using SortTypes = std::vector<fc::sorting_type>;
using SortTypes = std::vector<SortType>;
// Constants
static constexpr std::size_t checkbox_space = 4;
@ -434,7 +432,7 @@ class FListView : public FWidget
void processKeyAction (FKeyEvent*);
template <typename Compare>
void sort (Compare);
std::size_t getAlignOffset ( const fc::text_alignment
std::size_t getAlignOffset ( const Align
, const std::size_t
, const std::size_t ) const;
iterator getListEnd (const FListViewItem*);
@ -465,8 +463,8 @@ class FListView : public FWidget
void wheelDown (int);
bool dragScrollUp (int);
bool dragScrollDown (int);
void dragUp (int);
void dragDown (int);
void dragUp (MouseButton);
void dragDown (MouseButton);
void stopDragScroll();
iterator appendItem (FListViewItem*);
void processClick() const;
@ -514,13 +512,13 @@ class FListView : public FWidget
const FListViewItem* clicked_checkbox_item{nullptr};
std::size_t nf_offset{0};
std::size_t max_line_width{1};
fc::dragScroll drag_scroll{fc::noScroll};
DragScrollMode drag_scroll{DragScrollMode::None};
int first_line_position_before{-1};
int scroll_repeat{100};
int scroll_distance{1};
int xoffset{0};
int sort_column{-1};
fc::sorting_order sort_order{fc::unsorted};
SortOrder sort_order{SortOrder::Unsorted};
bool scroll_timer{false};
bool tree_view{false};
bool hide_sort_indicator{false};
@ -545,7 +543,7 @@ struct FListView::Header
Header () = default;
FString name{};
fc::text_alignment alignment{fc::alignLeft};
Align alignment{Align::Left};
int width{0};
bool fixed_width{false};
};
@ -557,7 +555,7 @@ inline FString FListView::getClassName() const
{ return "FListView"; }
//----------------------------------------------------------------------
inline fc::sorting_order FListView::getSortOrder() const
inline SortOrder FListView::getSortOrder() const
{ return sort_order; }
//----------------------------------------------------------------------

View File

@ -162,7 +162,7 @@ class FMenuItem : public FWidget
void processDeactivate() const;
void createDialogList (FMenu*) const;
template <typename T>
void passMouseEvent (T, const FMouseEvent*, fc::events) const;
void passMouseEvent (T, const FMouseEvent*, Event) const;
// Callback methods
void cb_switchToDialog (FDialog*) const;
@ -177,8 +177,8 @@ class FMenuItem : public FWidget
FDialog* associated_window{nullptr};
std::size_t text_length{0};
std::size_t text_width{0};
FKey accel_key{0};
FKey hotkey{0};
FKey accel_key{FKey::None};
FKey hotkey{FKey::None};
bool selected{false};
bool separator{false};
bool checkable{false};
@ -291,7 +291,7 @@ inline bool FMenuItem::isRadioButton() const
//----------------------------------------------------------------------
inline bool FMenuItem::hasHotkey() const
{ return bool(hotkey != 0); }
{ return bool(hotkey != FKey::None); }
//----------------------------------------------------------------------
inline bool FMenuItem::hasMenu() const

View File

@ -99,6 +99,9 @@ class FMouseData
// Destructor
virtual ~FMouseData() noexcept;
// copy assignment operator (=)
FMouseData& operator = (const FMouseData&) = default;
// Accessors
virtual FString getClassName() const;
const FPoint& getPos() const;
@ -132,7 +135,7 @@ class FMouseData
};
struct FMouseButton
{
{
State left_button{};
State right_button{};
State middle_button{};
@ -168,11 +171,11 @@ class FMouse : public FMouseData
// Enumeration
enum class MouseType
{
none = 0,
gpm = 1,
x11 = 2,
sgr = 3,
urxvt = 4
None = 0,
Gpm = 1,
X11 = 2,
Sgr = 3,
Urxvt = 4
};
// Constructor
@ -270,15 +273,15 @@ class FMouseGPM final : public FMouse
private:
// Enumeration
enum gpmEventType
enum class gpmEventType
{
no_event = 0,
keyboard_event = 1,
mouse_event = 2
None = 0,
Keyboard = 1,
Mouse = 2
};
// Method
int gpmEvent (bool = true) const;
gpmEventType gpmEvent (bool = true) const;
// Data member
Gpm_Event gpm_ev{};

View File

@ -74,21 +74,21 @@ class FScrollbar : public FWidget
using FWidget::setGeometry;
// Enumeration
enum class SType
enum class ScrollType
{
noScroll = 0,
scrollJump = 1,
scrollStepBackward = 2,
scrollStepForward = 3,
scrollPageBackward = 4,
scrollPageForward = 5,
scrollWheelUp = 6,
scrollWheelDown = 7
None = 0,
Jump = 1,
StepBackward = 2,
StepForward = 3,
PageBackward = 4,
PageForward = 5,
WheelUp = 6,
WheelDown = 7
};
// Constructors
explicit FScrollbar (FWidget* = nullptr);
explicit FScrollbar (fc::orientation = fc::vertical, FWidget* = nullptr);
explicit FScrollbar (Orientation = Orientation::Vertical, FWidget* = nullptr);
// Disable copy constructor
FScrollbar (const FScrollbar&) = delete;
@ -102,7 +102,7 @@ class FScrollbar : public FWidget
// Accessors
FString getClassName() const override;
int getValue() const;
SType getScrollType() const;
ScrollType getScrollType() const;
// Mutators
void setMinimum (int);
@ -111,7 +111,7 @@ class FScrollbar : public FWidget
void setValue (int);
void setSteps (double);
void setPageSize (int, int);
void setOrientation (fc::orientation);
void setOrientation (Orientation);
void setSize (const FSize&, bool = true) override;
void setGeometry ( const FPoint&, const FSize&
, bool = true ) override;
@ -138,9 +138,9 @@ class FScrollbar : public FWidget
void drawHorizontalBar();
void drawHorizontalBackgroundColumn();
void drawButtons();
SType getClickedScrollType (int, int) const;
SType getVerticalClickedScrollType (int) const;
SType getHorizontalClickedScrollType (int) const;
ScrollType getClickedScrollType (int, int) const;
ScrollType getVerticalClickedScrollType (int) const;
ScrollType getHorizontalClickedScrollType (int) const;
int getSliderClickPos (int, int) const;
void jumpToClickPos (int, int);
void jumpToClickPos (int);
@ -149,7 +149,7 @@ class FScrollbar : public FWidget
void changeOnResize();
// Data members
SType scroll_type{SType::noScroll};
ScrollType scroll_type{ScrollType::None};
bool threshold_reached{false};
int threshold_time{500};
int repeat_time{80};
@ -165,7 +165,7 @@ class FScrollbar : public FWidget
int pagesize{0};
double steps{1};
std::size_t length{20};
fc::orientation bar_orientation{fc::vertical};
Orientation bar_orientation{Orientation::Vertical};
int max_color{FTerm::getMaxColor()};
};
@ -175,24 +175,14 @@ class FScrollbar : public FWidget
template <typename Instance
, typename Callback>
void initScrollbar ( FScrollbarPtr& bar
, fc::orientation o
, Orientation o
, Instance cb_instance
, const Callback& cb_handler )
{
try
{
bar = std::make_shared<FScrollbar>(o, cb_instance);
}
catch (const std::bad_alloc&)
{
badAllocOutput ("FScrollbar");
return;
}
bar = std::make_shared<FScrollbar>(o, cb_instance);
bar->setMinimum(0);
bar->setValue(0);
bar->hide();
bar->addCallback
(
"change-value",
@ -211,7 +201,7 @@ inline int FScrollbar::getValue() const
{ return val; }
//----------------------------------------------------------------------
inline FScrollbar::SType FScrollbar::getScrollType() const
inline FScrollbar::ScrollType FScrollbar::getScrollType() const
{ return scroll_type; }
} // namespace finalcut

View File

@ -112,15 +112,15 @@ class FScrollView : public FWidget
bool setBorder (bool);
bool setBorder();
bool unsetBorder();
void setHorizontalScrollBarMode (fc::scrollBarMode);
void setVerticalScrollBarMode (fc::scrollBarMode);
void setHorizontalScrollBarMode (ScrollBarMode);
void setVerticalScrollBarMode (ScrollBarMode);
// Inquiries
bool hasBorder() const;
bool isViewportPrint() const;
// Methods
void clearArea (int = ' ') override;
void clearArea (wchar_t = L' ') override;
void scrollToX (int);
void scrollToY (int);
void scrollTo (const FPoint&);
@ -150,11 +150,11 @@ class FScrollView : public FWidget
private:
// Using-declaration
using KeyMap = std::unordered_map<int, std::function<void()>>;
using KeyMap = std::unordered_map<FKey, std::function<void()>>;
// Constants
static constexpr int vertical_border_spacing = 2;
static constexpr int horizontal_border_spacing = 2;
static constexpr std::size_t vertical_border_spacing = 2;
static constexpr std::size_t horizontal_border_spacing = 2;
// Accessors
FPoint getViewportCursorPos();
@ -165,7 +165,7 @@ class FScrollView : public FWidget
void calculateScrollbarPos() const;
template <typename Callback>
void initScrollbar ( FScrollbarPtr&
, fc::orientation
, Orientation
, Callback );
void setHorizontalScrollBarVisibility() const;
void setVerticalScrollBarVisibility() const;
@ -185,8 +185,8 @@ class FScrollView : public FWidget
uInt8 nf_offset{0};
bool use_own_print_area{false};
bool update_scrollbar{true};
fc::scrollBarMode v_mode{fc::Auto}; // fc:Auto, fc::Hidden or fc::Scroll
fc::scrollBarMode h_mode{fc::Auto};
ScrollBarMode v_mode{ScrollBarMode::Auto}; // fc:Auto, fc::Hidden or fc::Scroll
ScrollBarMode h_mode{ScrollBarMode::Auto};
};
// FScrollView inline functions
@ -270,7 +270,7 @@ inline void FScrollView::print (const FPoint& pos)
//----------------------------------------------------------------------
template <typename Callback>
inline void FScrollView::initScrollbar ( FScrollbarPtr& bar
, fc::orientation o
, Orientation o
, Callback cb_handler )
{
finalcut::initScrollbar (bar, o, this, cb_handler);

View File

@ -125,19 +125,19 @@ class FSpinBox : public FWidget
private:
// Enumeration
enum spiningState
enum class SpiningState
{
noSpin = 0,
spinUp = 1,
spinDown = 2
None = 0,
Up = 1,
Down = 2
};
// Methods
void init();
void draw() override;
void updateInputField();
void increaseValue();
void decreaseValue();
void increaseValue (sInt64 = 1);
void decreaseValue (sInt64 = 1);
void processActivate() const;
void processChanged() const;
void forceFocus();
@ -153,7 +153,7 @@ class FSpinBox : public FWidget
sInt64 max{std::numeric_limits<sInt64>::max()};
FString pfix{};
FString sfix{};
spiningState spining_state{FSpinBox::noSpin};
SpiningState spining_state{SpiningState::None};
bool threshold_reached{false};
int threshold_time{500};
int repeat_time{80};

View File

@ -93,7 +93,7 @@ class FStartOptions final
uInt16 dark_theme : 1;
uInt16 : 15; // padding bits
fc::encoding encoding{fc::UNKNOWN};
Encoding encoding{Encoding::Unknown};
std::ofstream logfile_stream{};
};

View File

@ -117,7 +117,7 @@ class FStatusKey : public FWidget
// Data members
FString text{};
FStatusBar* bar{nullptr};
FKey key{0};
FKey key{};
bool active{false};
bool mouse_focus{false};

View File

@ -90,13 +90,14 @@ class FString
explicit FString (int);
explicit FString (std::size_t);
FString (std::size_t, wchar_t);
FString (std::size_t, const UniChar&);
FString (const FString&); // copy constructor
FString (FString&&) noexcept; // move constructor
FString (const std::wstring&); // implicit conversion constructor
FString (const wchar_t[]); // implicit conversion constructor
FString (const std::string&); // implicit conversion constructor
FString (const char[]); // implicit conversion constructor
FString (fc::SpecialCharacter); // implicit conversion constructor
FString (const UniChar&); // implicit conversion constructor
FString (const wchar_t); // implicit conversion constructor
FString (const char); // implicit conversion constructor
@ -110,7 +111,7 @@ class FString
const FString& operator += (const FString&);
FString& operator << (const FString&);
FString& operator << (fc::SpecialCharacter);
FString& operator << (const UniChar&);
FString& operator << (const wchar_t);
FString& operator << (const char);
template <typename NumT
@ -258,11 +259,11 @@ class FString
const wchar_t* _extractToken (wchar_t*[], const wchar_t[], const wchar_t[]) const;
// Data members
wchar_t* string{nullptr};
std::size_t length{0};
std::size_t bufsize{0};
mutable char* c_string{nullptr};
static wchar_t null_char;
wchar_t* string{nullptr};
std::size_t length{0};
std::size_t bufsize{0};
mutable char* c_string{nullptr};
static wchar_t null_char;
static const wchar_t const_null_char;
// Friend Non-member operator functions

View File

@ -50,7 +50,7 @@ class FStyle
{
public:
// Constructors
explicit FStyle (FAttribute attr = fc::Reset)
explicit FStyle (Style attr = Style::None)
: attribute{attr}
{ }
@ -58,19 +58,19 @@ class FStyle
FString getClassName() const
{ return "FStyle"; }
FColor getStyle() const
Style getStyle() const
{ return attribute; }
// Mutators
void setStyle (const FStyle& style)
{ attribute = style.attribute; }
void setStyle (FAttribute attr)
void setStyle (Style attr)
{ attribute = attr; }
private:
// Data members
FAttribute attribute; // Save character attributes
Style attribute; // Save character attributes
};
} // namespace finalcut

View File

@ -274,7 +274,7 @@ class FTerm final
static void detectTermSize();
static void setTermSize (const FSize&);
static void setTermTitle (const FString&);
static void setKDECursor (fc::kdeKonsoleCursorShape);
static void setKDECursor (KdeKonsoleCursorShape);
static void saveColorMap();
static void resetColorMap();
static void setPalette (FColor, int, int, int);
@ -284,12 +284,12 @@ class FTerm final
static void resetBeep();
static void beep();
static void setEncoding (fc::encoding);
static fc::encoding getEncoding();
static void setEncoding (Encoding);
static Encoding getEncoding();
static std::string getEncodingString();
static bool charEncodable (wchar_t);
static wchar_t charEncode (wchar_t);
static wchar_t charEncode (wchar_t, fc::encoding);
static wchar_t charEncode (wchar_t, Encoding);
static bool scrollTermForward();
static bool scrollTermReverse();
@ -443,15 +443,13 @@ inline void FTerm::initTerminal()
} // namespace finalcut
//----------------------------------------------------------------------
inline std::ostream& operator << ( std::ostream& os
, finalcut::fc::SpecialCharacter c )
inline std::ostream& operator << (std::ostream& os, finalcut::UniChar c)
{
return os << static_cast<char>(c);
}
//----------------------------------------------------------------------
inline std::wostream& operator << ( std::wostream& os
, finalcut::fc::SpecialCharacter c )
inline std::wostream& operator << (std::wostream& os, finalcut::UniChar c)
{
return os << static_cast<wchar_t>(c);
}

View File

@ -74,6 +74,7 @@ class FTermBuffer
// Overloaded operators
template <typename typeT>
FTermBuffer& operator << (const typeT&);
FTermBuffer& operator << (const UniChar&);
FTermBuffer& operator << (const FCharVector&);
FTermBuffer& operator << (const std::string&);
FTermBuffer& operator << (const std::wstring&);
@ -137,6 +138,13 @@ inline FTermBuffer& FTermBuffer::operator << (const typeT& s)
return *this;
}
//----------------------------------------------------------------------
inline FTermBuffer& FTermBuffer::operator << (const UniChar& c)
{
write (static_cast<wchar_t>(c));
return *this;
}
//----------------------------------------------------------------------
inline FTermBuffer& FTermBuffer::operator << (const FCharVector& vec)
{

Some files were not shown because too many files have changed in this diff Show More