Replacing null-terminated wide strings with FString objects

This commit is contained in:
Markus Gans 2019-10-01 23:14:00 +02:00
parent 6b9336d6c1
commit 298755a0fe
48 changed files with 514 additions and 810 deletions

View File

@ -1,3 +1,7 @@
2019-10-01 Markus Gans <guru.mail@muenster.de>
* Replacing null-terminated wide strings with FString objects
* Fix for getColumnWidth() with newfont character
2019-09-29 Markus Gans <guru.mail@muenster.de> 2019-09-29 Markus Gans <guru.mail@muenster.de>
* Streaming into an FTextView() object * Streaming into an FTextView() object
* Fixes the streaming of empty FString objects into a stream with * Fixes the streaming of empty FString objects into a stream with

View File

@ -83,9 +83,7 @@ The calculator example in newfont mode:
Virtual terminal Virtual terminal
---------------- ----------------
It uses a virtual terminal to print the character via an update method on the screen. FINAL CUT uses a virtual terminal to print character via an update method on the screen. It provides (as an overlying layer) virtual windows for the realization of window movements. The update methods only transfer differences to the virtual terminal or physical screen.
The virtual windows are an overlying layer to realizing window movements.
The update method transmits only the changes to the virtual terminal or the screen.
<pre style="line-height: 1 !important;"> <pre style="line-height: 1 !important;">
print(...) print(...)
@ -261,9 +259,7 @@ GNU Lesser General Public License Version 3
Frequently Asked Questions Frequently Asked Questions
-------------------------- --------------------------
If you have any problems, please read the For general questions about FINAL CUT, likely the answer is already included in the [FAQ](doc/faq.md#frequently-asked-questions).
[FAQ](doc/faq.md#frequently-asked-questions)
before you give up.
Please send bug reports to Please send bug reports to
-------------------------- --------------------------

6
debian/libfinal0.docs vendored Normal file
View File

@ -0,0 +1,6 @@
AUTHORS
COPYING
COPYING.LESSER
ChangeLog
doc/readme.txt
fonts/newfont.txt

View File

@ -1,3 +1,6 @@
usr/lib/*/lib*.so usr/lib/*/lib*.so
usr/lib/*/lib*.so.* usr/lib/*/lib*.so.*
fonts/8x16graph.pcf.gz /usr/share/fonts/X11/misc/finalcut/
fonts/fonts.alias /usr/share/fonts/X11/misc/finalcut/
fonts/fonts.dir /usr/share/fonts/X11/misc/finalcut/
fonts/newfont.txt /usr/share/fonts/X11/misc/finalcut/

View File

@ -12,3 +12,50 @@ the C++ class design of FINAL CUT. It provides common controls like
dialog boxes, push buttons, check boxes, radio buttons, input lines, dialog boxes, push buttons, check boxes, radio buttons, input lines,
list boxes, status bars and so on. list boxes, status bars and so on.
Installation
------------
> git clone git://github.com/gansm/finalcut.git
> cd finalcut
> autoreconf --install --force
> ./configure --prefix=/usr
> make
> su -c "make install"
Supported platforms
-------------------
* Linux
* FreeBSD
* NetBSD
* OpenBSD
* macOS
* Cygwin
* Solaris
First steps
-----------
See the first-steps.md documentation for information on how to use
the library.
License
-------
GNU Lesser General Public License Version 3
Frequently Asked Questions
--------------------------
For general questions about FINAL CUT, likely the answer is already included in the faq.md.
Download
--------
You can find the latest version at https://github.com/gansm/finalcut
Please send bug reports to
--------------------------
https://github.com/gansm/finalcut/issues

View File

@ -1,6 +1,13 @@
The virtual terminal (vterm) The virtual terminal (vterm)
---------------------------- ----------------------------
FINAL CUT uses a virtual terminal to print character via an update
method on the screen. It provides (as an overlying layer) virtual windows
for the realization of window movements. The update methods only transfer
differences to the virtual terminal or physical screen.
print(...) print(...)
printf(...) printf(...)

View File

@ -80,7 +80,7 @@ void Button::setChecked (bool enable)
} }
else else
{ {
const finalcut::FWidgetColors& wc = getFWidgetColors(); const auto& wc = getFWidgetColors();
setBackgroundColor(wc.button_active_bg); setBackgroundColor(wc.button_active_bg);
setFocusForegroundColor(wc.button_active_focus_fg); setFocusForegroundColor(wc.button_active_focus_fg);
setFocusBackgroundColor(wc.button_active_focus_bg); setFocusBackgroundColor(wc.button_active_focus_bg);
@ -328,7 +328,7 @@ void Calc::drawDispay()
if ( isMonochron() ) if ( isMonochron() )
setReverse(false); setReverse(false);
const finalcut::FWidgetColors& wc = getFWidgetColors(); const auto& wc = getFWidgetColors();
print() << FColorPair(fc::Black, fc::LightGray) print() << FColorPair(fc::Black, fc::LightGray)
<< FPoint(3, 3) << display << ' ' << FPoint(3, 3) << display << ' '
<< FColorPair(wc.dialog_fg, wc.dialog_bg); << FColorPair(wc.dialog_fg, wc.dialog_bg);

View File

@ -131,7 +131,7 @@ void Scrollview::draw()
if ( isMonochron() ) if ( isMonochron() )
setReverse(true); setReverse(true);
const finalcut::FWidgetColors& wc = getFWidgetColors(); const auto& wc = getFWidgetColors();
setColor (wc.label_inactive_fg, wc.dialog_bg); setColor (wc.label_inactive_fg, wc.dialog_bg);
clearArea(); clearArea();

View File

@ -262,7 +262,7 @@ void AttribDemo::printColorLine()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void AttribDemo::printAltCharset() void AttribDemo::printAltCharset()
{ {
const finalcut::FWidgetColors& wc = getFWidgetColors(); const auto& wc = getFWidgetColors();
auto parent = static_cast<AttribDlg*>(getParent()); auto parent = static_cast<AttribDlg*>(getParent());
if ( ! isMonochron() ) if ( ! isMonochron() )
@ -413,7 +413,7 @@ void AttribDemo::printProtected()
void AttribDemo::draw() void AttribDemo::draw()
{ {
// test alternate character set // test alternate character set
const finalcut::FWidgetColors& wc = getFWidgetColors(); const auto& wc = getFWidgetColors();
printAltCharset(); printAltCharset();
std::vector<std::function<void()> > effect std::vector<std::function<void()> > effect

View File

@ -89,7 +89,7 @@ void Transparent::draw()
if ( type == shadow ) if ( type == shadow )
{ {
const finalcut::FWidgetColors& wc = getFWidgetColors(); const auto& wc = getFWidgetColors();
setColor(wc.shadow_bg, wc.shadow_fg); setColor(wc.shadow_bg, wc.shadow_fg);
setTransShadow(); setTransShadow();
} }

View File

@ -68,7 +68,7 @@ class SmallWindow : public finalcut::FDialog
SmallWindow::SmallWindow (finalcut::FWidget* parent) SmallWindow::SmallWindow (finalcut::FWidget* parent)
: finalcut::FDialog(parent) : finalcut::FDialog(parent)
{ {
const finalcut::FWidgetColors& wc = getFWidgetColors(); const auto& wc = getFWidgetColors();
wchar_t arrow_up, arrow_down; wchar_t arrow_up, arrow_down;
arrow_up = fc::BlackUpPointingTriangle; arrow_up = fc::BlackUpPointingTriangle;
arrow_down = fc::BlackDownPointingTriangle; arrow_down = fc::BlackDownPointingTriangle;

View File

@ -1,3 +1,7 @@
# The FINAL CUT newfont
## *A graphical text font for X11 and the Linux console*
### How can I use the new graphical font under the Linux text console? ### How can I use the new graphical font under the Linux text console?
Simply start your program with the parameter `--newfont`. Simply start your program with the parameter `--newfont`.

View File

@ -1,3 +1,9 @@
----------------------------------------------------------------------
The FINAL CUT newfont
A graphical text font for X11 and the Linux console
----------------------------------------------------------------------
How can I use the new graphical font under the Linux text console? How can I use the new graphical font under the Linux text console?
------------------------------------------------------------------ ------------------------------------------------------------------

View File

@ -251,14 +251,11 @@ void FButton::hide()
if ( size == 0 ) if ( size == 0 )
return; return;
char* blank = createBlankArray(size + 1);
for (std::size_t y{0}; y < getHeight() + s + (f << 1); y++) for (std::size_t y{0}; y < getHeight() + s + (f << 1); y++)
{ {
print() << FPoint(1 - int(f), 1 + int(y - f)) << blank; print() << FPoint(1 - int(f), 1 + int(y - f))
<< FString(size, L' ');
} }
destroyBlankArray (blank);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -422,25 +419,7 @@ void FButton::init()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FButton::setHotkeyAccelerator() void FButton::setHotkeyAccelerator()
{ {
FKey hotkey = getHotkey(text); setHotkeyViaString (this, text);
if ( hotkey > 0xff00 && hotkey < 0xff5f ) // full-width character
hotkey -= 0xfee0;
if ( hotkey )
{
if ( std::isalpha(int(hotkey)) || std::isdigit(int(hotkey)) )
{
addAccelerator (FKey(std::tolower(int(hotkey))));
addAccelerator (FKey(std::toupper(int(hotkey))));
// Meta + hotkey
addAccelerator (fc::Fmkey_meta + FKey(std::tolower(int(hotkey))));
}
else
addAccelerator (hotkey);
}
else
delAccelerator();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -560,7 +539,7 @@ inline void FButton::drawTopBottomBackground()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FButton::drawButtonTextLine (wchar_t button_text[]) inline void FButton::drawButtonTextLine (const FString& button_text)
{ {
std::size_t pos{}; std::size_t pos{};
print() << FPoint(2 + int(indent), 1 + int(vcenter_offset)) print() << FPoint(2 + int(indent), 1 + int(vcenter_offset))
@ -638,23 +617,12 @@ inline void FButton::drawButtonTextLine (wchar_t button_text[])
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FButton::draw() void FButton::draw()
{ {
wchar_t* button_text{}; FString button_text{};
auto parent_widget = getParentWidget(); auto parent_widget = getParentWidget();
auto txtlength = text.getLength();
column_width = getColumnWidth(text); column_width = getColumnWidth(text);
space_char = int(' '); space_char = int(' ');
active_focus = getFlags().active && getFlags().focus; active_focus = getFlags().active && getFlags().focus;
try
{
button_text = new wchar_t[txtlength + 1]();
}
catch (const std::bad_alloc& ex)
{
std::cerr << bad_alloc_str << ex.what() << std::endl;
return;
}
if ( isMonochron() ) if ( isMonochron() )
setReverse(true); // Light background setReverse(true); // Light background
@ -673,7 +641,7 @@ void FButton::draw()
if ( getFlags().flat && ! button_down ) if ( getFlags().flat && ! button_down )
drawFlatBorder(); drawFlatBorder();
hotkeypos = finalcut::getHotkeyPos(text.wc_str(), button_text, uInt(txtlength)); hotkeypos = finalcut::getHotkeyPos(text, button_text);
if ( hotkeypos != NOT_SET ) if ( hotkeypos != NOT_SET )
column_width--; column_width--;
@ -702,7 +670,6 @@ void FButton::draw()
if ( isMonochron() ) if ( isMonochron() )
setReverse(false); // Dark background setReverse(false); // Dark background
delete[] button_text;
updateStatusBar(); updateStatusBar();
} }

View File

@ -182,6 +182,7 @@ void FButtonGroup::hide()
{ {
for (auto&& item : buttonlist) for (auto&& item : buttonlist)
{ {
// Hide items
auto toggle_button = static_cast<FToggleButton*>(item); auto toggle_button = static_cast<FToggleButton*>(item);
toggle_button->hide(); toggle_button->hide();
} }
@ -205,15 +206,13 @@ void FButtonGroup::hide()
if ( size == 0 ) if ( size == 0 )
return; return;
char* blank = createBlankArray(size + 1); // Hide border
unsetViewportPrint();
for (int y{0}; y < int(getHeight()); y++) for (int y{0}; y < int(getHeight()); y++)
{ print() << FPoint(1, 1 + y) << FString(size, L' ');
FWidget::setPrintPos (FPoint(1, 1 + y));
print (blank);
}
destroyBlankArray (blank); setViewportPrint();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -308,10 +307,10 @@ void FButtonGroup::onAccel (FAccelEvent*)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FButtonGroup::onFocusIn (FFocusEvent* in_ev) void FButtonGroup::onFocusIn (FFocusEvent* in_ev)
{ {
in_ev->ignore(); // Change default value to ignore
if ( hasCheckedButton() && ! buttonlist.empty() ) if ( hasCheckedButton() && ! buttonlist.empty() )
{ {
in_ev->ignore();
for (auto&& item : buttonlist) for (auto&& item : buttonlist)
{ {
auto toggle_button = static_cast<FToggleButton*>(item); auto toggle_button = static_cast<FToggleButton*>(item);
@ -374,25 +373,7 @@ void FButtonGroup::onFocusIn (FFocusEvent* in_ev)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FButtonGroup::setHotkeyAccelerator() void FButtonGroup::setHotkeyAccelerator()
{ {
FKey hotkey = getHotkey(text); setHotkeyViaString (this, text);
if ( hotkey > 0xff00 && hotkey < 0xff5f ) // full-width character
hotkey -= 0xfee0;
if ( hotkey )
{
if ( std::isalpha(int(hotkey)) || std::isdigit(int(hotkey)) )
{
addAccelerator (FKey(std::tolower(int(hotkey))));
addAccelerator (FKey(std::toupper(int(hotkey))));
// Meta + hotkey
addAccelerator (fc::Fmkey_meta + FKey(std::tolower(int(hotkey))));
}
else
addAccelerator (hotkey);
}
else
delAccelerator();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -417,36 +398,18 @@ void FButtonGroup::drawLabel()
if ( text.isNull() || text.isEmpty() ) if ( text.isNull() || text.isEmpty() )
return; return;
wchar_t* LabelText{}; FString label_text{};
FString txt{" " + text + " "}; FString txt{" " + text + " "};
std::size_t length = txt.getLength();
try
{
LabelText = new wchar_t[length + 1]();
}
catch (const std::bad_alloc& ex)
{
std::cerr << bad_alloc_str << ex.what() << std::endl;
return;
}
wchar_t* src = const_cast<wchar_t*>(txt.wc_str());
wchar_t* dest = const_cast<wchar_t*>(LabelText);
unsetViewportPrint(); unsetViewportPrint();
auto hotkeypos = finalcut::getHotkeyPos(src, dest, length); auto hotkeypos = finalcut::getHotkeyPos(txt, label_text);
if ( hotkeypos != NOT_SET )
length--;
if ( hasBorder() ) if ( hasBorder() )
FWidget::setPrintPos (FPoint(2, 1)); FWidget::setPrintPos (FPoint(2, 1));
else else
FWidget::setPrintPos (FPoint(0, 1)); FWidget::setPrintPos (FPoint(0, 1));
drawText (LabelText, hotkeypos, length); drawText (label_text, hotkeypos);
setViewportPrint(); setViewportPrint();
delete[] LabelText;
} }
@ -472,18 +435,18 @@ void FButtonGroup::init()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FButtonGroup::drawText ( wchar_t LabelText[] void FButtonGroup::drawText ( const FString& label_text
, std::size_t hotkeypos , std::size_t hotkeypos )
, std::size_t length )
{ {
const auto& wc = getFWidgetColors(); const auto& wc = getFWidgetColors();
std::size_t column_width = getColumnWidth(LabelText); std::size_t column_width = getColumnWidth(label_text);
std::size_t length = label_text.getLength();
bool ellipsis{false}; bool ellipsis{false};
if ( column_width > getClientWidth() ) if ( column_width > getClientWidth() )
{ {
std::size_t len = getClientWidth() - 3; std::size_t len = getClientWidth() - 3;
FString s = finalcut::getColumnSubString (LabelText, 1, len); FString s = finalcut::getColumnSubString (label_text, 1, len);
length = s.getLength(); length = s.getLength();
ellipsis = true; ellipsis = true;
} }
@ -505,7 +468,7 @@ void FButtonGroup::drawText ( wchar_t LabelText[]
if ( ! getFlags().no_underline ) if ( ! getFlags().no_underline )
setUnderline(); setUnderline();
print (LabelText[z]); print (label_text[z]);
if ( ! getFlags().no_underline ) if ( ! getFlags().no_underline )
unsetUnderline(); unsetUnderline();
@ -513,7 +476,7 @@ void FButtonGroup::drawText ( wchar_t LabelText[]
setColor (wc.label_emphasis_fg, wc.label_bg); setColor (wc.label_emphasis_fg, wc.label_bg);
} }
else else
print (LabelText[z]); print (label_text[z]);
} }
if ( ellipsis ) // Print ellipsis if ( ellipsis ) // Print ellipsis

View File

@ -333,25 +333,7 @@ void FLabel::init()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FLabel::setHotkeyAccelerator() void FLabel::setHotkeyAccelerator()
{ {
FKey hotkey = getHotkey(text); setHotkeyViaString (this, text);
if ( hotkey > 0xff00 && hotkey < 0xff5f ) // full-width character
hotkey -= 0xfee0;
if ( hotkey )
{
if ( std::isalpha(int(hotkey)) || std::isdigit(int(hotkey)) )
{
addAccelerator (FKey(std::tolower(int(hotkey))));
addAccelerator (FKey(std::toupper(int(hotkey))));
// Meta + hotkey
addAccelerator (fc::Fmkey_meta + FKey(std::tolower(int(hotkey))));
}
else
addAccelerator (hotkey);
}
else
delAccelerator();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -423,87 +405,48 @@ void FLabel::drawMultiLine()
while ( y < text_lines && y < std::size_t(getHeight()) ) while ( y < text_lines && y < std::size_t(getHeight()) )
{ {
wchar_t* label_text{}; FString label_text{};
std::size_t hotkeypos{NOT_SET}; hotkeypos = NOT_SET;
std::size_t align_offset{};
auto length = multiline_text[y].getLength(); auto length = multiline_text[y].getLength();
auto column_width = getColumnWidth(multiline_text[y]); column_width = getColumnWidth(multiline_text[y]);
try
{
label_text = new wchar_t[length + 1]();
}
catch (const std::bad_alloc& ex)
{
std::cerr << bad_alloc_str << ex.what() << std::endl;
return;
}
auto src = const_cast<wchar_t*>(multiline_text[y].wc_str());
auto dest = const_cast<wchar_t*>(label_text);
if ( ! hotkey_printed ) if ( ! hotkey_printed )
hotkeypos = finalcut::getHotkeyPos(src, dest, length); hotkeypos = finalcut::getHotkeyPos (multiline_text[y], label_text);
else else
std::wcsncpy(dest, src, length); label_text = multiline_text[y];
print() << FPoint(1, 1 + int(y)); print() << FPoint(1, 1 + int(y));
if ( hotkeypos != NOT_SET ) if ( hotkeypos != NOT_SET )
{ {
align_offset = getAlignOffset(length - 1); align_offset = getAlignOffset(length - 1);
printLine (label_text, length - 1, column_width, hotkeypos, align_offset);
hotkey_printed = true; hotkey_printed = true;
} }
else else
{
align_offset = getAlignOffset(length); align_offset = getAlignOffset(length);
printLine (label_text, length, column_width, NOT_SET, align_offset);
}
printLine (std::move(label_text));
y++; y++;
delete[] label_text;
} }
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FLabel::drawSingleLine() void FLabel::drawSingleLine()
{ {
wchar_t* label_text{}; FString label_text{};
std::size_t hotkeypos{NOT_SET}; column_width = getColumnWidth(text);
auto length = text.getLength(); hotkeypos = finalcut::getHotkeyPos (text, label_text);
auto column_width = getColumnWidth(text);
try
{
label_text = new wchar_t[length + 1]();
}
catch (const std::bad_alloc& ex)
{
std::cerr << bad_alloc_str << ex.what() << std::endl;
return;
}
hotkeypos = finalcut::getHotkeyPos (text.wc_str(), label_text, length);
if ( hotkeypos != NOT_SET ) if ( hotkeypos != NOT_SET )
{
length--;
column_width--; column_width--;
}
print() << FPoint(1, 1); print() << FPoint(1, 1);
auto align_offset = getAlignOffset(column_width); align_offset = getAlignOffset(column_width);
printLine (label_text, length, column_width, hotkeypos, align_offset); printLine (std::move(label_text));
delete[] label_text;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FLabel::printLine ( wchar_t line[] void FLabel::printLine (FString&& line)
, std::size_t length
, std::size_t column_width
, std::size_t hotkeypos
, std::size_t align_offset )
{ {
std::size_t to_char{}; std::size_t to_char{};
std::size_t to_column{}; std::size_t to_column{};
@ -514,7 +457,7 @@ void FLabel::printLine ( wchar_t line[]
if ( column_width <= width ) if ( column_width <= width )
{ {
to_char = length; to_char = line.getLength();
to_column = column_width; to_column = column_width;
} }
else else

View File

@ -27,7 +27,6 @@
#include "final/fcolorpair.h" #include "final/fcolorpair.h"
#include "final/fevent.h" #include "final/fevent.h"
#include "final/flistbox.h" #include "final/flistbox.h"
#include "final/fscrollbar.h"
#include "final/fstring.h" #include "final/fstring.h"
#include "final/fstatusbar.h" #include "final/fstatusbar.h"
#include "final/fwidgetcolors.h" #include "final/fwidgetcolors.h"
@ -305,21 +304,16 @@ void FListBox::clear()
const auto& wc = getFWidgetColors(); const auto& wc = getFWidgetColors();
setColor (wc.list_fg, wc.list_bg); setColor (wc.list_fg, wc.list_bg);
std::size_t size = getWidth() - 2; std::size_t size = getWidth() - 2;
drawBorder();
drawHeadline();
if ( size == 0 ) if ( size == 0 )
return; return;
char* blank = createBlankArray(size + 1);
std::memset (blank, ' ', size);
blank[size] = '\0';
for (int y{0}; y < int(getHeight()) - 2; y++) for (int y{0}; y < int(getHeight()) - 2; y++)
{ {
print() << FPoint(2, 2 + y) << blank; print() << FPoint(2, 2 + y) << FString(size, L' ');
} }
destroyBlankArray (blank);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -754,8 +748,8 @@ inline FString& FListBox::getString (listBoxItems::iterator iter)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListBox::init() void FListBox::init()
{ {
initScrollbar (vbar, fc::vertical, &FListBox::cb_VBarChange); initScrollbar (vbar, fc::vertical, this, &FListBox::cb_VBarChange);
initScrollbar (hbar, fc::horizontal, &FListBox::cb_HBarChange); initScrollbar (hbar, fc::horizontal, this, &FListBox::cb_HBarChange);
setGeometry (FPoint(1, 1), FSize(5, 4), false); // initialize geometry values setGeometry (FPoint(1, 1), FSize(5, 4), false); // initialize geometry values
const auto& wc = getFWidgetColors(); const auto& wc = getFWidgetColors();
setForegroundColor (wc.dialog_fg); setForegroundColor (wc.dialog_fg);
@ -767,32 +761,6 @@ void FListBox::init()
setRightPadding(1 + int(nf_offset)); setRightPadding(1 + int(nf_offset));
} }
//----------------------------------------------------------------------
void FListBox::initScrollbar ( FScrollbarPtr& bar
, fc::orientation o
, FListBoxCallback callback )
{
try
{
bar = std::make_shared<FScrollbar>(o, this);
}
catch (const std::bad_alloc& ex)
{
std::cerr << bad_alloc_str << ex.what() << std::endl;
return;
}
bar->setMinimum(0);
bar->setValue(0);
bar->hide();
bar->addCallback
(
"change-value",
F_METHOD_CALLBACK (this, callback)
);
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListBox::draw() void FListBox::draw()
{ {

View File

@ -32,7 +32,6 @@
#include "final/fcolorpair.h" #include "final/fcolorpair.h"
#include "final/fevent.h" #include "final/fevent.h"
#include "final/flistview.h" #include "final/flistview.h"
#include "final/fscrollbar.h"
#include "final/fstatusbar.h" #include "final/fstatusbar.h"
#include "final/fstring.h" #include "final/fstring.h"
#include "final/ftermbuffer.h" #include "final/ftermbuffer.h"
@ -42,7 +41,7 @@ namespace finalcut
{ {
// Static class attribute // Static class attribute
FObject::FObjectIterator FListView::null_iter; FObject::iterator FListView::null_iter;
// Function prototypes // Function prototypes
uInt64 firstNumberFromString (const FString&); uInt64 firstNumberFromString (const FString&);
@ -55,14 +54,13 @@ bool sortDescendingByNumber (const FObject*, const FObject*);
//---------------------------------------------------------------------- //----------------------------------------------------------------------
uInt64 firstNumberFromString (const FString& str) uInt64 firstNumberFromString (const FString& str)
{ {
auto last = str.end();
auto iter = str.begin(); auto iter = str.begin();
while ( iter != last ) while ( iter != str.end() )
{ {
if ( wchar_t(*iter) >= L'0' && wchar_t(*iter) <= L'9' ) if ( wchar_t(*iter) >= L'0' && wchar_t(*iter) <= L'9' )
{ {
if ( wchar_t(*(iter - 1)) == L'-' ) if ( iter != str.begin() && wchar_t(*(iter - 1)) == L'-' )
--iter; --iter;
break; break;
@ -73,10 +71,10 @@ uInt64 firstNumberFromString (const FString& str)
auto first_pos = iter; auto first_pos = iter;
if ( first_pos == last ) if ( first_pos == str.end() )
return 0; return 0;
while ( iter != last ) while ( iter != str.end() )
{ {
if ( wchar_t(*iter) < L'0' || wchar_t(*iter) > L'9' ) if ( wchar_t(*iter) < L'0' || wchar_t(*iter) > L'9' )
break; break;
@ -86,7 +84,7 @@ uInt64 firstNumberFromString (const FString& str)
auto last_pos = iter; auto last_pos = iter;
if ( last_pos == last ) if ( last_pos == str.end() )
return 0; return 0;
uInt64 number; uInt64 number;
@ -186,7 +184,7 @@ FListViewItem::FListViewItem (const FListViewItem& item)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FListViewItem::FListViewItem (FObjectIterator parent_iter) FListViewItem::FListViewItem (iterator parent_iter)
: FObject((*parent_iter)->getParent()) : FObject((*parent_iter)->getParent())
{ {
insert (this, parent_iter); insert (this, parent_iter);
@ -195,7 +193,7 @@ FListViewItem::FListViewItem (FObjectIterator parent_iter)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FListViewItem::FListViewItem ( const FStringList& cols FListViewItem::FListViewItem ( const FStringList& cols
, FDataPtr data , FDataPtr data
, FObjectIterator parent_iter ) , iterator parent_iter )
: FObject(nullptr) : FObject(nullptr)
, column_list(cols) , column_list(cols)
, data_pointer(data) , data_pointer(data)
@ -279,7 +277,7 @@ void FListViewItem::setText (int column, const FString& text)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FObject::FObjectIterator FListViewItem::insert (FListViewItem* child) FObject::iterator FListViewItem::insert (FListViewItem* child)
{ {
// Add a FListViewItem as child element // Add a FListViewItem as child element
if ( ! child ) if ( ! child )
@ -289,8 +287,8 @@ FObject::FObjectIterator FListViewItem::insert (FListViewItem* child)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FObject::FObjectIterator FListViewItem::insert ( FListViewItem* child FObject::iterator FListViewItem::insert ( FListViewItem* child
, FObjectIterator parent_iter ) , iterator parent_iter )
{ {
if ( parent_iter == FListView::null_iter ) if ( parent_iter == FListView::null_iter )
return FListView::null_iter; return FListView::null_iter;
@ -353,7 +351,7 @@ void FListViewItem::sort (Compare cmp)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FObject::FObjectIterator FListViewItem::appendItem (FListViewItem* child) FObject::iterator FListViewItem::appendItem (FListViewItem* child)
{ {
expandable = true; expandable = true;
resetVisibleLineCounter(); resetVisibleLineCounter();
@ -434,7 +432,7 @@ void FListViewItem::resetVisibleLineCounter()
// constructor and destructor // constructor and destructor
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FListViewIterator::FListViewIterator (FObjectIterator iter) FListViewIterator::FListViewIterator (iterator iter)
: node(iter) : node(iter)
{ } { }
@ -496,7 +494,7 @@ FListViewIterator& FListViewIterator::operator -= (volatile int n)
// private methods of FListViewIterator // private methods of FListViewIterator
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListViewIterator::nextElement (FObjectIterator& iter) void FListViewIterator::nextElement (iterator& iter)
{ {
auto item = static_cast<FListViewItem*>(*iter); auto item = static_cast<FListViewItem*>(*iter);
@ -526,7 +524,7 @@ void FListViewIterator::nextElement (FObjectIterator& iter)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListViewIterator::prevElement (FObjectIterator& iter) void FListViewIterator::prevElement (iterator& iter)
{ {
auto start_iter = iter; auto start_iter = iter;
@ -713,7 +711,7 @@ void FListView::setColumnSortType (int column, fc::sorting_type type)
if ( column < 1 || header.empty() || column > int(header.size()) ) if ( column < 1 || header.empty() || column > int(header.size()) )
return; return;
std::size_t size = std::size_t(column + 1); std::size_t size = std::size_t(column) + 1;
if ( sort_type.empty() || sort_type.size() < size ) if ( sort_type.empty() || sort_type.size() < size )
sort_type.resize(size); sort_type.resize(size);
@ -760,10 +758,10 @@ void FListView::hide()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FObject::FObjectIterator FListView::insert ( FListViewItem* item FObject::iterator FListView::insert ( FListViewItem* item
, FObjectIterator parent_iter ) , iterator parent_iter )
{ {
FObjectIterator item_iter; iterator item_iter;
if ( parent_iter == FListView::null_iter ) if ( parent_iter == FListView::null_iter )
return FListView::null_iter; return FListView::null_iter;
@ -799,9 +797,9 @@ FObject::FObjectIterator FListView::insert ( FListViewItem* item
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FObject::FObjectIterator FListView::insert ( const FStringList& cols FObject::iterator FListView::insert ( const FStringList& cols
, FDataPtr d , FDataPtr d
, FObjectIterator parent_iter ) , iterator parent_iter )
{ {
FListViewItem* item; FListViewItem* item;
@ -1379,8 +1377,8 @@ void FListView::adjustSize()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListView::init() void FListView::init()
{ {
initScrollbar (vbar, fc::vertical, &FListView::cb_VBarChange); initScrollbar (vbar, fc::vertical, this, &FListView::cb_VBarChange);
initScrollbar (hbar, fc::horizontal, &FListView::cb_HBarChange); initScrollbar (hbar, fc::horizontal, this, &FListView::cb_HBarChange);
selflist.push_back(this); selflist.push_back(this);
root = selflist.begin(); root = selflist.begin();
null_iter = selflist.end(); null_iter = selflist.end();
@ -1395,32 +1393,6 @@ void FListView::init()
setRightPadding(1 + int(nf_offset)); setRightPadding(1 + int(nf_offset));
} }
//----------------------------------------------------------------------
void FListView::initScrollbar ( FScrollbarPtr& bar
, fc::orientation o
, FListViewCallback callback )
{
try
{
bar = std::make_shared<FScrollbar>(o, this);
}
catch (const std::bad_alloc& ex)
{
std::cerr << bad_alloc_str << ex.what() << std::endl;
return;
}
bar->setMinimum(0);
bar->setValue(0);
bar->hide();
bar->addCallback
(
"change-value",
F_METHOD_CALLBACK (this, callback)
);
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
template <typename Compare> template <typename Compare>
void FListView::sort (Compare cmp) void FListView::sort (Compare cmp)
@ -2283,7 +2255,7 @@ void FListView::stopDragScroll()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FObject::FObjectIterator FListView::appendItem (FListViewItem* item) FObject::iterator FListView::appendItem (FListViewItem* item)
{ {
item->root = root; item->root = root;
addChild (item); addChild (item);

View File

@ -1236,8 +1236,6 @@ inline void FMenu::drawMenuLine (FMenuItem* m_item, int y)
{ {
FString txt(m_item->getText()); FString txt(m_item->getText());
menuText txtdata{}; menuText txtdata{};
std::size_t txt_length = txt.getLength();
std::size_t to_char = txt_length;
std::size_t column_width = getColumnWidth(txt); std::size_t column_width = getColumnWidth(txt);
FKey accel_key = m_item->accel_key; FKey accel_key = m_item->accel_key;
bool is_enabled = m_item->isEnabled(); bool is_enabled = m_item->isEnabled();
@ -1252,25 +1250,11 @@ inline void FMenu::drawMenuLine (FMenuItem* m_item, int y)
// Print leading blank space // Print leading blank space
print (' '); print (' ');
try hotkeypos = finalcut::getHotkeyPos(txt, txtdata.text);
{
txtdata.text = new wchar_t[txt_length + 1]();
}
catch (const std::bad_alloc& ex)
{
std::cerr << bad_alloc_str << ex.what() << std::endl;
return;
}
hotkeypos = finalcut::getHotkeyPos(txt.wc_str(), txtdata.text, txt_length);
if ( hotkeypos != NOT_SET ) if ( hotkeypos != NOT_SET )
{
to_char--;
column_width--; column_width--;
}
txtdata.length = to_char;
txtdata.no_underline = m_item->getFlags().no_underline; txtdata.no_underline = m_item->getFlags().no_underline;
setCursorToHotkeyPosition (m_item); setCursorToHotkeyPosition (m_item);
@ -1292,8 +1276,6 @@ inline void FMenu::drawMenuLine (FMenuItem* m_item, int y)
if ( isMonochron() && is_enabled && is_selected ) if ( isMonochron() && is_enabled && is_selected )
setReverse(true); setReverse(true);
delete[] txtdata.text;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -1347,7 +1329,7 @@ inline void FMenu::drawMenuText (menuText& data)
{ {
// Print menu text // Print menu text
for (std::size_t z{0}; z < data.length; z++) for (std::size_t z{0}; z < data.text.getLength(); z++)
{ {
if ( ! std::iswprint(std::wint_t(data.text[z])) ) if ( ! std::iswprint(std::wint_t(data.text[z])) )
{ {

View File

@ -64,15 +64,13 @@ void FMenuBar::resetMenu()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenuBar::hide() void FMenuBar::hide()
{ {
FWindow::hide();
const auto& wc = getFWidgetColors(); const auto& wc = getFWidgetColors();
FColor fg = wc.term_fg; FColor fg = wc.term_fg;
FColor bg = wc.term_bg; FColor bg = wc.term_bg;
setColor (fg, bg); setColor (fg, bg);
screenWidth = getDesktopWidth(); print() << FPoint(1, 1) << FString(getDesktopWidth(), L' ');
char* blank = createBlankArray (screenWidth + 1); updateTerminal();
print() << FPoint(1, 1) << blank; FWindow::hide();
destroyBlankArray (blank);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -482,14 +480,13 @@ void FMenuBar::drawItems()
if ( isMonochron() ) if ( isMonochron() )
setReverse(true); setReverse(true);
screenWidth = getDesktopWidth();
std::size_t x{1}; std::size_t x{1};
for (auto&& item : list) for (auto&& item : list)
drawItem (item, x); drawItem (item, x);
// Print spaces to end of line // Print spaces to end of line
for (; x <= screenWidth; x++) for (; x <= getDesktopWidth(); x++)
print (' '); print (' ');
if ( isMonochron() ) if ( isMonochron() )
@ -503,8 +500,6 @@ inline void FMenuBar::drawItem (FMenuItem* menuitem, std::size_t& x)
txtdata.startpos = x + 1; txtdata.startpos = x + 1;
txtdata.no_underline = menuitem->getFlags().no_underline; txtdata.no_underline = menuitem->getFlags().no_underline;
FString txt(menuitem->getText()); FString txt(menuitem->getText());
std::size_t to_char{};
std::size_t txt_length = txt.getLength();
std::size_t column_width = getColumnWidth(txt); std::size_t column_width = getColumnWidth(txt);
bool is_enabled = menuitem->isEnabled(); bool is_enabled = menuitem->isEnabled();
bool is_selected = menuitem->isSelected(); bool is_selected = menuitem->isSelected();
@ -513,32 +508,14 @@ inline void FMenuBar::drawItem (FMenuItem* menuitem, std::size_t& x)
setLineAttributes (menuitem); setLineAttributes (menuitem);
drawLeadingSpace (x); drawLeadingSpace (x);
try if ( x - 1 > screenWidth )
{ txt = txt.left(getColumnWidth(txt) - screenWidth - x - 1);
txtdata.text = new wchar_t[txt_length + 1]();
}
catch (const std::bad_alloc& ex)
{
std::cerr << bad_alloc_str << ex.what() << std::endl;
return;
}
if ( x - 1 <= screenWidth ) std::size_t hotkeypos = finalcut::getHotkeyPos(txt, txtdata.text);
to_char = txt_length;
else
to_char = txt_length - screenWidth - x - 1;
std::size_t hotkeypos = finalcut::getHotkeyPos ( txt.wc_str()
, txtdata.text
, txt_length );
if ( hotkeypos != NOT_SET ) if ( hotkeypos != NOT_SET )
{
column_width--; column_width--;
to_char--;
}
txtdata.length = to_char;
x += column_width; x += column_width;
if ( ! is_enabled || is_selected ) if ( ! is_enabled || is_selected )
@ -556,8 +533,6 @@ inline void FMenuBar::drawItem (FMenuItem* menuitem, std::size_t& x)
if ( isMonochron() && is_enabled && is_selected ) if ( isMonochron() && is_enabled && is_selected )
setReverse(true); setReverse(true);
delete[] txtdata.text;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -616,7 +591,7 @@ inline void FMenuBar::drawMenuText (menuText& data)
{ {
// Print menu text // Print menu text
for (std::size_t z{0}; z < data.length; z++) for (std::size_t z{0}; z < data.text.getLength(); z++)
{ {
if ( data.startpos > screenWidth - z ) if ( data.startpos > screenWidth - z )
break; break;

View File

@ -101,7 +101,7 @@ std::ostream& operator << (std::ostream& outstr, const FPoint& p)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
std::istream& operator >> (std::istream& instr, FPoint& p) std::istream& operator >> (std::istream& instr, FPoint& p)
{ {
int x, y; int x{}, y{};
instr >> x; instr >> x;
instr >> y; instr >> y;
p.setPoint (x, y); p.setPoint (x, y);

View File

@ -381,7 +381,7 @@ std::ostream& operator << (std::ostream& outstr, const FRect& r)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
std::istream& operator >> (std::istream& instr, FRect& r) std::istream& operator >> (std::istream& instr, FRect& r)
{ {
int x1, y1, x2, y2; int x1{}, y1{}, x2{}, y2{};
instr >> x1; instr >> x1;
instr >> y1; instr >> y1;
instr >> x2; instr >> x2;

View File

@ -346,7 +346,7 @@ void FScrollbar::onMouseMove (FMouseEvent* ev)
if ( scroll_type == FScrollbar::scrollJump ) if ( scroll_type == FScrollbar::scrollJump )
{ {
int new_val; int new_val{};
if ( bar_orientation == fc::vertical ) if ( bar_orientation == fc::vertical )
{ {

View File

@ -797,34 +797,6 @@ void FScrollView::init (FWidget* parent)
setChildPrintArea (viewport); setChildPrintArea (viewport);
} }
//----------------------------------------------------------------------
void FScrollView::initScrollbar ( FScrollbarPtr& bar
, fc::orientation o
, FScrollViewCallback callback )
{
try
{
bar = std::make_shared<FScrollbar>(o, this);
}
catch (const std::bad_alloc& ex)
{
std::cerr << bad_alloc_str << ex.what() << std::endl;
return;
}
term_area* area = getPrintArea();
bar->setPrintArea(area);
bar->setMinimum(0);
bar->setValue(0);
bar->hide();
bar->addCallback
(
"change-value",
F_METHOD_CALLBACK (this, callback)
);
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FScrollView::calculateScrollbarPos() void FScrollView::calculateScrollbarPos()
{ {

View File

@ -174,15 +174,13 @@ bool FStatusBar::hasActivatedKey()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FStatusBar::hide() void FStatusBar::hide()
{ {
FWindow::hide();
const auto& wc = getFWidgetColors(); const auto& wc = getFWidgetColors();
FColor fg = wc.term_fg; FColor fg = wc.term_fg;
FColor bg = wc.term_bg; FColor bg = wc.term_bg;
setColor (fg, bg); setColor (fg, bg);
screenWidth = getDesktopWidth(); print() << FPoint(1, 1) << FString(getDesktopWidth(), L' ');
char* blank = createBlankArray(screenWidth + 1); updateTerminal();
print() << FPoint(1, 1) << blank; FWindow::hide();
destroyBlankArray (blank);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -408,10 +406,9 @@ void FStatusBar::onMouseUp (FMouseEvent* ev)
if ( (*iter)->hasMouseFocus() ) if ( (*iter)->hasMouseFocus() )
{ {
int mouse_x, mouse_y;
(*iter)->unsetMouseFocus(); (*iter)->unsetMouseFocus();
mouse_x = ev->getX(); int mouse_x = ev->getX();
mouse_y = ev->getY(); int mouse_y = ev->getY();
if ( mouse_x >= x1 && mouse_x <= x2 && mouse_y == 1 ) if ( mouse_x >= x1 && mouse_x <= x2 && mouse_y == 1 )
(*iter)->setActive(); (*iter)->setActive();

View File

@ -847,7 +847,7 @@ FString& FString::setString (const FString& s)
FString& FString::setNumber (sInt64 num) FString& FString::setNumber (sInt64 num)
{ {
bool neg{false}; bool neg{false};
wchar_t buf[30]; wchar_t buf[30]{};
wchar_t* s = &buf[29]; wchar_t* s = &buf[29];
if ( num < 0 ) if ( num < 0 )
@ -879,7 +879,7 @@ FString& FString::setNumber (sInt64 num)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FString& FString::setNumber (uInt64 num) FString& FString::setNumber (uInt64 num)
{ {
wchar_t buf[30]; wchar_t buf[30]{};
wchar_t* s = &buf[29]; wchar_t* s = &buf[29];
*s = '\0'; *s = '\0';
@ -897,7 +897,7 @@ FString& FString::setNumber (uInt64 num)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FString& FString::setNumber (lDouble f_num, int precision) FString& FString::setNumber (lDouble f_num, int precision)
{ {
wchar_t format[20]; // = "%.<precision>Lg" wchar_t format[20]{}; // = "%.<precision>Lg"
wchar_t* s = &format[0]; wchar_t* s = &format[0];
*s++ = L'%'; *s++ = L'%';
*s++ = L'.'; *s++ = L'.';
@ -930,7 +930,7 @@ FString& FString::setFormatedNumber (sInt64 num, char separator)
{ {
bool neg{false}; bool neg{false};
int n{0}; int n{0};
wchar_t buf[30]; wchar_t buf[30]{};
wchar_t* s = &buf[29]; wchar_t* s = &buf[29];
if ( separator == 0 ) if ( separator == 0 )
@ -969,7 +969,7 @@ FString& FString::setFormatedNumber (sInt64 num, char separator)
FString& FString::setFormatedNumber (uInt64 num, char separator) FString& FString::setFormatedNumber (uInt64 num, char separator)
{ {
int n{0}; int n{0};
wchar_t buf[30]; wchar_t buf[30]{};
wchar_t* s = &buf[29]; wchar_t* s = &buf[29];
*s = L'\0'; *s = L'\0';
@ -1328,7 +1328,7 @@ void FString::_assign (const wchar_t s[])
if ( string && std::wcscmp(string, s) == 0 ) if ( string && std::wcscmp(string, s) == 0 )
return; // string == s return; // string == s
uInt new_length= uInt(std::wcslen(s)); uInt new_length = uInt(std::wcslen(s));
if ( ! string || new_length > capacity() ) if ( ! string || new_length > capacity() )
{ {

View File

@ -759,7 +759,7 @@ bool FTerm::setOldFont()
if ( font.getLength() > 2 ) if ( font.getLength() > 2 )
{ {
// restore saved xterm font // restore saved xterm font
xterm->setFont (font); xterm->setFont(font);
} }
else else
{ {
@ -1855,14 +1855,14 @@ void FTerm::init_captureFontAndTitle()
// Save the used xterm font and window title // Save the used xterm font and window title
xterm->captureFontAndTitle(); xterm->captureFontAndTitle();
const auto font = xterm->getFont(); const auto& font = xterm->getFont();
const auto title = xterm->getTitle(); const auto& title = xterm->getTitle();
if ( font ) if ( ! font.isEmpty() )
data->setXtermFont(*font); data->setXtermFont(font);
if ( title ) if ( ! title.isEmpty() )
data->setXtermTitle(*title); data->setXtermTitle(title);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -2549,7 +2549,7 @@ wchar_t cp437_to_unicode (uChar c)
{ {
constexpr std::size_t CP437 = 0; constexpr std::size_t CP437 = 0;
constexpr std::size_t UNICODE = 1; constexpr std::size_t UNICODE = 1;
wchar_t ucs(c); wchar_t ucs = c;
for (std::size_t i{0}; i <= fc::lastCP437Item; i++) for (std::size_t i{0}; i <= fc::lastCP437Item; i++)
{ {
@ -2740,15 +2740,20 @@ std::size_t getColumnWidth (const FString& s)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
std::size_t getColumnWidth (const wchar_t wchar) std::size_t getColumnWidth (const wchar_t wchar)
{ {
int column_width = wcwidth (wchar); int column_width{};
if ( wchar >= fc::NF_rev_left_arrow2 && wchar <= fc::NF_check_mark )
column_width = 1;
else
column_width = wcwidth(wchar);
return ( column_width == -1 ) ? 0 : std::size_t(column_width); return ( column_width == -1 ) ? 0 : std::size_t(column_width);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
std::size_t getColumnWidth (charData& term_char) std::size_t getColumnWidth (charData& term_char)
{ {
int column_width = wcwidth (term_char.code); std::size_t char_width = getColumnWidth(term_char.code);
std::size_t char_width = ( column_width == -1 ) ? 0 : std::size_t(column_width);
if ( char_width == 2 && FTerm::getEncoding() != fc::UTF8 ) if ( char_width == 2 && FTerm::getEncoding() != fc::UTF8 )
{ {

View File

@ -43,14 +43,14 @@ bool FTermXTerminal::meta_sends_esc{false};
bool FTermXTerminal::xterm_default_colors{false}; bool FTermXTerminal::xterm_default_colors{false};
std::size_t FTermXTerminal::term_width{80}; std::size_t FTermXTerminal::term_width{80};
std::size_t FTermXTerminal::term_height{24}; std::size_t FTermXTerminal::term_height{24};
const FString* FTermXTerminal::xterm_font{nullptr}; FString FTermXTerminal::xterm_font{};
const FString* FTermXTerminal::xterm_title{nullptr}; FString FTermXTerminal::xterm_title{};
const FString* FTermXTerminal::foreground_color{nullptr}; FString FTermXTerminal::foreground_color{};
const FString* FTermXTerminal::background_color{nullptr}; FString FTermXTerminal::background_color{};
const FString* FTermXTerminal::cursor_color{nullptr}; FString FTermXTerminal::cursor_color{};
const FString* FTermXTerminal::mouse_foreground_color{nullptr}; FString FTermXTerminal::mouse_foreground_color{};
const FString* FTermXTerminal::mouse_background_color{nullptr}; FString FTermXTerminal::mouse_background_color{};
const FString* FTermXTerminal::highlight_background_color{nullptr}; FString FTermXTerminal::highlight_background_color{};
FSystem* FTermXTerminal::fsystem{nullptr}; FSystem* FTermXTerminal::fsystem{nullptr};
FTermDetection* FTermXTerminal::term_detection{nullptr}; FTermDetection* FTermXTerminal::term_detection{nullptr};
fc::xtermCursorStyle FTermXTerminal::cursor_style{fc::unknown_cursor_style}; fc::xtermCursorStyle FTermXTerminal::cursor_style{fc::unknown_cursor_style};
@ -70,31 +70,7 @@ FTermXTerminal::FTermXTerminal()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FTermXTerminal::~FTermXTerminal() // destructor FTermXTerminal::~FTermXTerminal() // destructor
{ { }
if ( highlight_background_color )
delete highlight_background_color;
if ( mouse_background_color )
delete mouse_background_color;
if ( mouse_foreground_color )
delete mouse_foreground_color;
if ( cursor_color )
delete cursor_color;
if ( background_color )
delete background_color;
if ( foreground_color )
delete foreground_color;
if ( xterm_title )
delete xterm_title;
if ( xterm_font )
delete xterm_font;
}
// public methods of FTermXTerminal // public methods of FTermXTerminal
@ -112,10 +88,7 @@ void FTermXTerminal::setFont (const FString& fontname)
{ {
// Change the XTerm font (needs the allowFontOps resource) // Change the XTerm font (needs the allowFontOps resource)
if ( xterm_font ) xterm_font = fontname;
delete xterm_font;
xterm_font = new FString(fontname);
setXTermFont(); setXTermFont();
} }
@ -124,10 +97,7 @@ void FTermXTerminal::setTitle (const FString& title)
{ {
// Set the xterm title // Set the xterm title
if ( xterm_title ) xterm_title = title;
delete xterm_title;
xterm_title = new FString(title);
setXTermTitle(); setXTermTitle();
} }
@ -146,10 +116,7 @@ void FTermXTerminal::setForeground (const FString& fg)
{ {
// Set the XTerm text foreground color // Set the XTerm text foreground color
if ( foreground_color ) foreground_color = fg;
delete foreground_color;
foreground_color = new FString(fg);
setXTermForeground(); setXTermForeground();
} }
@ -158,10 +125,7 @@ void FTermXTerminal::setBackground (const FString& bg)
{ {
// Set the XTerm text background color // Set the XTerm text background color
if ( background_color ) background_color = bg;
delete background_color;
background_color = new FString(bg);
setXTermBackground(); setXTermBackground();
} }
@ -170,10 +134,7 @@ void FTermXTerminal::setCursorColor (const FString& cc)
{ {
// Set the text cursor color // Set the text cursor color
if ( cursor_color ) cursor_color = cc;
delete cursor_color;
cursor_color = new FString(cc);
setXTermCursorColor(); setXTermCursorColor();
} }
@ -182,10 +143,7 @@ void FTermXTerminal::setMouseForeground (const FString& mfg)
{ {
// Set the mouse foreground color // Set the mouse foreground color
if ( mouse_foreground_color ) mouse_foreground_color = mfg;
delete mouse_foreground_color;
mouse_foreground_color = new FString(mfg);
setXTermMouseForeground(); setXTermMouseForeground();
} }
@ -194,10 +152,7 @@ void FTermXTerminal::setMouseBackground (const FString& mbg)
{ {
// Set the mouse background color // Set the mouse background color
if ( mouse_background_color ) mouse_background_color = mbg;
delete mouse_background_color;
mouse_background_color = new FString(mbg);
setXTermMouseBackground(); setXTermMouseBackground();
} }
@ -206,10 +161,7 @@ void FTermXTerminal::setHighlightBackground (const FString& hbg)
{ {
// Set the highlight background color // Set the highlight background color
if ( highlight_background_color ) highlight_background_color = hbg;
delete highlight_background_color;
highlight_background_color = new FString(hbg);
setXTermHighlightBackground(); setXTermHighlightBackground();
} }
@ -266,10 +218,7 @@ void FTermXTerminal::resetForeground()
{ {
// Reset the XTerm text foreground color // Reset the XTerm text foreground color
if ( foreground_color ) foreground_color.clear();
delete foreground_color;
foreground_color = nullptr;
resetXTermForeground(); resetXTermForeground();
} }
@ -278,10 +227,7 @@ void FTermXTerminal::resetBackground()
{ {
// Reset the XTerm text background color // Reset the XTerm text background color
if ( background_color ) background_color.clear();
delete background_color;
background_color = nullptr;
resetXTermBackground(); resetXTermBackground();
} }
@ -290,10 +236,7 @@ void FTermXTerminal::resetCursorColor()
{ {
// Reset the text cursor color // Reset the text cursor color
if ( cursor_color ) cursor_color.clear();
delete cursor_color;
cursor_color = nullptr;
resetXTermCursorColor(); resetXTermCursorColor();
} }
@ -302,10 +245,7 @@ void FTermXTerminal::resetMouseForeground()
{ {
// Reset the mouse foreground color // Reset the mouse foreground color
if ( mouse_foreground_color ) mouse_foreground_color.clear();
delete mouse_foreground_color;
mouse_foreground_color = nullptr;
resetXTermMouseForeground(); resetXTermMouseForeground();
} }
@ -314,10 +254,7 @@ void FTermXTerminal::resetMouseBackground()
{ {
// Reset the mouse background color // Reset the mouse background color
if ( mouse_background_color ) mouse_background_color.clear();
delete mouse_background_color;
mouse_background_color = nullptr;
resetXTermMouseBackground(); resetXTermMouseBackground();
} }
@ -326,10 +263,7 @@ void FTermXTerminal::resetHighlightBackground()
{ {
// Reset the highlight background color // Reset the highlight background color
if ( highlight_background_color ) highlight_background_color.clear();
delete highlight_background_color;
highlight_background_color = nullptr;
resetXTermHighlightBackground(); resetXTermHighlightBackground();
} }
@ -364,12 +298,6 @@ void FTermXTerminal::captureFontAndTitle()
|| term_detection->isUrxvtTerminal() ) || term_detection->isUrxvtTerminal() )
&& ! term_detection->isRxvtTerminal() ) && ! term_detection->isRxvtTerminal() )
{ {
if ( xterm_font )
delete xterm_font;
if ( xterm_title )
delete xterm_title;
FTermios::setCaptureSendCharacters(); FTermios::setCaptureSendCharacters();
xterm_font = captureXTermFont(); xterm_font = captureXTermFont();
xterm_title = captureXTermTitle(); xterm_title = captureXTermTitle();
@ -420,7 +348,7 @@ void FTermXTerminal::setXTermTitle()
|| FTermcap::osc_support ) || FTermcap::osc_support )
{ {
oscPrefix(); oscPrefix();
FTerm::putstringf (OSC "0;%s" BEL, xterm_title->c_str()); FTerm::putstringf (OSC "0;%s" BEL, xterm_title.c_str());
oscPostfix(); oscPostfix();
std::fflush(stdout); std::fflush(stdout);
} }
@ -449,7 +377,7 @@ void FTermXTerminal::setXTermFont()
|| FTermcap::osc_support ) || FTermcap::osc_support )
{ {
oscPrefix(); oscPrefix();
FTerm::putstringf (OSC "50;%s" BEL, xterm_font->c_str() ); FTerm::putstringf (OSC "50;%s" BEL, xterm_font.c_str() );
oscPostfix(); oscPostfix();
} }
} }
@ -466,7 +394,7 @@ void FTermXTerminal::setXTermForeground()
|| FTermcap::osc_support ) || FTermcap::osc_support )
{ {
oscPrefix(); oscPrefix();
FTerm::putstringf (OSC "10;%s" BEL, foreground_color->c_str()); FTerm::putstringf (OSC "10;%s" BEL, foreground_color.c_str());
oscPostfix(); oscPostfix();
std::fflush(stdout); std::fflush(stdout);
} }
@ -484,7 +412,7 @@ void FTermXTerminal::setXTermBackground()
|| FTermcap::osc_support ) || FTermcap::osc_support )
{ {
oscPrefix(); oscPrefix();
FTerm::putstringf (OSC "11;%s" BEL, background_color->c_str()); FTerm::putstringf (OSC "11;%s" BEL, background_color.c_str());
oscPostfix(); oscPostfix();
std::fflush(stdout); std::fflush(stdout);
} }
@ -502,7 +430,7 @@ void FTermXTerminal::setXTermCursorColor()
|| FTermcap::osc_support ) || FTermcap::osc_support )
{ {
oscPrefix(); oscPrefix();
FTerm::putstringf (OSC "12;%s" BEL, cursor_color->c_str()); FTerm::putstringf (OSC "12;%s" BEL, cursor_color.c_str());
oscPostfix(); oscPostfix();
std::fflush(stdout); std::fflush(stdout);
} }
@ -519,7 +447,7 @@ void FTermXTerminal::setXTermMouseForeground()
|| FTermcap::osc_support ) || FTermcap::osc_support )
{ {
oscPrefix(); oscPrefix();
FTerm::putstringf (OSC "13;%s" BEL, mouse_foreground_color->c_str()); FTerm::putstringf (OSC "13;%s" BEL, mouse_foreground_color.c_str());
oscPostfix(); oscPostfix();
std::fflush(stdout); std::fflush(stdout);
} }
@ -535,7 +463,7 @@ void FTermXTerminal::setXTermMouseBackground()
|| FTermcap::osc_support ) || FTermcap::osc_support )
{ {
oscPrefix(); oscPrefix();
FTerm::putstringf (OSC "14;%s" BEL, mouse_background_color->c_str()); FTerm::putstringf (OSC "14;%s" BEL, mouse_background_color.c_str());
oscPostfix(); oscPostfix();
std::fflush(stdout); std::fflush(stdout);
} }
@ -552,7 +480,7 @@ void FTermXTerminal::setXTermHighlightBackground()
|| FTermcap::osc_support ) || FTermcap::osc_support )
{ {
oscPrefix(); oscPrefix();
FTerm::putstringf (OSC "17;%s" BEL, highlight_background_color->c_str()); FTerm::putstringf (OSC "17;%s" BEL, highlight_background_color.c_str());
oscPostfix(); oscPostfix();
std::fflush(stdout); std::fflush(stdout);
} }
@ -769,7 +697,7 @@ void FTermXTerminal::oscPostfix()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
const FString* FTermXTerminal::captureXTermFont() const FString FTermXTerminal::captureXTermFont()
{ {
if ( term_detection->isXTerminal() if ( term_detection->isXTerminal()
|| term_detection->isScreenTerm() || term_detection->isScreenTerm()
@ -796,36 +724,25 @@ const FString* FTermXTerminal::captureXTermFont()
if ( std::scanf("\033]50;%148[^\n]s", temp) == 1 ) if ( std::scanf("\033]50;%148[^\n]s", temp) == 1 )
{ {
FString* xtermfont;
std::size_t n = std::strlen(temp); std::size_t n = std::strlen(temp);
// BEL + '\0' = string terminator // BEL + '\0' = string terminator
if ( n >= 5 && temp[n - 1] == BEL[0] && temp[n] == '\0' ) if ( n >= 5 && temp[n - 1] == BEL[0] && temp[n] == '\0' )
temp[n - 1] = '\0'; temp[n - 1] = '\0';
try return FString(temp);
{
xtermfont = new FString(temp);
}
catch (const std::bad_alloc& ex)
{
std::cerr << bad_alloc_str << ex.what() << std::endl;
return 0;
}
return xtermfont;
} }
} }
} }
return 0; return FString{};
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
const FString* FTermXTerminal::captureXTermTitle() const FString FTermXTerminal::captureXTermTitle()
{ {
if ( term_detection->isKdeTerminal() ) if ( term_detection->isKdeTerminal() )
return 0; return FString{};
fd_set ifds{}; fd_set ifds{};
struct timeval tv{}; struct timeval tv{};
@ -851,29 +768,16 @@ const FString* FTermXTerminal::captureXTermTitle()
// Esc + \ = OSC string terminator // Esc + \ = OSC string terminator
if ( n >= 2 && temp[n - 2] == ESC[0] && temp[n - 1] == '\\' ) if ( n >= 2 && temp[n - 2] == ESC[0] && temp[n - 1] == '\\' )
{ {
FString* xtermtitle;
if ( n < 4 ) if ( n < 4 )
return 0; return FString{};
temp[n - 2] = '\0'; temp[n - 2] = '\0';
return FString{temp};
try
{
xtermtitle = new FString(temp);
}
catch (const std::bad_alloc& ex)
{
std::cerr << bad_alloc_str << ex.what() << std::endl;
return 0;
}
return xtermtitle;
} }
} }
} }
return 0; return FString{};
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -65,30 +65,28 @@ const FString FTextView::getText() const
return FString(""); return FString("");
std::size_t len{0}; std::size_t len{0};
std::size_t rows = getRows();
for (std::size_t i{0} ; i < rows; i++) for (auto&& line : data)
len += data[i].getLength() + 1; len += line.getLength() + 1; // String length + '\n'
FString s(len + 1); FString s(len); // Reserves storage
std::size_t idx{0}; auto iter = s.begin();
for (std::size_t i{0}; i < rows; i++) for (auto&& line : data)
{ {
const wchar_t* p = data[i].wc_str(); if ( ! line.isEmpty() )
if ( p )
{ {
while ( (s[idx++] = *p++) != 0 ); if ( iter != s.begin() )
s[idx - 1] = '\n'; {
*iter = '\n';
++iter;
} }
else
{ std::copy (line.begin(), line.end(), iter);
s[idx++] = '\n'; iter += std::distance(line.begin(), line.end());
} }
} }
s[idx - 1] = 0;
return s; return s;
} }
@ -297,19 +295,28 @@ void FTextView::clear()
// clear list from screen // clear list from screen
setColor(); setColor();
if ( useFDialogBorder() )
{
auto parent = getParentWidget();
static_cast<FDialog*>(parent)->redraw();
}
else
drawBorder();
std::size_t size = getWidth() - 2; std::size_t size = getWidth() - 2;
if ( size == 0 ) if ( size == 0 )
return; return;
char* blank = createBlankArray(size + 1);
for (int y{0}; y < int(getTextHeight()); y++) for (int y{0}; y < int(getTextHeight()); y++)
{ {
print() << FPoint(2, 2 - nf_offset + y) << blank; print() << FPoint(2, 2 - nf_offset + y)
<< FString(size, L' ');
} }
destroyBlankArray (blank); updateTerminal();
processChanged(); processChanged();
} }
@ -595,8 +602,8 @@ std::size_t FTextView::getTextWidth()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTextView::init() void FTextView::init()
{ {
initScrollbar (vbar, fc::vertical, &FTextView::cb_VBarChange); initScrollbar (vbar, fc::vertical, this, &FTextView::cb_VBarChange);
initScrollbar (hbar, fc::horizontal, &FTextView::cb_HBarChange); initScrollbar (hbar, fc::horizontal, this, &FTextView::cb_HBarChange);
const auto& wc = getFWidgetColors(); const auto& wc = getFWidgetColors();
setForegroundColor (wc.dialog_fg); setForegroundColor (wc.dialog_fg);
setBackgroundColor (wc.dialog_bg); setBackgroundColor (wc.dialog_bg);
@ -607,61 +614,11 @@ void FTextView::init()
setRightPadding(1 + nf_offset); setRightPadding(1 + nf_offset);
} }
//----------------------------------------------------------------------
void FTextView::initScrollbar ( FScrollbarPtr& bar
, fc::orientation o
, FTextViewCallback callback )
{
try
{
bar = std::make_shared<FScrollbar>(o, this);
}
catch (const std::bad_alloc& ex)
{
std::cerr << bad_alloc_str << ex.what() << std::endl;
return;
}
bar->setMinimum(0);
bar->setValue(0);
bar->hide();
bar->addCallback
(
"change-value",
F_METHOD_CALLBACK (this, callback)
);
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTextView::draw() void FTextView::draw()
{ {
auto parent = getParentWidget();
bool is_text_dialog;
setColor(); setColor();
if ( isMonochron() )
setReverse(true);
if ( parent
&& parent->isDialogWidget()
&& isPaddingIgnored()
&& getGeometry() == FRect ( 1
, 2
, parent->getWidth()
, parent->getHeight() - 1) )
{
is_text_dialog = true;
}
else
is_text_dialog = false;
if ( ! (is_text_dialog || isNewFont()) )
drawBorder(); drawBorder();
if ( isMonochron() )
setReverse(false);
drawScrollbars(); drawScrollbars();
drawText(); drawText();
@ -682,6 +639,21 @@ void FTextView::draw()
flush_out(); flush_out();
} }
//----------------------------------------------------------------------
void FTextView::drawBorder()
{
if ( ! useFDialogBorder() )
{
if ( isMonochron() )
setReverse(true);
FWidget::drawBorder();
if ( isMonochron() )
setReverse(false);
}
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTextView::drawScrollbars() void FTextView::drawScrollbars()
{ {
@ -740,6 +712,26 @@ void FTextView::drawText()
setReverse(false); setReverse(false);
} }
//----------------------------------------------------------------------
inline bool FTextView::useFDialogBorder()
{
auto parent = getParentWidget();
bool use_fdialog_border{false};
if ( parent
&& parent->isDialogWidget()
&& isPaddingIgnored()
&& getGeometry() == FRect ( 1
, 2
, parent->getWidth()
, parent->getHeight() - 1) )
{
use_fdialog_border = true;
}
return use_fdialog_border;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FTextView::isPrintable (wchar_t ch) inline bool FTextView::isPrintable (wchar_t ch)
{ {

View File

@ -370,25 +370,7 @@ void FToggleButton::onFocusOut (FFocusEvent* out_ev)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FToggleButton::setHotkeyAccelerator() void FToggleButton::setHotkeyAccelerator()
{ {
FKey hotkey = getHotkey(text); setHotkeyViaString (this, text);
if ( hotkey > 0xff00 && hotkey < 0xff5f ) // full-width character
hotkey -= 0xfee0;
if ( hotkey )
{
if ( std::isalpha(int(hotkey)) || std::isdigit(int(hotkey)) )
{
addAccelerator (FKey(std::tolower(int(hotkey))));
addAccelerator (FKey(std::toupper(int(hotkey))));
// Meta + hotkey
addAccelerator (fc::Fmkey_meta + FKey(std::tolower(int(hotkey))));
}
else
addAccelerator (hotkey);
}
else
delAccelerator();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -429,34 +411,14 @@ void FToggleButton::draw()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FToggleButton::drawLabel() void FToggleButton::drawLabel()
{ {
wchar_t* LabelText;
if ( text.isNull() || text.isEmpty() ) if ( text.isNull() || text.isEmpty() )
return; return;
std::size_t length = text.getLength();
try
{
LabelText = new wchar_t[length + 1]();
}
catch (const std::bad_alloc& ex)
{
std::cerr << bad_alloc_str << ex.what() << std::endl;
return;
}
FString txt(text); FString txt(text);
wchar_t* src = const_cast<wchar_t*>(txt.wc_str()); FString label_text{};
wchar_t* dest = const_cast<wchar_t*>(LabelText); auto hotkeypos = finalcut::getHotkeyPos(txt, label_text);
auto hotkeypos = finalcut::getHotkeyPos(src, dest, length);
if ( hotkeypos != NOT_SET )
length--;
print() << FPoint(1 + int(label_offset_pos), 1); print() << FPoint(1 + int(label_offset_pos), 1);
drawText (LabelText, hotkeypos, length); drawText (std::move(label_text), hotkeypos);
delete[] LabelText;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -561,9 +523,7 @@ void FToggleButton::init()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FToggleButton::drawText ( wchar_t LabelText[] void FToggleButton::drawText (FString&& label_text, std::size_t hotkeypos)
, std::size_t hotkeypos
, std::size_t length )
{ {
if ( isMonochron() ) if ( isMonochron() )
setReverse(true); setReverse(true);
@ -575,7 +535,7 @@ void FToggleButton::drawText ( wchar_t LabelText[]
else else
setColor (wc.label_inactive_fg, wc.label_inactive_bg); setColor (wc.label_inactive_fg, wc.label_inactive_bg);
for (std::size_t z{0}; z < length; z++) for (std::size_t z{0}; z < label_text.getLength(); z++)
{ {
if ( (z == hotkeypos) && flags.active ) if ( (z == hotkeypos) && flags.active )
{ {
@ -584,7 +544,7 @@ void FToggleButton::drawText ( wchar_t LabelText[]
if ( ! flags.no_underline ) if ( ! flags.no_underline )
setUnderline(); setUnderline();
print ( LabelText[z] ); print ( label_text[z] );
if ( ! flags.no_underline ) if ( ! flags.no_underline )
unsetUnderline(); unsetUnderline();
@ -592,7 +552,7 @@ void FToggleButton::drawText ( wchar_t LabelText[]
setColor (wc.label_fg, wc.label_bg); setColor (wc.label_fg, wc.label_bg);
} }
else else
print (LabelText[z]); print (label_text[z]);
} }
if ( isMonochron() ) if ( isMonochron() )

View File

@ -1746,7 +1746,7 @@ charData FVTerm::getCharacter ( character_type char_type
for (auto&& win_obj : *FWidget::getWindowList()) for (auto&& win_obj : *FWidget::getWindowList())
{ {
bool significant_char; bool significant_char{false};
// char_type can be "overlapped_character" // char_type can be "overlapped_character"
// or "covered_character" // or "covered_character"

View File

@ -1626,17 +1626,15 @@ void FWidget::hideArea (const FSize& size)
} }
setColor (fg, bg); setColor (fg, bg);
char* blank = createBlankArray(size.getWidth());
if ( blank == 0 ) if ( size.getWidth() == 0 )
return; return;
for (int y{0}; y < int(size.getHeight()); y++) for (int y{0}; y < int(size.getHeight()); y++)
{ {
print() << FPoint(1, 1 + y) << blank; print() << FPoint(1, 1 + y) << FString(size.getWidth(), L' ');
} }
destroyBlankArray (blank);
flush_out(); flush_out();
} }
@ -2258,7 +2256,6 @@ void FWidget::drawTransparentShadow (int x1, int y1, int x2, int y2)
void FWidget::drawBlockShadow (int x1, int y1, int x2, int y2) void FWidget::drawBlockShadow (int x1, int y1, int x2, int y2)
{ {
// non-transparent shadow // non-transparent shadow
wchar_t block;
if ( ! hasShadowCharacter() ) if ( ! hasShadowCharacter() )
return; return;
@ -2273,7 +2270,6 @@ void FWidget::drawBlockShadow (int x1, int y1, int x2, int y2)
else if ( auto p = getParentWidget() ) else if ( auto p = getParentWidget() )
setColor (wcolors.shadow_fg, p->getBackgroundColor()); setColor (wcolors.shadow_fg, p->getBackgroundColor());
block = fc::FullBlock; // █
print (fc::LowerHalfBlock); // ▄ print (fc::LowerHalfBlock); // ▄
if ( isWindowWidget() ) if ( isWindowWidget() )
@ -2281,7 +2277,7 @@ void FWidget::drawBlockShadow (int x1, int y1, int x2, int y2)
for (std::size_t y{1}; y < getHeight(); y++) for (std::size_t y{1}; y < getHeight(); y++)
{ {
print() << FPoint(x2 + 1, y1 + int(y)) << block; // █ print() << FPoint(x2 + 1, y1 + int(y)) << fc::FullBlock; // █
} }
print() << FPoint(x1 + 1, y2 + 1); print() << FPoint(x1 + 1, y2 + 1);
@ -2309,38 +2305,12 @@ void FWidget::setColorTheme()
// non-member functions // non-member functions
//----------------------------------------------------------------------
char* createBlankArray (std::size_t size)
{
char* blank;
if ( size == 0 )
return 0;
try
{
blank = new char[size + 1];
}
catch (const std::bad_alloc& ex)
{
std::cerr << bad_alloc_str << ex.what() << std::endl;
return 0;
}
std::memset(blank, ' ', size);
blank[size] = '\0';
return blank;
}
//----------------------------------------------------------------------
void destroyBlankArray (char blank[])
{
delete[] blank;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FKey getHotkey (const FString& text) FKey getHotkey (const FString& text)
{ {
// Returns the hotkey character from a string
// e.g. "E&xit" returns 'x'
if ( text.isEmpty() ) if ( text.isEmpty() )
return 0; return 0;
@ -2362,34 +2332,64 @@ FKey getHotkey (const FString& text)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
std::size_t getHotkeyPos (wchar_t src[], wchar_t dest[], std::size_t length) std::size_t getHotkeyPos (const FString& src, FString& dest)
{ {
// Find hotkey position in string // Find hotkey position in string
// + generate a new string without the '&'-sign // + generate a new string without the '&'-sign
const wchar_t* txt = src;
constexpr std::size_t NOT_SET = static_cast<std::size_t>(-1); constexpr std::size_t NOT_SET = static_cast<std::size_t>(-1);
std::size_t hotkeypos{NOT_SET}; std::size_t hotkeypos{NOT_SET};
std::size_t i{0};
for (std::size_t i{0}; i < length; i++) for (auto&& ch : src)
{
if ( txt[i] == L'&' && hotkeypos == NOT_SET )
{ {
if ( ch == L'&' && hotkeypos == NOT_SET && src.getLength() != i + 1 )
hotkeypos = i; hotkeypos = i;
i++; else
src++; dest += ch;
}
*dest++ = *src++; i++;
} }
return hotkeypos; return hotkeypos;
} }
//----------------------------------------------------------------------
void setHotkeyViaString (FWidget* w, const FString& text)
{
// Set hotkey accelerator via string
if ( ! w )
return;
FKey hotkey = getHotkey(text);
if ( hotkey > 0xff00 && hotkey < 0xff5f ) // full-width character
hotkey -= 0xfee0;
if ( hotkey )
{
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))));
}
else
w->addAccelerator (hotkey);
}
else
w->delAccelerator();
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void drawBox (FWidget* w, const FRect& r) inline void drawBox (FWidget* w, const FRect& r)
{ {
// Use box-drawing characters to draw a border // Use box-drawing characters to draw a border
if ( ! w )
return;
w->print() << r.getUpperLeftPos() << fc::BoxDrawingsDownAndRight; // ┌ w->print() << r.getUpperLeftPos() << fc::BoxDrawingsDownAndRight; // ┌
for (int x = r.getX1() + 1; x < r.getX2(); x++) for (int x = r.getX1() + 1; x < r.getX2(); x++)

View File

@ -149,7 +149,7 @@ class FButton : public FWidget
void drawMarginLeft(); void drawMarginLeft();
void drawMarginRight(); void drawMarginRight();
void drawTopBottomBackground(); void drawTopBottomBackground();
void drawButtonTextLine (wchar_t[]); void drawButtonTextLine (const FString&);
void draw() override; void draw() override;
void updateStatusBar(); void updateStatusBar();
void updateButtonColor(); void updateButtonColor();

View File

@ -131,7 +131,7 @@ class FButtonGroup : public FScrollView
// Methods // Methods
void init(); void init();
void drawText (wchar_t[], std::size_t, std::size_t); void drawText (const FString&, std::size_t);
void directFocus(); void directFocus();
// Callback method // Callback method

View File

@ -146,14 +146,16 @@ class FLabel : public FWidget
void draw() override; void draw() override;
void drawMultiLine(); void drawMultiLine();
void drawSingleLine(); void drawSingleLine();
void printLine ( wchar_t[], std::size_t, std::size_t void printLine (FString&&);
, std::size_t, std::size_t = 0 );
// Data members // Data members
FStringList multiline_text{}; FStringList multiline_text{};
FString text{}; FString text{};
FWidget* accel_widget{nullptr}; FWidget* accel_widget{nullptr};
fc::text_alignment alignment{fc::alignLeft}; fc::text_alignment alignment{fc::alignLeft};
std::size_t align_offset{0};
std::size_t hotkeypos{NOT_SET};
std::size_t column_width{0};
FColor emphasis_color{getFWidgetColors().label_emphasis_fg}; FColor emphasis_color{getFWidgetColors().label_emphasis_fg};
FColor ellipsis_color{getFWidgetColors().label_ellipsis_fg}; FColor ellipsis_color{getFWidgetColors().label_ellipsis_fg};
bool multiline{false}; bool multiline{false};

View File

@ -56,8 +56,10 @@ e Copyright 2014-2019 Markus Gans *
#include <memory> #include <memory>
#include <vector> #include <vector>
#include "final/fscrollbar.h"
#include "final/fwidget.h" #include "final/fwidget.h"
namespace finalcut namespace finalcut
{ {
@ -236,10 +238,6 @@ class FListBox : public FWidget
void adjustSize() override; void adjustSize() override;
private: private:
// Typedef
typedef std::shared_ptr<FScrollbar> FScrollbarPtr;
typedef void (FListBox::*FListBoxCallback)(FWidget*, FDataPtr);
// Enumeration // Enumeration
enum convert_type enum convert_type
{ {
@ -257,9 +255,6 @@ class FListBox : public FWidget
// Methods // Methods
void init(); void init();
void initScrollbar ( FScrollbarPtr&
, fc::orientation
, FListBoxCallback );
void draw() override; void draw() override;
void drawBorder() override; void drawBorder() override;
void drawScrollbars(); void drawScrollbars();

View File

@ -57,6 +57,7 @@
#include <stack> #include <stack>
#include <vector> #include <vector>
#include "final/fscrollbar.h"
#include "final/ftermbuffer.h" #include "final/ftermbuffer.h"
#include "final/fwidget.h" #include "final/fwidget.h"
@ -77,10 +78,10 @@ class FListViewItem : public FObject
public: public:
// Constructor // Constructor
FListViewItem (const FListViewItem&); // copy constructor FListViewItem (const FListViewItem&); // copy constructor
explicit FListViewItem (FObjectIterator); explicit FListViewItem (iterator);
FListViewItem ( const FStringList& FListViewItem ( const FStringList&
, FDataPtr , FDataPtr
, FObjectIterator ); , iterator );
// Destructor // Destructor
virtual ~FListViewItem(); virtual ~FListViewItem();
@ -107,8 +108,8 @@ class FListViewItem : public FObject
bool isExpand() const; bool isExpand() const;
// Methods // Methods
FObjectIterator insert (FListViewItem*); iterator insert (FListViewItem*);
FObjectIterator insert (FListViewItem*, FObjectIterator); iterator insert (FListViewItem*, iterator);
void expand(); void expand();
void collapse(); void collapse();
@ -120,7 +121,7 @@ class FListViewItem : public FObject
// Methods // Methods
template <typename Compare> template <typename Compare>
void sort (Compare); void sort (Compare);
FObjectIterator appendItem (FListViewItem*); iterator appendItem (FListViewItem*);
void replaceControlCodes(); void replaceControlCodes();
std::size_t getVisibleLines(); std::size_t getVisibleLines();
void resetVisibleLineCounter(); void resetVisibleLineCounter();
@ -128,7 +129,7 @@ class FListViewItem : public FObject
// Data members // Data members
FStringList column_list{}; FStringList column_list{};
FDataPtr data_pointer{nullptr}; FDataPtr data_pointer{nullptr};
FObjectIterator root{}; iterator root{};
std::size_t visible_lines{1}; std::size_t visible_lines{1};
bool expandable{false}; bool expandable{false};
bool is_expand{false}; bool is_expand{false};
@ -188,12 +189,12 @@ class FListViewIterator
public: public:
// Typedefs // Typedefs
typedef std::list<FObject*> FObjectList; typedef std::list<FObject*> FObjectList;
typedef FObjectList::iterator FObjectIterator; typedef FObjectList::iterator iterator;
typedef std::stack<FObjectIterator> FObjectIteratorStack; typedef std::stack<iterator> iterator_stack;
// Constructor // Constructor
FListViewIterator () = default; FListViewIterator () = default;
FListViewIterator (FObjectIterator); FListViewIterator (iterator);
// Overloaded operators // Overloaded operators
FListViewIterator& operator ++ (); // prefix FListViewIterator& operator ++ (); // prefix
@ -216,12 +217,12 @@ class FListViewIterator
private: private:
// Methods // Methods
void nextElement (FObjectIterator&); void nextElement (iterator&);
void prevElement (FObjectIterator&); void prevElement (iterator&);
// Data members // Data members
FObjectIteratorStack iter_path{}; iterator_stack iter_path{};
FObjectIterator node{}; iterator node{};
int position{0}; int position{0};
}; };
@ -251,6 +252,7 @@ inline const char* FListViewIterator::getClassName() const
inline int FListViewIterator::getPosition() const inline int FListViewIterator::getPosition() const
{ return position; } { return position; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// class FListView // class FListView
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -304,38 +306,38 @@ class FListView : public FWidget
// Methods // Methods
virtual int addColumn (const FString&, int = USE_MAX_SIZE); virtual int addColumn (const FString&, int = USE_MAX_SIZE);
void hide() override; void hide() override;
FObjectIterator insert (FListViewItem*); iterator insert (FListViewItem*);
FObjectIterator insert (FListViewItem*, FObjectIterator); iterator insert (FListViewItem*, iterator);
FObjectIterator insert ( const FStringList& iterator insert ( const FStringList&
, FDataPtr = nullptr ); , FDataPtr = nullptr );
FObjectIterator insert ( const FStringList& iterator insert ( const FStringList&
, FObjectIterator ); , iterator );
FObjectIterator insert ( const FStringList& iterator insert ( const FStringList&
, FDataPtr , FDataPtr
, FObjectIterator ); , iterator );
template <typename T> template <typename T>
FObjectIterator insert ( const std::initializer_list<T>& iterator insert ( const std::initializer_list<T>&
, FDataPtr = nullptr ); , FDataPtr = nullptr );
template <typename T> template <typename T>
FObjectIterator insert ( const std::initializer_list<T>& iterator insert ( const std::initializer_list<T>&
, FObjectIterator ); , iterator );
template <typename T> template <typename T>
FObjectIterator insert ( const std::initializer_list<T>& iterator insert ( const std::initializer_list<T>&
, FDataPtr , FDataPtr
, FObjectIterator ); , iterator );
template <typename ColT> template <typename ColT>
FObjectIterator insert ( const std::vector<ColT>& iterator insert ( const std::vector<ColT>&
, FDataPtr = nullptr ); , FDataPtr = nullptr );
template <typename ColT> template <typename ColT>
FObjectIterator insert ( const std::vector<ColT>& iterator insert ( const std::vector<ColT>&
, FObjectIterator ); , iterator );
template <typename ColT> template <typename ColT>
FObjectIterator insert ( const std::vector<ColT>& iterator insert ( const std::vector<ColT>&
, FDataPtr , FDataPtr
, FObjectIterator ); , iterator );
FObjectIterator beginOfList(); iterator beginOfList();
FObjectIterator endOfList(); iterator endOfList();
virtual void sort(); virtual void sort();
// Event handlers // Event handlers
@ -350,7 +352,7 @@ class FListView : public FWidget
void onFocusOut (FFocusEvent*) override; void onFocusOut (FFocusEvent*) override;
// Data members // Data members
static FObjectIterator null_iter; static iterator null_iter;
protected: protected:
// Methods // Methods
@ -365,8 +367,6 @@ class FListView : public FWidget
struct Header; // forward declaration struct Header; // forward declaration
typedef std::vector<Header> headerItems; typedef std::vector<Header> headerItems;
typedef std::vector<fc::sorting_type> sortTypes; typedef std::vector<fc::sorting_type> sortTypes;
typedef std::shared_ptr<FScrollbar> FScrollbarPtr;
typedef void (FListView::*FListViewCallback)(FWidget*, FDataPtr);
// Constants // Constants
static constexpr int USE_MAX_SIZE = -1; static constexpr int USE_MAX_SIZE = -1;
@ -377,9 +377,6 @@ class FListView : public FWidget
// Methods // Methods
void init(); void init();
void initScrollbar ( FScrollbarPtr&
, fc::orientation
, FListViewCallback );
template <typename Compare> template <typename Compare>
void sort (Compare); void sort (Compare);
std::size_t getAlignOffset ( fc::text_alignment std::size_t getAlignOffset ( fc::text_alignment
@ -414,7 +411,7 @@ class FListView : public FWidget
void dragUp (int); void dragUp (int);
void dragDown (int); void dragDown (int);
void stopDragScroll(); void stopDragScroll();
FObjectIterator appendItem (FListViewItem*); iterator appendItem (FListViewItem*);
void processClick(); void processClick();
void processChanged(); void processChanged();
void toggleCheckbox(); void toggleCheckbox();
@ -441,7 +438,7 @@ class FListView : public FWidget
void cb_HBarChange (FWidget*, FDataPtr); void cb_HBarChange (FWidget*, FDataPtr);
// Data members // Data members
FObjectIterator root{}; iterator root{};
FObjectList selflist{}; FObjectList selflist{};
FObjectList itemlist{}; FObjectList itemlist{};
FListViewIterator current_iter{}; FListViewIterator current_iter{};
@ -537,39 +534,39 @@ inline bool FListView::unsetTreeView()
{ return setTreeView(false); } { return setTreeView(false); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FObject::FObjectIterator FListView::insert (FListViewItem* item) inline FObject::iterator FListView::insert (FListViewItem* item)
{ return insert (item, root); } { return insert (item, root); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FObject::FObjectIterator inline FObject::iterator
FListView::insert (const FStringList& cols, FDataPtr d) FListView::insert (const FStringList& cols, FDataPtr d)
{ return insert (cols, d, root); } { return insert (cols, d, root); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FObject::FObjectIterator inline FObject::iterator
FListView::insert ( const FStringList& cols FListView::insert ( const FStringList& cols
, FObjectIterator parent_iter ) , iterator parent_iter )
{ return insert (cols, 0, parent_iter); } { return insert (cols, 0, parent_iter); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
template<typename T> template<typename T>
inline FObject::FObjectIterator inline FObject::iterator
FListView::insert (const std::initializer_list<T>& list, FDataPtr d) FListView::insert (const std::initializer_list<T>& list, FDataPtr d)
{ return insert (list, d, root); } { return insert (list, d, root); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
template<typename T> template<typename T>
inline FObject::FObjectIterator inline FObject::iterator
FListView::insert ( const std::initializer_list<T>& list FListView::insert ( const std::initializer_list<T>& list
, FObjectIterator parent_iter ) , iterator parent_iter )
{ return insert (list, 0, parent_iter); } { return insert (list, 0, parent_iter); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
template<typename T> template<typename T>
FObject::FObjectIterator FObject::iterator
FListView::insert ( const std::initializer_list<T>& list FListView::insert ( const std::initializer_list<T>& list
, FDataPtr d , FDataPtr d
, FObjectIterator parent_iter ) , iterator parent_iter )
{ {
FStringList str_cols; FStringList str_cols;
@ -589,23 +586,23 @@ FObject::FObjectIterator
//---------------------------------------------------------------------- //----------------------------------------------------------------------
template <typename ColT> template <typename ColT>
inline FObject::FObjectIterator inline FObject::iterator
FListView::insert (const std::vector<ColT>& cols, FDataPtr d) FListView::insert (const std::vector<ColT>& cols, FDataPtr d)
{ return insert (cols, d, root); } { return insert (cols, d, root); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
template <typename ColT> template <typename ColT>
inline FObject::FObjectIterator inline FObject::iterator
FListView::insert ( const std::vector<ColT>& cols FListView::insert ( const std::vector<ColT>& cols
, FObjectIterator parent_iter ) , iterator parent_iter )
{ return insert (cols, 0, parent_iter); } { return insert (cols, 0, parent_iter); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
template <typename ColT> template <typename ColT>
FObject::FObjectIterator FObject::iterator
FListView::insert ( const std::vector<ColT>& cols FListView::insert ( const std::vector<ColT>& cols
, FDataPtr d , FDataPtr d
, FObjectIterator parent_iter ) , iterator parent_iter )
{ {
FStringList str_cols; FStringList str_cols;
@ -624,11 +621,11 @@ FObject::FObjectIterator
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FObject::FObjectIterator FListView::beginOfList() inline FObject::iterator FListView::beginOfList()
{ return itemlist.begin(); } { return itemlist.begin(); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FObject::FObjectIterator FListView::endOfList() inline FObject::iterator FListView::endOfList()
{ return itemlist.end(); } { return itemlist.end(); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -147,8 +147,7 @@ class FMenu : public FWindow, public FMenuList
typedef struct typedef struct
{ {
wchar_t* text; FString text;
std::size_t length;
std::size_t hotkeypos; std::size_t hotkeypos;
bool no_underline; bool no_underline;
} menuText; } menuText;

View File

@ -112,8 +112,7 @@ class FMenuBar : public FWindow, public FMenuList
// Typedef // Typedef
typedef struct typedef struct
{ {
wchar_t* text; FString text;
std::size_t length;
std::size_t startpos; std::size_t startpos;
std::size_t hotkeypos; std::size_t hotkeypos;
bool no_underline; bool no_underline;

View File

@ -233,7 +233,7 @@ int FMessageBox::error ( FWidget* parent
mbox.beep(); mbox.beep();
mbox.setHeadline("Warning:"); mbox.setHeadline("Warning:");
mbox.setCenterText(); mbox.setCenterText();
const FWidgetColors& wc = mbox.getFWidgetColors(); const auto& wc = mbox.getFWidgetColors();
mbox.setForegroundColor(wc.error_box_fg); mbox.setForegroundColor(wc.error_box_fg);
mbox.setBackgroundColor(wc.error_box_bg); mbox.setBackgroundColor(wc.error_box_bg);
mbox.emphasis_color = wc.error_box_emphasis_fg; mbox.emphasis_color = wc.error_box_emphasis_fg;

View File

@ -73,8 +73,8 @@ class FObject
public: public:
// Typedef // Typedef
typedef std::list<FObject*> FObjectList; typedef std::list<FObject*> FObjectList;
typedef FObjectList::iterator FObjectIterator; typedef FObjectList::iterator iterator;
typedef FObjectList::const_iterator constFObjectIterator; typedef FObjectList::const_iterator const_iterator;
// Constructor // Constructor
explicit FObject (FObject* = nullptr); explicit FObject (FObject* = nullptr);
@ -95,10 +95,10 @@ class FObject
FObjectList& getChildren(); FObjectList& getChildren();
const FObjectList& getChildren() const; const FObjectList& getChildren() const;
int numOfChildren() const; int numOfChildren() const;
FObjectIterator begin(); iterator begin();
FObjectIterator end(); iterator end();
constFObjectIterator begin() const; const_iterator begin() const;
constFObjectIterator end() const; const_iterator end() const;
// Inquiries // Inquiries
bool hasParent() const; bool hasParent() const;
@ -185,19 +185,19 @@ inline int FObject::numOfChildren() const
{ return int(children_list.size()); } { return int(children_list.size()); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FObject::FObjectIterator FObject::begin() inline FObject::iterator FObject::begin()
{ return children_list.begin(); } { return children_list.begin(); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FObject::FObjectIterator FObject::end() inline FObject::iterator FObject::end()
{ return children_list.end(); } { return children_list.end(); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FObject::constFObjectIterator FObject::begin() const inline FObject::const_iterator FObject::begin() const
{ return children_list.begin(); } { return children_list.begin(); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FObject::constFObjectIterator FObject::end() const inline FObject::const_iterator FObject::end() const
{ return children_list.end(); } { return children_list.end(); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -57,6 +57,12 @@
namespace finalcut namespace finalcut
{ {
// class forward declaration
class FScrollbar;
// Global typedef
typedef std::shared_ptr<FScrollbar> FScrollbarPtr;
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// class FScrollbar // class FScrollbar
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -161,6 +167,37 @@ class FScrollbar : public FWidget
int max_color{getMaxColor()}; int max_color{getMaxColor()};
}; };
// non-member function forward declarations
//----------------------------------------------------------------------
template<typename Callback>
void initScrollbar ( FScrollbarPtr& bar
, fc::orientation o
, FWidget* cb_instance
, Callback cb_handler )
{
try
{
bar = std::make_shared<FScrollbar>(o, cb_instance);
}
catch (const std::bad_alloc& ex)
{
std::cerr << bad_alloc_str << ex.what() << std::endl;
return;
}
bar->setMinimum(0);
bar->setValue(0);
bar->hide();
bar->addCallback
(
"change-value",
F_METHOD_CALLBACK (cb_instance, cb_handler)
);
}
// FScrollbar inline functions // FScrollbar inline functions
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const char* FScrollbar::getClassName() const inline const char* FScrollbar::getClassName() const

View File

@ -153,10 +153,6 @@ class FScrollView : public FWidget
void copy2area(); void copy2area();
private: private:
// Typedef
typedef std::shared_ptr<FScrollbar> FScrollbarPtr;
typedef void (FScrollView::*FScrollViewCallback)(FWidget*, FDataPtr);
// Constants // Constants
static constexpr int vertical_border_spacing = 2; static constexpr int vertical_border_spacing = 2;
static constexpr int horizontal_border_spacing = 2; static constexpr int horizontal_border_spacing = 2;
@ -166,9 +162,10 @@ class FScrollView : public FWidget
// Methods // Methods
void init (FWidget*); void init (FWidget*);
template<typename Callback>
void initScrollbar ( FScrollbarPtr& void initScrollbar ( FScrollbarPtr&
, fc::orientation , fc::orientation
, FScrollViewCallback ); , Callback );
void calculateScrollbarPos(); void calculateScrollbarPos();
void setHorizontalScrollBarVisibility(); void setHorizontalScrollBarVisibility();
void setVerticalScrollBarVisibility(); void setVerticalScrollBarVisibility();
@ -270,6 +267,17 @@ inline void FScrollView::print (const FPoint& pos)
setPrintPos(pos); setPrintPos(pos);
} }
//----------------------------------------------------------------------
template<typename Callback>
inline void FScrollView::initScrollbar ( FScrollbarPtr& bar
, fc::orientation o
, Callback cb_handler )
{
finalcut::initScrollbar (bar, o, this, cb_handler);
term_area* area = getPrintArea();
bar->setPrintArea(area);
}
} // namespace finalcut } // namespace finalcut
#endif // FSCROLLVIEW_H #endif // FSCROLLVIEW_H

View File

@ -76,14 +76,14 @@ class FTermXTerminal final
// Accessors // Accessors
const char* getClassName() const; const char* getClassName() const;
static fc::xtermCursorStyle getCursorStyle(); static fc::xtermCursorStyle getCursorStyle();
static const FString* getFont(); static const FString getFont();
static const FString* getTitle(); static const FString getTitle();
static const FString* getForeground(); static const FString getForeground();
static const FString* getBackground(); static const FString getBackground();
static const FString* getCursorColor(); static const FString getCursorColor();
static const FString* getMouseForeground(); static const FString getMouseForeground();
static const FString* getMouseBackground(); static const FString getMouseBackground();
static const FString* getHighlightBackground(); static const FString getHighlightBackground();
// Inquiries // Inquiries
static bool hasFont(); static bool hasFont();
@ -128,8 +128,8 @@ class FTermXTerminal final
static bool canResetColor(); static bool canResetColor();
static void oscPrefix(); static void oscPrefix();
static void oscPostfix(); static void oscPostfix();
static const FString* captureXTermFont(); static const FString captureXTermFont();
static const FString* captureXTermTitle(); static const FString captureXTermTitle();
static void enableXTermMouse(); static void enableXTermMouse();
static void disableXTermMouse(); static void disableXTermMouse();
static void enableXTermMetaSendsESC(); static void enableXTermMetaSendsESC();
@ -141,14 +141,14 @@ class FTermXTerminal final
static bool xterm_default_colors; static bool xterm_default_colors;
static std::size_t term_width; static std::size_t term_width;
static std::size_t term_height; static std::size_t term_height;
static const FString* xterm_font; static FString xterm_font;
static const FString* xterm_title; static FString xterm_title;
static const FString* foreground_color; static FString foreground_color;
static const FString* background_color; static FString background_color;
static const FString* cursor_color; static FString cursor_color;
static const FString* mouse_foreground_color; static FString mouse_foreground_color;
static const FString* mouse_background_color; static FString mouse_background_color;
static const FString* highlight_background_color; static FString highlight_background_color;
static FSystem* fsystem; static FSystem* fsystem;
static FTermDetection* term_detection; static FTermDetection* term_detection;
static fc::xtermCursorStyle cursor_style; static fc::xtermCursorStyle cursor_style;
@ -169,44 +169,44 @@ inline fc::xtermCursorStyle FTermXTerminal::getCursorStyle()
{ return cursor_style; } { return cursor_style; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const FString* FTermXTerminal::getFont() inline const FString FTermXTerminal::getFont()
{ return xterm_font; } { return xterm_font; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const FString* FTermXTerminal::getTitle() inline const FString FTermXTerminal::getTitle()
{ return xterm_title; } { return xterm_title; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const FString* FTermXTerminal::getForeground() inline const FString FTermXTerminal::getForeground()
{ return foreground_color; } { return foreground_color; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const FString* FTermXTerminal::getBackground() inline const FString FTermXTerminal::getBackground()
{ return background_color; } { return background_color; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const FString* FTermXTerminal::getCursorColor() inline const FString FTermXTerminal::getCursorColor()
{ return cursor_color; } { return cursor_color; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const FString* FTermXTerminal::getMouseForeground() inline const FString FTermXTerminal::getMouseForeground()
{ return mouse_foreground_color; } { return mouse_foreground_color; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const FString* FTermXTerminal::getMouseBackground() inline const FString FTermXTerminal::getMouseBackground()
{ return mouse_background_color; } { return mouse_background_color; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const FString* FTermXTerminal::getHighlightBackground() inline const FString FTermXTerminal::getHighlightBackground()
{ return highlight_background_color; } { return highlight_background_color; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FTermXTerminal::hasFont() inline bool FTermXTerminal::hasFont()
{ return bool(xterm_font && xterm_font->getLength() > 2); } { return bool(xterm_font.getLength() > 2); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FTermXTerminal::hasTitle() inline bool FTermXTerminal::hasTitle()
{ return bool(xterm_title && xterm_title->getLength() > 0); } { return bool(xterm_title.getLength() > 0); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FTermXTerminal::setMouseSupport() inline void FTermXTerminal::setMouseSupport()

View File

@ -136,10 +136,6 @@ class FTextView : public FWidget
void adjustSize() override; void adjustSize() override;
private: private:
// Typedef
typedef std::shared_ptr<FScrollbar> FScrollbarPtr;
typedef void (FTextView::*FTextViewCallback)(FWidget*, FDataPtr);
// Accessors // Accessors
std::size_t getTextHeight(); std::size_t getTextHeight();
std::size_t getTextWidth(); std::size_t getTextWidth();
@ -150,12 +146,11 @@ class FTextView : public FWidget
// Methods // Methods
void init(); void init();
void initScrollbar ( FScrollbarPtr&
, fc::orientation
, FTextViewCallback );
void draw() override; void draw() override;
void drawBorder() override;
void drawScrollbars(); void drawScrollbars();
void drawText(); void drawText();
bool useFDialogBorder();
bool isPrintable (wchar_t); bool isPrintable (wchar_t);
void processChanged(); void processChanged();

View File

@ -151,7 +151,7 @@ class FToggleButton : public FWidget
// Methods // Methods
void init(); void init();
void drawText (wchar_t[], std::size_t , std::size_t); void drawText (FString&&, std::size_t);
// Friend classes // Friend classes
friend class FButtonGroup; friend class FButtonGroup;

View File

@ -525,10 +525,9 @@ class FWidget : public FVTerm, public FObject
// non-member function forward declarations // non-member function forward declarations
//---------------------------------------------------------------------- //----------------------------------------------------------------------
char* createBlankArray (std::size_t);
void destroyBlankArray (char[]);
FKey getHotkey (const FString&); FKey getHotkey (const FString&);
std::size_t getHotkeyPos (wchar_t[], wchar_t[], std::size_t); std::size_t getHotkeyPos (const FString& src, FString& dest);
void setHotkeyViaString (FWidget*, const FString&);
void drawBorder (FWidget*, FRect); void drawBorder (FWidget*, FRect);
// FWidget inline functions // FWidget inline functions

View File

@ -388,7 +388,7 @@ void FObjectTest::iteratorTest()
CPPUNIT_ASSERT ( child2->getParent() == obj ); CPPUNIT_ASSERT ( child2->getParent() == obj );
CPPUNIT_ASSERT ( child3->getParent() == obj ); CPPUNIT_ASSERT ( child3->getParent() == obj );
finalcut::FObject::constFObjectIterator c_iter, c_last; finalcut::FObject::const_iterator c_iter, c_last;
c_iter = obj->begin(); c_iter = obj->begin();
c_last = obj->end(); c_last = obj->end();
int i = 0; int i = 0;
@ -402,7 +402,7 @@ void FObjectTest::iteratorTest()
CPPUNIT_ASSERT ( obj->numOfChildren() == i ); CPPUNIT_ASSERT ( obj->numOfChildren() == i );
CPPUNIT_ASSERT ( i == 3 ); CPPUNIT_ASSERT ( i == 3 );
finalcut::FObject::FObjectIterator iter, last; finalcut::FObject::iterator iter, last;
iter = obj->begin(); iter = obj->begin();
last = obj->end(); last = obj->end();
i = 0; i = 0;