From 1bf4f2f906649eeedfb776d4e8485e340ea6a054 Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Fri, 3 Nov 2017 05:04:27 +0100 Subject: [PATCH] Small NewFont improvements --- README.md | 8 +++++++- examples/mouse.cpp | 32 ++++++++++++++++++++++++-------- fonts/README.md | 10 +++++----- fonts/bdf2pcf.sh | 1 + fonts/fonts.alias | 3 +++ src/fbuttongroup.cpp | 3 ++- src/flistview.cpp | 26 ++++++++++++++++---------- src/ftogglebutton.cpp | 7 +++++-- src/fvterm.cpp | 14 +++++++++++--- 9 files changed, 74 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index 3a0883b0..8f651bb9 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,8 @@ The C++ class design was inspired by the Qt framework. It provides common contro newfont ------- -A new text font for X11 and the Linux console. +A [graphical text font](fonts/) for X11 and the Linux console. + ![](doc/newfont1.png) ![](doc/newfont2.png) @@ -204,3 +205,8 @@ Class digramm └──┤ FRadioMenuItem ├---┘ └────────────────┘ + +Please send bug reports to +-------------------------- +https://github.com/gansm/finalcut/issues + diff --git a/examples/mouse.cpp b/examples/mouse.cpp index 6380a9a9..5cb81ca9 100644 --- a/examples/mouse.cpp +++ b/examples/mouse.cpp @@ -410,17 +410,33 @@ void MouseDraw::draw() int y_max = getHeight(); FDialog::draw(); setColor(); - setPrintPos (10, 2); - print (wchar_t(fc::BoxDrawingsDownAndHorizontal)); - - for (int y = 3; y < y_max; y++) + + if ( isNewFont() ) { - setPrintPos (10, y); - print (wchar_t(fc::BoxDrawingsVertical)); + for (int y = 2; y < y_max; y++) + { + setPrintPos (10, y); + print (wchar_t(fc::NF_rev_border_line_right)); + } + + setPrintPos (10, y_max); + print (wchar_t(fc::NF_rev_border_corner_lower_right)); + } + else + { + setPrintPos (10, 2); + print (wchar_t(fc::BoxDrawingsDownAndHorizontal)); + + for (int y = 3; y < y_max; y++) + { + setPrintPos (10, y); + print (wchar_t(fc::BoxDrawingsVertical)); + } + + setPrintPos (10, y_max); + print (wchar_t(fc::BoxDrawingsUpAndHorizontal)); } - setPrintPos (10, y_max); - print (wchar_t(fc::BoxDrawingsUpAndHorizontal)); drawCanvas(); } diff --git a/fonts/README.md b/fonts/README.md index 86d5b80f..386a3723 100644 --- a/fonts/README.md +++ b/fonts/README.md @@ -4,13 +4,13 @@ Simply start your program with the parameter `--newfont`. ### How can I use the new graphical font under X11? -The use of the new graphical font under X11 is only possible with +The use of the new graphical font under X11 is only possible with the terminal emulators [xterm](http://invisible-island.net/xterm/xterm.html) or -[urxvt](http://software.schmorp.de/pkg/rxvt-unicode.html), -because only these terminal emulators can change the font by -using an escape sequence. For an xterm, the "[Allow Font Ops](doc/xterm.txt)" +[urxvt](http://software.schmorp.de/pkg/rxvt-unicode.html), +because only these terminal emulators can change the font by +using an escape sequence. For an xterm, the "[Allow Font Ops](../doc/xterm.txt)" option must be set. #### Install the gzip compressed X11 pcf bitmap font 8x16graph.pcf.gz on your xserver: @@ -18,7 +18,7 @@ option must be set. 1. Create as user root the font directory
`mkdir /usr/share/fonts/X11/misc/finalcut/` -2. Copy the files 8x16graph.pcf.gz, fonts.dir and fonts.alias +2. Copy the files 8x16graph.pcf.gz, fonts.dir and fonts.alias into the just created directory
`cp 8x16graph.pcf.gz fonts.dir fonts.alias /usr/share/fonts/X11/misc/finalcut/` diff --git a/fonts/bdf2pcf.sh b/fonts/bdf2pcf.sh index f7179653..ea1ff421 100755 --- a/fonts/bdf2pcf.sh +++ b/fonts/bdf2pcf.sh @@ -1,5 +1,6 @@ #!/bin/bash +test -f 8x16graph.pcf.gz && rm 8x16graph.pcf.gz bdftopcf -o 8x16graph.pcf 8x16graph.bdf gzip -9 8x16graph.pcf diff --git a/fonts/fonts.alias b/fonts/fonts.alias index 23e67a51..3c454917 100644 --- a/fonts/fonts.alias +++ b/fonts/fonts.alias @@ -2,3 +2,6 @@ 8x16graph -misc-8x16graph-medium-r-normal--17-160-75-75-p-80-iso8859-1 -misc-8x16graph-medium-r-normal--17-160-75-75-p-80-ibm-cp437 -misc-8x16graph-medium-r-normal--17-160-75-75-p-80-iso8859-1 +!---------------------------------------- +! Note: urxvt can't load a ibm-cp437 font +!---------------------------------------- diff --git a/src/fbuttongroup.cpp b/src/fbuttongroup.cpp index 3cf48386..1b4185bd 100644 --- a/src/fbuttongroup.cpp +++ b/src/fbuttongroup.cpp @@ -71,7 +71,7 @@ FButtonGroup::~FButtonGroup() // destructor // public methods of FButtonGroup //---------------------------------------------------------------------- -FToggleButton* FButtonGroup::getButton(int index) const +FToggleButton* FButtonGroup::getButton (int index) const { constFObjectIterator iter; index--; @@ -546,6 +546,7 @@ void FButtonGroup::drawLabel() i++; src++; } + *dest++ = *src++; } diff --git a/src/flistview.cpp b/src/flistview.cpp index b979fed6..71170bc9 100644 --- a/src/flistview.cpp +++ b/src/flistview.cpp @@ -733,7 +733,7 @@ void FListView::onKeyPress (FKeyEvent* ev) case fc::Fkey_left: if ( xoffset == 0 ) { - if ( item->isExpandable() && item->isExpand() ) + if ( tree_view && item->isExpandable() && item->isExpand() ) { // Collapse element item->collapse(); @@ -784,7 +784,7 @@ void FListView::onKeyPress (FKeyEvent* ev) break; case fc::Fkey_right: - if ( item->isExpandable() && ! item->isExpand() ) + if ( tree_view && item->isExpandable() && ! item->isExpand() ) { // Expand element item->expand(); @@ -841,15 +841,21 @@ void FListView::onKeyPress (FKeyEvent* ev) break; case int('+'): - item->expand(); - adjustSize(); - ev->accept(); + if ( tree_view && item->isExpandable() && ! item->isExpand() ) + { + item->expand(); + adjustSize(); + ev->accept(); + } break; case int('-'): - item->collapse(); - adjustSize(); - ev->accept(); + if ( tree_view && item->isExpandable() && item->isExpand() ) + { + item->collapse(); + adjustSize(); + ev->accept(); + } break; default: @@ -1093,7 +1099,7 @@ void FListView::onMouseDoubleClick (FMouseEvent* ev) FListViewItem* item = getCurrentItem(); - if ( item->isExpandable() ) + if ( tree_view && item->isExpandable() ) { if ( item->isExpand() ) item->collapse(); @@ -1549,7 +1555,7 @@ void FListView::drawColumnLabels() first = h.begin() + xoffset; if ( int(h.size()) <= getClientWidth() ) - last = h.end() - 1; + last = h.end();// - 1; else { int len = getClientWidth() + xoffset - 1; diff --git a/src/ftogglebutton.cpp b/src/ftogglebutton.cpp index 9e3d4958..75ee08d4 100644 --- a/src/ftogglebutton.cpp +++ b/src/ftogglebutton.cpp @@ -89,7 +89,8 @@ void FToggleButton::setGeometry (int x, int y, int w, int h, bool adjust) { // Set the toggle button geometry - int min_width = button_width + int(text.getLength()); + int hotkey_mark = ( getHotkey() ) ? 1 : 0; + int min_width = button_width + int(text.getLength()) - hotkey_mark; if ( w < min_width ) w = min_width; @@ -199,7 +200,9 @@ bool FToggleButton::setChecked (bool on) void FToggleButton::setText (const FString& txt) { text = txt; - setWidth(button_width + int(text.getLength())); + int hotkey_mark = ( getHotkey() ) ? 1 : 0; + + setWidth(button_width + int(text.getLength()) - hotkey_mark); if ( isEnabled() ) { diff --git a/src/fvterm.cpp b/src/fvterm.cpp index a2a01f7c..6b11b1f7 100644 --- a/src/fvterm.cpp +++ b/src/fvterm.cpp @@ -2737,9 +2737,17 @@ inline void FVTerm::charsetChanges (char_data*& next_char) else if ( Encoding == fc::PC ) { next_char->attr.bit.pc_charset = true; - // Character 0x00..0x1f - if ( isXTerminal() && hasUTF8() && ch_enc < 0x20 ) - next_char->code = int(charEncode(code, fc::ASCII)); + + if ( isXTerminal() && ch_enc < 0x20 ) // Character 0x00..0x1f + { + if ( hasUTF8() ) + next_char->code = int(charEncode(code, fc::ASCII)); + else + { + next_char->code += 0x5f; + next_char->attr.bit.alt_charset = true; + } + } } } }