Reduce the number of interface parameters

This commit is contained in:
Markus Gans 2019-08-04 23:38:47 +02:00
parent aac2231898
commit 77b76b7a2a
25 changed files with 860 additions and 784 deletions

View File

@ -1,3 +1,6 @@
2019-08-04 Markus Gans <guru.mail@muenster.de>
* Reduce the number of interface parameters
2019-07-31 Markus Gans <guru.mail@muenster.de> 2019-07-31 Markus Gans <guru.mail@muenster.de>
* Unit test for the move assignment operator and move constructor * Unit test for the move assignment operator and move constructor
in FPoint, FSize and FRect in FPoint, FSize and FRect

View File

@ -144,7 +144,7 @@ void ColorChooser::draw()
if ( c == bg_color ) if ( c == bg_color )
{ {
print() << L' ' << fc::Times << L' '; print() << L' ' << wchar_t(fc::Times) << L' ';
} }
else else
print (" "); print (" ");

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2016-2018 Markus Gans * * Copyright 2016-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -111,7 +111,7 @@ void move (int xold, int yold, int xnew, int ynew)
<< std::left << std::setw(10) << to << std::left << std::setw(10) << to
<< " "; << " ";
// get the move string // get the move string
buffer = terminal->moveCursor (xold, yold, xnew, ynew); buffer = finalcut::FTerm::moveCursorString (xold, yold, xnew, ynew);
len = uInt(std::strlen(buffer)); len = uInt(std::strlen(buffer));
for (uInt i = 0; i < len; i++) for (uInt i = 0; i < len; i++)
@ -197,7 +197,8 @@ int main (int argc, char* argv[])
// Show terminal speed and milliseconds for all cursor movement sequence // Show terminal speed and milliseconds for all cursor movement sequence
std::cout << "\r" << line; std::cout << "\r" << line;
TermApp.printMoveDurations(); const finalcut::FOptiMove& opti_move = *TermApp.getFTerm().getFOptiMove();
finalcut::printDurations(opti_move);
// Waiting for keypress // Waiting for keypress
keyPressed(); keyPressed();

View File

@ -43,6 +43,7 @@ libfinal_la_SOURCES = \
ftooltip.cpp \ ftooltip.cpp \
ffiledialog.cpp \ ffiledialog.cpp \
fkey_map.cpp \ fkey_map.cpp \
fcharmap.cpp \
ftextview.cpp \ ftextview.cpp \
fstatusbar.cpp \ fstatusbar.cpp \
ftermcap.cpp \ ftermcap.cpp \
@ -87,6 +88,7 @@ finalcutinclude_HEADERS = \
include/final/ffiledialog.h \ include/final/ffiledialog.h \
include/final/final.h \ include/final/final.h \
include/final/fkey_map.h \ include/final/fkey_map.h \
include/final/fcharmap.h \
include/final/flabel.h \ include/final/flabel.h \
include/final/flineedit.h \ include/final/flineedit.h \
include/final/flistbox.h \ include/final/flistbox.h \

View File

@ -107,6 +107,7 @@ OBJS = \
ftooltip.o \ ftooltip.o \
ffiledialog.o \ ffiledialog.o \
fkey_map.o \ fkey_map.o \
fcharmap.o \
ftextview.o \ ftextview.o \
fstatusbar.o \ fstatusbar.o \
fmouse.o \ fmouse.o \

View File

@ -107,6 +107,7 @@ OBJS = \
ftooltip.o \ ftooltip.o \
ffiledialog.o \ ffiledialog.o \
fkey_map.o \ fkey_map.o \
fcharmap.o \
ftextview.o \ ftextview.o \
fstatusbar.o \ fstatusbar.o \
fmouse.o \ fmouse.o \

470
src/fcharmap.cpp Normal file
View File

@ -0,0 +1,470 @@
/***********************************************************************
* fcharmap.cpp - Character mapping and encoding *
* *
* This file is part of the Final Cut widget toolkit *
* *
* Copyright 2015-2019 Markus Gans *
* *
* The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License *
* as published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. *
* *
* The Final Cut is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this program. If not, see *
* <http://www.gnu.org/licenses/>. *
***********************************************************************/
#include "final/fc.h"
#include "final/ftypes.h"
#include "final/fcharmap.h"
namespace finalcut
{
namespace fc
{
uInt character[][fc::NUM_OF_ENCODINGS] =
{
// .--------------------- Unicode (UTF-8)
// | .--------------- VT100
// | | .--------- PC (IBM-437)
// | | | .---- ASCII (7-Bit)
// | | | |
{0x20ac, 0, 0xee, 'E'}, // € - Euro
{0x00a3, '}', 0x9c, 'P'}, // £ - Pound
{0x00a7, '$', 0x15, '$'}, // § - Section
{0x25d8, '*', 0x08, '*'}, // ◘ - InverseBullet
{0x25d9, '*', 0x0a, '*'}, // ◙ - InverseWhiteCircle
{0x203c, '!', 0x13, '!'}, // ‼ - DoubleExclamationMark
{0x2195, 'I', 0x12, 'I'}, // ↕ - UpDownArrow
{0x2194, '-', 0x1d, '-'}, // ↔ - LeftRightArrow
{0x25ac, '_', 0x16, '_'}, // ▬ - BlackRectangle
{0x2191, '^', 0x18, '^'}, // ↑ - UpwardsArrow
{0x2193, 'v', 0x19, 'v'}, // ↓ - DownwardsArrow
{0x2192, '>', 0x1a, '>'}, // → - RightwardsArrow
{0x2190, '<', 0x1b, '<'}, // ← - LeftwardsArrow
{0x03c0, '{', 0xe3, 'n'}, // π - Pi
{0x207F, 'I', 0xfc, ' '}, // ⁿ - SuperscriptLatinSmallLetterN
{0x2265, 'z', 0xf2, '>'}, // ≥ - GreaterThanOrEqualTo
{0x2264, 'y', 0xf3, '<'}, // ≤ - LessThanOrEqualTo
{0x2260, 0, 0xd8, '#'}, // ≠ - NotEqualTo
{0x00b1, 'g', 0xf1, '#'}, // ± - PlusMinus
{0x00f7, '/', 0xf6, '/'}, // ÷ - Division sign
{0x00d7, 0, 'x', 'x'}, // × - Multiplication sign
{0x02e3, '~', 0xfc, '`'}, // ˣ - Modifier letter small x
{0x00b0, 'f', 0xb0, 'o'}, // ° - Degree
{0x2022, '`', 0x04, '*'}, // • - Bullet
{0x00b7, '`', 0xfa, '.'}, // · - small Bullet
{0x25cf, '`', 0x04, '*'}, // ● - BlackCircle
{0x2666, '`', 0x04, '*'}, // ◆ - BlackDiamondSuit
{0x2424, 'h', ' ', ' '}, // ␤ - SymbolForNewline (1)
{0x240b, 'i', ' ', ' '}, // ␋ - SymbolForVerticalTab (1)
{0x2409, 'b', ' ', ' '}, // ␉ - SymbolForHorizontalTab (1)
{0x240c, 'c', ' ', ' '}, // ␌ - SymbolForFormFeed (1)
{0x240d, 'd', ' ', ' '}, // ␍ - SymbolForCarriageReturn (1)
{0x240a, 'e', ' ', ' '}, // ␊ - SymbolForLineFeed (1)
{0x2592, 'a', 0xb0, '#'}, // ▒ - MediumShade
{0x2588, '0', 0xdb, '#'}, // █ - FullBlock
{0x25ae, '_', 0xfe, '#'}, // ▮ - BlackVerticalRectangle (1)
{0x258c, 0, 0xdd, ' '}, // ▌ - LeftHalfBlock
{0x2590, 0, 0xde, ' '}, // ▐ - RightHalfBlock
{0x2584, 0, 0xdc, ' '}, // ▄ - LowerHalfBlock
{0x2580, 0, 0xdf, ' '}, // ▀ - UpperHalfBlock
{0x2500, 'q', 0xc4, '-'}, // ─ - BoxDrawingsHorizontal
{0x2502, 'x', 0xb3, '|'}, // │ - BoxDrawingsVertical
{0x250c, 'l', 0xda, '.'}, // ┌ - BoxDrawingsDownAndRight
{0x2510, 'k', 0xbf, '.'}, // ┐ - BoxDrawingsDownAndLeft
{0x2514, 'm', 0xc0, '`'}, // └ - BoxDrawingsUpAndRight
{0x2518, 'j', 0xd9, '\''}, // ┘ - BoxDrawingsUpAndLeft
{0x253c, 'n', 0xc5, '+'}, // ┼ - BoxDrawingsCross
{0x252c, 'w', 0xc2, '+'}, // ┬ - BoxDrawingsDownAndHorizontal
{0x2524, 'u', 0xb4, '+'}, // ┤ - BoxDrawingsVerticalAndLeft
{0x251c, 't', 0xc3, '+'}, // ├ - BoxDrawingsVerticalAndRight
{0x2534, 'v', 0xc1, '+'}, // ┴ - BoxDrawingsUpAndHorizontal
{0x23ba, 'o', '~', '~'}, // ⎺ - HorizontalScanLine1 (1)
{0x23bb, 'p', 0xc4, '-'}, // ⎻ - HorizontalScanLine3 (1)
{0x23bc, 'r', 0xc4, '-'}, // ⎼ - HorizontalScanLine7 (1)
{0x23bd, 's', '_', '_'}, // ⎽ - HorizontalScanLine9 (1)
{0x25b2, '-', 0x1e, '^'}, // ▲ - BlackUpPointingTriangle
{0x25bc, '.', 0x1f, 'v'}, // ▼ - BlackDownPointingTriangle
{0x25b6, '+', 0x10, '>'}, // ▶ - BlackRightPointingTriangle
{0x25c0, ',', 0x11, '<'}, // ◀ - BlackLeftPointingTriangle (1)
{0x25ba, '+', 0x10, '>'}, // ► - BlackRightPointingPointer (1)
{0x25c4, ',', 0x11, '<'}, // ◄ - BlackLeftPointingPointer
{0x1ab4, 0, 0xb4, 0}, // ⊐ - NF_rev_left_arrow2 (2)
{0x1ab5, 0, 0xb5, 0}, // ► - NF_rev_right_arrow2 (2)
{0x1ab7, 0, 0xb7, 0}, // ) - NF_radio_button3 (2)
{0x1ab8, 0, 0xb8, 0}, // ⎤ - NF_rev_border_corner_upper_right (2)
{0x1ab9, 0, 0xb9, 0}, // ⎹ - NF_rev_border_line_right (2)
{0x1aba, 0, 0xba, 0}, // ┤ - NF_rev_border_line_vertical_left (2)
{0x1abb, 0, 0xbb, 0}, // ⎦ - NF_rev_border_corner_lower_right (2)
{0x1abc, 0, 0xbc, 0}, // ⎸ - NF_border_line_left (2)
{0x1abd, 0, 0xbd, 0}, //⎹◣ - NF_rev_up_arrow2 (2)
{0x1abe, 0, 0xbe, 0}, //⎹◤ - NF_rev_down_arrow2 (2)
{0x1ac0, 0, 0xc0, 0}, // └ - NF_border_corner_middle_lower_left (2)
{0x1ac1, 0, 0xc1, 0}, // ◢⎸ - NF_rev_up_arrow1 (2)
{0x1ac2, 0, 0xc2, 0}, // ◥⎸ - NF_rev_down_arrow1 (2)
{0x1ac3, 0, 0xc3, 0}, // ├ - NF_border_line_vertical_right (2)
{0x1ac5, 0, 0xc5, 0}, // = - NF_border_line_up_and_down (2)
{0x1ac6, 0, 0xc6, 0}, // = - NF_shadow_box_middle (2)
{0x1ac7, 0, 0xc7, 0}, // = - NF_shadow_box_hdd (2)
{0x1ac8, 0, 0xc8, 0}, // ◄ - NF_rev_left_arrow1 (2)
{0x1ac9, 0, 0xc9, 0}, // ⊏ - NF_rev_right_arrow1 (2)
{0x1aca, 0, 0xca, 0}, // [ - NF_rev_menu_button1 (2)
{0x1acb, 0, 0xcb, 0}, // - - NF_rev_menu_button2 (2)
{0x1acc, 0, 0xcc, 0}, // ┌ - NF_border_corner_middle_upper_left (2)
{0x1acd, 0, 0xcd, 0}, // = - NF_shadow_box_cd (2)
{0x1ace, 0, 0xce, 0}, // [ - NF_shadow_box_left (2)
{0x1acf, 0, 0xcf, 0}, // ┘ - NF_border_corner_middle_lower_right (2)
{0x1ad0, 0, 0xd0, 0}, // ┐ - NF_border_corner_middle_upper_right (2)
{0x1ad1, 0, 0xd1, 0}, // = - NF_shadow_box_net (2)
{0x1ad2, 0, 0xd2, 0}, // ◢ - NF_rev_up_pointing_triangle1 (2)
{0x1ad3, 0, 0xd3, 0}, // ⎣ - NF_border_corner_lower_left (2)
{0x1ad4, 0, 0xd4, 0}, // _ - NF_border_line_bottom (2)
{0x1ad5, 0, 0xd5, 0}, // O - NF_radio_button2 (2)
{0x1ad6, 0, 0xd6, 0}, // ● - NF_radio_button2_checked (2)
{0x1ad7, 0, 0xd7, 0}, // ◥ - NF_rev_down_pointing_triangle1 (2)
{0x1ad8, 0, 0xd8, 0}, // ¯ - NF_border_line_upper (2)
{0x1ad9, 0, 0xd9, 0}, // ( - NF_radio_button1 (2)
{0x1ada, 0, 0xda, 0}, // ⎡ - NF_border_corner_upper_left (2)
{0x1adc, 0, 0xdc, 0}, // ✓ - NF_shadow_box_checked (2)
{0x1ae7, 0, 0xe7, 0}, // ║ - NF_rev_border_line_right_and_left (2)
{0x1ae8, 0, 0xe8, 0}, // ◣ - NF_rev_up_pointing_triangle2 (2)
{0x1ae9, 0, 0xe9, 0}, // ◤ - NF_rev_down_pointing_triangle2 (2)
{0x1af4, 0, 0xf4, 0}, // ] - NF_rev_menu_button3 (2)
{0x1af5, 0, 0xf5, 0}, // ] - NF_shadow_box_right (2)
{0x1afb, 0, 0xfb, 0}, // ✓ - NF_check_mark (2)
{0x221a, 0, 0xfb, 'x'}, // √ - square root
{0x25cf, '`', 0x04, '*'} // ● - black circle
};
/*
* (1) Not defined in Windows Glyph List 4 (WGL4)
* (2) Only supported in use with newfont
*/
const std::size_t lastCharItem = \
std::size_t((sizeof(character) / sizeof(character[0])) - 1);
int vt100_key_to_utf8[][2] =
{
{fc::vt100_key_rarrow , fc::BlackRightPointingPointer}, // ►
{fc::vt100_key_larrow , fc::BlackLeftPointingPointer}, // ◄
{fc::vt100_key_uarrow , fc::BlackUpPointingTriangle}, // ▲
{fc::vt100_key_darrow , fc::BlackDownPointingTriangle}, // ▼
{fc::vt100_key_block , fc::FullBlock}, // █
{fc::vt100_key_nsup , fc::SuperscriptLatinSmallLetterN}, // ⁿ
{fc::vt100_key_blackrect, fc::BlackVerticalRectangle}, // ▮
{fc::vt100_key_diamond , fc::BlackDiamondSuit}, // ◆
{fc::vt100_key_ckboard , fc::MediumShade}, // ▒
{fc::vt100_key_htab , fc::SymbolForHorizontalTab}, // ␉
{fc::vt100_key_ff , fc::SymbolForFormFeed}, // ␌
{fc::vt100_key_cr , fc::SymbolForCarriageReturn}, // ␍
{fc::vt100_key_lf , fc::SymbolForLineFeed}, // ␊
{fc::vt100_key_degree , fc::Degree}, // °
{fc::vt100_key_plminus , fc::PlusMinus}, // ±
{fc::vt100_key_board , fc::SymbolForNewline}, // ␤
{fc::vt100_key_lantern , fc::SymbolForVerticalTab}, // ␋
{fc::vt100_key_lrcorner , fc::BoxDrawingsUpAndLeft}, // ┘
{fc::vt100_key_urcorner , fc::BoxDrawingsDownAndLeft}, // ┐
{fc::vt100_key_ulcorner , fc::BoxDrawingsDownAndRight}, // ┌
{fc::vt100_key_llcorner , fc::BoxDrawingsUpAndRight}, // └
{fc::vt100_key_plus , fc::BoxDrawingsCross}, // ┼
{fc::vt100_key_s1 , fc::HorizontalScanLine1}, // ⎺
{fc::vt100_key_s3 , fc::HorizontalScanLine3}, // ⎻
{fc::vt100_key_hline , fc::BoxDrawingsHorizontal}, // ─
{fc::vt100_key_s7 , fc::HorizontalScanLine7}, // ⎼
{fc::vt100_key_s9 , fc::HorizontalScanLine9}, // ⎽
{fc::vt100_key_ltee , fc::BoxDrawingsVerticalAndRight}, // ├
{fc::vt100_key_rtee , fc::BoxDrawingsVerticalAndLeft}, // ┤
{fc::vt100_key_btee , fc::BoxDrawingsUpAndHorizontal}, // ┴
{fc::vt100_key_ttee , fc::BoxDrawingsDownAndHorizontal}, // ┬
{fc::vt100_key_vline , fc::BoxDrawingsVertical}, // │
{fc::vt100_key_lequal , fc::LessThanOrEqualTo}, // ≤
{fc::vt100_key_gequal , fc::GreaterThanOrEqualTo}, // ≥
{fc::vt100_key_pi , fc::Pi}, // π
{fc::vt100_key_nequal , fc::NotEqualTo}, // ≠
{fc::vt100_key_sterling , fc::Pound}, // £
{fc::vt100_key_bullet , fc::SmallBullet}, // ·
{fc::vt100_key_diamond , fc::Bullet} // ◆
};
const std::size_t lastKeyItem = \
std::size_t((sizeof(vt100_key_to_utf8) / sizeof(vt100_key_to_utf8[0])) - 1);
wchar_t cp437_to_ucs[][2] =
{
{0x00, 0x0000}, // null
{0x01, 0x263a}, // white smiling face
{0x02, 0x263b}, // black smiling face
{0x03, 0x2665}, // black heart suit
{0x04, 0x2666}, // black diamond suit
{0x05, 0x2663}, // black club suit
{0x06, 0x2660}, // black spade suit
{0x07, 0x2022}, // bullet
{0x08, 0x25d8}, // inverse bullet
{0x09, 0x25cb}, // white circle
{0x0a, 0x25d9}, // inverse white circle
{0x0b, 0x2642}, // male sign
{0x0c, 0x2640}, // female sign
{0x0d, 0x266a}, // eighth note
{0x0e, 0x266b}, // beamed eighth notes
{0x0f, 0x263c}, // white sun with rays
{0x10, 0x25ba}, // black right-pointing pointer
{0x11, 0x25c4}, // black left-pointing pointer
{0x12, 0x2195}, // up down arrow
{0x13, 0x203c}, // double exclamation mark
{0x14, 0x00b6}, // pilcrow sign
{0x15, 0x00a7}, // section sign
{0x16, 0x25ac}, // black rectangle
{0x17, 0x21a8}, // up down arrow with base
{0x18, 0x2191}, // upwards arrow
{0x19, 0x2193}, // downwards arrow
{0x1a, 0x2192}, // rightwards arrow
{0x1b, 0x2190}, // leftwards arrow
{0x1c, 0x221f}, // right angle
{0x1d, 0x2194}, // left right arrow
{0x1e, 0x25b2}, // black up-pointing triangle
{0x1f, 0x25bc}, // black down-pointing triangle
{0x20, 0x0020}, // space
{0x21, 0x0021}, // exclamation mark
{0x22, 0x0022}, // quotation mark
{0x23, 0x0023}, // number sign
{0x24, 0x0024}, // dollar sign
{0x25, 0x0025}, // percent sign
{0x26, 0x0026}, // ampersand
{0x27, 0x0027}, // apostrophe
{0x28, 0x0028}, // left parenthesis
{0x29, 0x0029}, // right parenthesis
{0x2a, 0x002a}, // asterisk
{0x2b, 0x002b}, // plus sign
{0x2c, 0x002c}, // comma
{0x2d, 0x002d}, // hyphen-minus
{0x2e, 0x002e}, // full stop
{0x2f, 0x002f}, // solidus
{0x30, 0x0030}, // digit zero
{0x31, 0x0031}, // digit one
{0x32, 0x0032}, // digit two
{0x33, 0x0033}, // digit three
{0x34, 0x0034}, // digit four
{0x35, 0x0035}, // digit five
{0x36, 0x0036}, // digit six
{0x37, 0x0037}, // digit seven
{0x38, 0x0038}, // digit eight
{0x39, 0x0039}, // digit nine
{0x3a, 0x003a}, // colon
{0x3b, 0x003b}, // semicolon
{0x3c, 0x003c}, // less-than sign
{0x3d, 0x003d}, // equals sign
{0x3e, 0x003e}, // greater-than sign
{0x3f, 0x003f}, // question mark
{0x40, 0x0040}, // commercial at
{0x41, 0x0041}, // latin capital letter a
{0x42, 0x0042}, // latin capital letter b
{0x43, 0x0043}, // latin capital letter c
{0x44, 0x0044}, // latin capital letter d
{0x45, 0x0045}, // latin capital letter e
{0x46, 0x0046}, // latin capital letter f
{0x47, 0x0047}, // latin capital letter g
{0x48, 0x0048}, // latin capital letter h
{0x49, 0x0049}, // latin capital letter i
{0x4a, 0x004a}, // latin capital letter j
{0x4b, 0x004b}, // latin capital letter k
{0x4c, 0x004c}, // latin capital letter l
{0x4d, 0x004d}, // latin capital letter m
{0x4e, 0x004e}, // latin capital letter n
{0x4f, 0x004f}, // latin capital letter o
{0x50, 0x0050}, // latin capital letter p
{0x51, 0x0051}, // latin capital letter q
{0x52, 0x0052}, // latin capital letter r
{0x53, 0x0053}, // latin capital letter s
{0x54, 0x0054}, // latin capital letter t
{0x55, 0x0055}, // latin capital letter u
{0x56, 0x0056}, // latin capital letter v
{0x57, 0x0057}, // latin capital letter w
{0x58, 0x0058}, // latin capital letter x
{0x59, 0x0059}, // latin capital letter y
{0x5a, 0x005a}, // latin capital letter z
{0x5b, 0x005b}, // left square bracket
{0x5c, 0x005c}, // reverse solidus
{0x5d, 0x005d}, // right square bracket
{0x5e, 0x005e}, // circumflex accent
{0x5f, 0x005f}, // low line
{0x60, 0x0060}, // grave accent
{0x61, 0x0061}, // latin small letter a
{0x62, 0x0062}, // latin small letter b
{0x63, 0x0063}, // latin small letter c
{0x64, 0x0064}, // latin small letter d
{0x65, 0x0065}, // latin small letter e
{0x66, 0x0066}, // latin small letter f
{0x67, 0x0067}, // latin small letter g
{0x68, 0x0068}, // latin small letter h
{0x69, 0x0069}, // latin small letter i
{0x6a, 0x006a}, // latin small letter j
{0x6b, 0x006b}, // latin small letter k
{0x6c, 0x006c}, // latin small letter l
{0x6d, 0x006d}, // latin small letter m
{0x6e, 0x006e}, // latin small letter n
{0x6f, 0x006f}, // latin small letter o
{0x70, 0x0070}, // latin small letter p
{0x71, 0x0071}, // latin small letter q
{0x72, 0x0072}, // latin small letter r
{0x73, 0x0073}, // latin small letter s
{0x74, 0x0074}, // latin small letter t
{0x75, 0x0075}, // latin small letter u
{0x76, 0x0076}, // latin small letter v
{0x77, 0x0077}, // latin small letter w
{0x78, 0x0078}, // latin small letter x
{0x79, 0x0079}, // latin small letter y
{0x7a, 0x007a}, // latin small letter z
{0x7b, 0x007b}, // left curly bracket
{0x7c, 0x007c}, // vertical line
{0x7d, 0x007d}, // right curly bracket
{0x7e, 0x007e}, // tilde
{0x7f, 0x007f}, // house
{0x80, 0x00c7}, // latin capital letter c with cedilla
{0x81, 0x00fc}, // latin small letter u with diaeresis
{0x82, 0x00e9}, // latin small letter e with acute
{0x83, 0x00e2}, // latin small letter a with circumflex
{0x84, 0x00e4}, // latin small letter a with diaeresis
{0x85, 0x00e0}, // latin small letter a with grave
{0x86, 0x00e5}, // latin small letter a with ring above
{0x87, 0x00e7}, // latin small letter c with cedilla
{0x88, 0x00ea}, // latin small letter e with circumflex
{0x89, 0x00eb}, // latin small letter e with diaeresis
{0x8a, 0x00e8}, // latin small letter e with grave
{0x8b, 0x00ef}, // latin small letter i with diaeresis
{0x8c, 0x00ee}, // latin small letter i with circumflex
{0x8d, 0x00ec}, // latin small letter i with grave
{0x8e, 0x00c4}, // latin capital letter a with diaeresis
{0x8f, 0x00c5}, // latin capital letter a with ring above
{0x90, 0x00c9}, // latin capital letter e with acute
{0x91, 0x00e6}, // latin small ligature ae
{0x92, 0x00c6}, // latin capital ligature ae
{0x93, 0x00f4}, // latin small letter o with circumflex
{0x94, 0x00f6}, // latin small letter o with diaeresis
{0x95, 0x00f2}, // latin small letter o with grave
{0x96, 0x00fb}, // latin small letter u with circumflex
{0x97, 0x00f9}, // latin small letter u with grave
{0x98, 0x00ff}, // latin small letter y with diaeresis
{0x99, 0x00d6}, // latin capital letter o with diaeresis
{0x9a, 0x00dc}, // latin capital letter u with diaeresis
{0x9b, 0x00a2}, // cent sign
{0x9c, 0x00a3}, // pound sign
{0x9d, 0x00a5}, // yen sign
{0x9e, 0x20a7}, // peseta sign
{0x9f, 0x0192}, // latin small letter f with hook
{0xa0, 0x00e1}, // latin small letter a with acute
{0xa1, 0x00ed}, // latin small letter i with acute
{0xa2, 0x00f3}, // latin small letter o with acute
{0xa3, 0x00fa}, // latin small letter u with acute
{0xa4, 0x00f1}, // latin small letter n with tilde
{0xa5, 0x00d1}, // latin capital letter n with tilde
{0xa6, 0x00aa}, // feminine ordinal indicator
{0xa7, 0x00ba}, // masculine ordinal indicator
{0xa8, 0x00bf}, // inverted question mark
{0xa9, 0x2310}, // reversed not sign
{0xaa, 0x00ac}, // not sign
{0xab, 0x00bd}, // vulgar fraction one half
{0xac, 0x00bc}, // vulgar fraction one quarter
{0xad, 0x00a1}, // inverted exclamation mark
{0xae, 0x00ab}, // left-pointing double angle quotation mark
{0xaf, 0x00bb}, // right-pointing double angle quotation mark
{0xb0, 0x2591}, // light shade
{0xb1, 0x2592}, // medium shade
{0xb2, 0x2593}, // dark shade
{0xb3, 0x2502}, // box drawings light vertical
{0xb4, 0x2524}, // box drawings light vertical and left
{0xb5, 0x2561}, // box drawings vertical single and left double
{0xb6, 0x2562}, // box drawings vertical double and left single
{0xb7, 0x2556}, // box drawings down double and left single
{0xb8, 0x2555}, // box drawings down single and left double
{0xb9, 0x2563}, // box drawings double vertical and left
{0xba, 0x2551}, // box drawings double vertical
{0xbb, 0x2557}, // box drawings double down and left
{0xbc, 0x255d}, // box drawings double up and left
{0xbd, 0x255c}, // box drawings up double and left single
{0xbe, 0x255b}, // box drawings up single and left double
{0xbf, 0x2510}, // box drawings light down and left
{0xc0, 0x2514}, // box drawings light up and right
{0xc1, 0x2534}, // box drawings light up and horizontal
{0xc2, 0x252c}, // box drawings light down and horizontal
{0xc3, 0x251c}, // box drawings light vertical and right
{0xc4, 0x2500}, // box drawings light horizontal
{0xc5, 0x253c}, // box drawings light vertical and horizontal
{0xc6, 0x255e}, // box drawings vertical single and right double
{0xc7, 0x255f}, // box drawings vertical double and right single
{0xc8, 0x255a}, // box drawings double up and right
{0xc9, 0x2554}, // box drawings double down and right
{0xca, 0x2569}, // box drawings double up and horizontal
{0xcb, 0x2566}, // box drawings double down and horizontal
{0xcc, 0x2560}, // box drawings double vertical and right
{0xcd, 0x2550}, // box drawings double horizontal
{0xce, 0x256c}, // box drawings double vertical and horizontal
{0xcf, 0x2567}, // box drawings up single and horizontal double
{0xd0, 0x2568}, // box drawings up double and horizontal single
{0xd1, 0x2564}, // box drawings down single and horizontal double
{0xd2, 0x2565}, // box drawings down double and horizontal single
{0xd3, 0x2559}, // box drawings up double and right single
{0xd4, 0x2558}, // box drawings up single and right double
{0xd5, 0x2552}, // box drawings down single and right double
{0xd6, 0x2553}, // box drawings down double and right single
{0xd7, 0x256b}, // box drawings vertical double and horizontal single
{0xd8, 0x256a}, // box drawings vertical single and horizontal double
{0xd9, 0x2518}, // box drawings light up and left
{0xda, 0x250c}, // box drawings light down and right
{0xdb, 0x2588}, // full block
{0xdc, 0x2584}, // lower half block
{0xdd, 0x258c}, // left half block
{0xde, 0x2590}, // right half block
{0xdf, 0x2580}, // upper half block
{0xe0, 0x03b1}, // greek small letter alpha
{0xe1, 0x00df}, // latin small letter sharp s
{0xe2, 0x0393}, // greek capital letter gamma
{0xe3, 0x03c0}, // greek small letter pi
{0xe4, 0x03a3}, // greek capital letter sigma
{0xe5, 0x03c3}, // greek small letter sigma
{0xe6, 0x00b5}, // micro sign
{0xe7, 0x03c4}, // greek small letter tau
{0xe8, 0x03a6}, // greek capital letter phi
{0xe9, 0x0398}, // greek capital letter theta
{0xea, 0x03a9}, // greek capital letter omega
{0xeb, 0x03b4}, // greek small letter delta
{0xec, 0x221e}, // infinity
{0xed, 0x03c6}, // greek small letter phi
{0xee, 0x03b5}, // greek small letter epsilon
{0xef, 0x2229}, // intersection
{0xf0, 0x2261}, // identical to
{0xf1, 0x00b1}, // plus-minus sign
{0xf2, 0x2265}, // greater-than or equal to
{0xf3, 0x2264}, // less-than or equal to
{0xf4, 0x2320}, // top half integral
{0xf5, 0x2321}, // bottom half integral
{0xf6, 0x00f7}, // division sign
{0xf7, 0x2248}, // almost equal to
{0xf8, 0x00b0}, // degree sign
{0xf9, 0x2219}, // bullet operator
{0xfa, 0x00b7}, // middle dot
{0xfb, 0x221a}, // square root
{0xfc, 0x207f}, // superscript latin small letter n
{0xfd, 0x00b2}, // superscript two
{0xfe, 0x25a0}, // black square
{0xff, 0x00a0} // no-break space
};
const std::size_t lastCP437Item = \
std::size_t((sizeof(cp437_to_ucs) / sizeof(cp437_to_ucs[0])) - 1);
} // namespace fc
} // namespace finalcut

View File

@ -22,6 +22,7 @@
#include "final/fc.h" #include "final/fc.h"
#include "final/fkey_map.h" #include "final/fkey_map.h"
#include "final/ftypes.h"
namespace finalcut namespace finalcut
{ {

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2015-2018 Markus Gans * * Copyright 2015-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -1100,4 +1100,46 @@ void FOptiMove::moveByMethod ( int method
} }
} }
// FOptiMove non-member function
//----------------------------------------------------------------------
void printDurations (const FOptiMove& om)
{
std::cout << " speed: "
<< om.baudrate << " baud\r\n";
std::cout << " char_duration: "
<< om.char_duration << " ms\r\n";
std::cout << " cursor_home: "
<< om.F_cursor_home.duration << " ms\r\n";
std::cout << " cursor_to_ll: "
<< om.F_cursor_to_ll.duration << " ms\r\n";
std::cout << " carriage_return: "
<< om.F_carriage_return.duration << " ms\r\n";
std::cout << " tab: "
<< om.F_tab.duration << " ms\r\n";
std::cout << " back_tab: "
<< om.F_back_tab.duration << " ms\r\n";
std::cout << " cursor_up: "
<< om.F_cursor_up.duration << " ms\r\n";
std::cout << " cursor_down: "
<< om.F_cursor_down.duration << " ms\r\n";
std::cout << " cursor_left: "
<< om.F_cursor_left.duration << " ms\r\n";
std::cout << " cursor_right: "
<< om.F_cursor_right.duration << " ms\r\n";
std::cout << " cursor_address: "
<< om.F_cursor_address.duration << " ms\r\n";
std::cout << " column_address: "
<< om.F_column_address.duration << " ms\r\n";
std::cout << " row_address: "
<< om.F_row_address.duration << " ms\r\n";
std::cout << " parm_up_cursor: "
<< om.F_parm_up_cursor.duration << " ms\r\n";
std::cout << " parm_down_cursor: "
<< om.F_parm_down_cursor.duration << " ms\r\n";
std::cout << " parm_left_cursor: "
<< om.F_parm_left_cursor.duration << " ms\r\n";
std::cout << "parm_right_cursor: "
<< om.F_parm_right_cursor.duration << " ms\r\n";
}
} // namespace finalcut } // namespace finalcut

View File

@ -559,7 +559,7 @@ bool FTerm::isNewFont()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FTerm::isCursorHideable() bool FTerm::isCursorHideable()
{ {
const char* cursor_off_str = disableCursor(); const char* cursor_off_str = disableCursorString();
if ( cursor_off_str && std::strlen(cursor_off_str) > 0 ) if ( cursor_off_str && std::strlen(cursor_off_str) > 0 )
return true; return true;
@ -773,7 +773,7 @@ bool FTerm::setOldFont()
#if defined(__linux__) #if defined(__linux__)
else if ( isLinuxTerm() ) else if ( isLinuxTerm() )
{ {
retval = linux->loadOldFont(fc::character); retval = linux->loadOldFont();
} }
#endif // defined(__linux__) #endif // defined(__linux__)
@ -848,7 +848,7 @@ int FTerm::closeConsole()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
char* FTerm::moveCursor (int xold, int yold, int xnew, int ynew) char* FTerm::moveCursorString (int xold, int yold, int xnew, int ynew)
{ {
// Returns the cursor move string // Returns the cursor move string
@ -859,7 +859,7 @@ char* FTerm::moveCursor (int xold, int yold, int xnew, int ynew)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
char* FTerm::cursorsVisibility (bool enable) char* FTerm::cursorsVisibilityString (bool enable)
{ {
// Hides or shows the input cursor on the terminal // Hides or shows the input cursor on the terminal
@ -870,14 +870,14 @@ char* FTerm::cursorsVisibility (bool enable)
if ( enable ) if ( enable )
{ {
visibility_str = disableCursor(); visibility_str = disableCursorString();
if ( visibility_str ) if ( visibility_str )
data->setCursorHidden (true); // Global state data->setCursorHidden (true); // Global state
} }
else else
{ {
visibility_str = enableCursor(); visibility_str = enableCursorString();
if ( visibility_str ) if ( visibility_str )
data->setCursorHidden (false); // Global state data->setCursorHidden (false); // Global state
@ -886,62 +886,6 @@ char* FTerm::cursorsVisibility (bool enable)
return visibility_str; return visibility_str;
} }
//----------------------------------------------------------------------
void FTerm::printMoveDurations()
{
finalcut::printDurations(*opti_move);
}
//----------------------------------------------------------------------
char* FTerm::enableCursor()
{
// Returns the cursor enable string
static constexpr std::size_t SIZE = 32;
static char enable_str[SIZE] = { };
const auto& vs = TCAP(fc::t_cursor_visible);
const auto& ve = TCAP(fc::t_cursor_normal);
if ( ve )
std::strncpy (enable_str, ve, SIZE - 1);
else if ( vs )
std::strncpy (enable_str, vs, SIZE - 1);
#if defined(__linux__)
if ( isLinuxTerm() )
{
// Restore the last used Linux console cursor style
const char* cstyle = linux->restoreCursorStyle();
std::strncat (enable_str, cstyle, SIZE - std::strlen(enable_str) - 1);
}
#endif // defined(__linux__)
enable_str[SIZE - 1] = '\0';
#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST)
if ( isFreeBSDTerm() )
{
// Restore the last used FreeBSD console cursor style
freebsd->restoreCursorStyle();
}
#endif // defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST)
return enable_str;
}
//----------------------------------------------------------------------
char* FTerm::disableCursor()
{
// Returns the cursor disable string
const auto& vi = TCAP(fc::t_cursor_invisible);
if ( vi )
return vi;
return 0;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTerm::detectTermSize() void FTerm::detectTermSize()
{ {
@ -1359,9 +1303,9 @@ void FTerm::initScreenSettings()
#if defined(__linux__) #if defined(__linux__)
// Important: Do not use setNewFont() or setVGAFont() after // Important: Do not use setNewFont() or setVGAFont() after
// the console character mapping has been initialized // the console character mapping has been initialized
linux->initCharMap (fc::character); linux->initCharMap();
#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST) #elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST)
freebsd->initCharMap (fc::character); freebsd->initCharMap();
#endif #endif
// set xterm underline cursor // set xterm underline cursor
@ -2008,13 +1952,9 @@ void FTerm::setInsertCursorStyle()
setKDECursor(fc::UnderlineCursor); setKDECursor(fc::UnderlineCursor);
#if defined(__linux__) #if defined(__linux__)
const char* cstyle = linux->setCursorStyle ( fc::underscore_cursor linux->setCursorStyle (fc::underscore_cursor);
, data->isCursorHidden() );
putstring (cstyle);
std::fflush(stdout);
#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST) #elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST)
freebsd->setCursorStyle ( fc::destructive_cursor freebsd->setCursorStyle (fc::destructive_cursor);
, data->isCursorHidden() );
#endif #endif
if ( isUrxvtTerminal() ) if ( isUrxvtTerminal() )
@ -2028,19 +1968,65 @@ void FTerm::setOverwriteCursorStyle()
setKDECursor(fc::BlockCursor); setKDECursor(fc::BlockCursor);
#if defined(__linux__) #if defined(__linux__)
char* cstyle = linux->setCursorStyle ( fc::full_block_cursor linux->setCursorStyle (fc::full_block_cursor);
, data->isCursorHidden() );
putstring (cstyle);
std::fflush(stdout);
#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST) #elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST)
freebsd->setCursorStyle ( fc::normal_cursor freebsd->setCursorStyle (fc::normal_cursor);
, data->isCursorHidden() );
#endif #endif
if ( isUrxvtTerminal() ) if ( isUrxvtTerminal() )
xterm->setCursorColor ("rgb:eeee/0000/0000"); xterm->setCursorColor ("rgb:eeee/0000/0000");
} }
//----------------------------------------------------------------------
char* FTerm::enableCursorString()
{
// Returns the cursor enable string
static constexpr std::size_t SIZE = 32;
static char enable_str[SIZE] = { };
const auto& vs = TCAP(fc::t_cursor_visible);
const auto& ve = TCAP(fc::t_cursor_normal);
if ( ve )
std::strncpy (enable_str, ve, SIZE - 1);
else if ( vs )
std::strncpy (enable_str, vs, SIZE - 1);
#if defined(__linux__)
if ( isLinuxTerm() )
{
// Restore the last used Linux console cursor style
const char* cstyle = linux->getCursorStyleString();
std::strncat (enable_str, cstyle, SIZE - std::strlen(enable_str) - 1);
}
#endif // defined(__linux__)
enable_str[SIZE - 1] = '\0';
#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST)
if ( isFreeBSDTerm() )
{
// Restore the last used FreeBSD console cursor style
freebsd->setCursorStyle (freebsd->getCursorStyle());
}
#endif // defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST)
return enable_str;
}
//----------------------------------------------------------------------
char* FTerm::disableCursorString()
{
// Returns the cursor disable string
const auto& vi = TCAP(fc::t_cursor_invisible);
if ( vi )
return vi;
return 0;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTerm::enableMouse() void FTerm::enableMouse()
{ {
@ -2187,34 +2173,27 @@ void FTerm::useNormalScreenBuffer()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FTerm::allocationValues() inline void FTerm::allocationValues()
{ {
try getFTermData();
{ getFSystem();
data = new FTermData(); getFOptiMove();
fsys = new FSystemImpl; getFOptiAttr();
opti_move = new FOptiMove(); getFTermDetection();
opti_attr = new FOptiAttr(); getFTermXTerminal();
term_detection = new FTermDetection(); getFKeyboard();
xterm = new FTermXTerminal(); getFMouseControl();
keyboard = new FKeyboard();
mouse = new FMouseControl();
#if defined(__linux__) #if defined(__linux__)
linux = new FTermLinux(); getFTermLinux();
#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST) #elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST)
freebsd = new FTermFreeBSD(); getFTermFreeBSD();
#elif defined(__NetBSD__) || defined(__OpenBSD__) || defined(UNIT_TEST) #elif defined(__NetBSD__) || defined(__OpenBSD__) || defined(UNIT_TEST)
openbsd = new FTermOpenBSD(); getFTermOpenBSD();
#endif #endif
#if DEBUG #if DEBUG
debug_data = new FTermDebugData(); getFTermDebugData();
#endif #endif
}
catch (const std::bad_alloc& ex)
{
std::cerr << bad_alloc_str << ex.what() << std::endl;
std::abort();
}
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -23,6 +23,7 @@
#include "final/fcharmap.h" #include "final/fcharmap.h"
#include "final/fsystem.h" #include "final/fsystem.h"
#include "final/fterm.h" #include "final/fterm.h"
#include "final/ftermdata.h"
#include "final/ftermfreebsd.h" #include "final/ftermfreebsd.h"
#include "final/ftypes.h" #include "final/ftypes.h"
@ -36,6 +37,7 @@ namespace finalcut
bool FTermFreeBSD::change_cursorstyle = true; bool FTermFreeBSD::change_cursorstyle = true;
bool FTermFreeBSD::meta_sends_escape = true; bool FTermFreeBSD::meta_sends_escape = true;
FSystem* FTermFreeBSD::fsystem = nullptr; FSystem* FTermFreeBSD::fsystem = nullptr;
FTermData* FTermFreeBSD::fterm_data = nullptr;
#endif #endif
@ -52,22 +54,22 @@ FTermFreeBSD::CursorStyle FTermFreeBSD::getCursorStyle()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FTermFreeBSD::setCursorStyle (CursorStyle style, bool hidden) bool FTermFreeBSD::setCursorStyle (CursorStyle style)
{ {
// Set cursor style in a BSD console // Set cursor style in a BSD console
if ( ! fsystem || ! isFreeBSDConsole() || ! change_cursorstyle ) if ( ! fsystem || ! isFreeBSDConsole() || ! change_cursorstyle )
return false; return false;
if ( ! fterm_data )
fterm_data = FTerm::getFTermData();
cursor_style = style; cursor_style = style;
if ( hidden ) if ( fterm_data->isCursorHidden() )
return false; return false;
if ( fsystem->ioctl(0, CONS_CURSORTYPE, &style) == 0 ) return setFreeBSDCursorStyle(style);
return true;
else
return false;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -103,7 +105,7 @@ void FTermFreeBSD::setBeep (int Hz, int ms)
constexpr int timer_frequency = 1193182; constexpr int timer_frequency = 1193182;
int period = timer_frequency / Hz; int period = timer_frequency / Hz;
ms /= 10; ms /= 10;
FTerm::putstringf ( CSI "=%d;%dB", period, ms ); FTerm::putstringf (CSI "=%d;%dB", period, ms);
std::fflush(stdout); std::fflush(stdout);
} }
@ -115,7 +117,7 @@ void FTermFreeBSD::resetBeep()
// default frequency: 1491 Hz // default frequency: 1491 Hz
// default duration: 50 ms // default duration: 50 ms
FTerm::putstring ( CSI "=800;5B" ); FTerm::putstring (CSI "=800;5B");
std::fflush(stdout); std::fflush(stdout);
} }
@ -125,6 +127,7 @@ void FTermFreeBSD::init()
// initialize BSD console // initialize BSD console
fsystem = FTerm::getFSystem(); fsystem = FTerm::getFSystem();
fterm_data = FTerm::getFTermData();
if ( ! isFreeBSDConsole() ) if ( ! isFreeBSDConsole() )
return; return;
@ -141,12 +144,12 @@ void FTermFreeBSD::init()
if ( change_cursorstyle ) if ( change_cursorstyle )
{ {
// Initialize FreeBSD console cursor // Initialize FreeBSD console cursor
setCursorStyle (fc::destructive_cursor, true); setCursorStyle (fc::destructive_cursor);
} }
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermFreeBSD::initCharMap (uInt char_map[][fc::NUM_OF_ENCODINGS]) void FTermFreeBSD::initCharMap()
{ {
// A FreeBSD console can't show ASCII codes from 0x00 to 0x1b // A FreeBSD console can't show ASCII codes from 0x00 to 0x1b
@ -154,8 +157,8 @@ void FTermFreeBSD::initCharMap (uInt char_map[][fc::NUM_OF_ENCODINGS])
return; return;
for (std::size_t i = 0; i <= fc::lastCharItem; i++) for (std::size_t i = 0; i <= fc::lastCharItem; i++)
if ( char_map[i][fc::PC] < 0x1c ) if ( fc::character[i][fc::PC] < 0x1c )
char_map[i][fc::PC] = char_map[i][fc::ASCII]; fc::character[i][fc::PC] = fc::character[i][fc::ASCII];
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -169,16 +172,9 @@ void FTermFreeBSD::finish()
if ( meta_sends_escape ) if ( meta_sends_escape )
resetFreeBSDAlt2Meta(); resetFreeBSDAlt2Meta();
setCursorStyle (fc::normal_cursor, false); setFreeBSDCursorStyle (fc::normal_cursor);
} }
//----------------------------------------------------------------------
void FTermFreeBSD::restoreCursorStyle()
{
// Reset to the last used FreeBSD console cursor style
setCursorStyle (getCursorStyle(), false);
}
// private methods of FTermFreeBSD // private methods of FTermFreeBSD
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -241,6 +237,15 @@ bool FTermFreeBSD::resetFreeBSDAlt2Meta()
return setFreeBSDAltKey (bsd_alt_keymap); return setFreeBSDAltKey (bsd_alt_keymap);
} }
//----------------------------------------------------------------------
bool FTermFreeBSD::setFreeBSDCursorStyle (CursorStyle style)
{
if ( fsystem->ioctl(0, CONS_CURSORTYPE, &style) == 0 )
return true;
else
return false;
}
#endif // defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST) #endif // defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST)
} // namespace finalcut } // namespace finalcut

View File

@ -87,24 +87,34 @@ fc::linuxConsoleCursorStyle FTermLinux::getCursorStyle()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
char* FTermLinux::setCursorStyle ( fc::linuxConsoleCursorStyle style char* FTermLinux::getCursorStyleString()
, bool hidden )
{ {
// Set cursor style in linux console // Gets the current cursor style string of the Linux console
static char buf[16] = { }; static char buf[16] = { };
std::fill (std::begin(buf), std::end(buf), '\0'); std::fill (std::begin(buf), std::end(buf), '\0');
std::sprintf (buf, CSI "?%dc", getCursorStyle());
return buf;
}
//----------------------------------------------------------------------
bool FTermLinux::setCursorStyle (fc::linuxConsoleCursorStyle style)
{
// Set cursor style in linux console
if ( ! fterm_data )
fterm_data = FTerm::getFTermData();
if ( ! FTerm::isLinuxTerm() ) if ( ! FTerm::isLinuxTerm() )
return buf; return false;
linux_console_cursor_style = style; linux_console_cursor_style = style;
if ( hidden ) if ( fterm_data->isCursorHidden() )
return buf; return false;
std::sprintf (buf, CSI "?%dc", style); setLinuxCursorStyle(style);
return buf; return true;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -162,7 +172,9 @@ void FTermLinux::init()
if ( ! fsystem ) if ( ! fsystem )
fsystem = FTerm::getFSystem(); fsystem = FTerm::getFSystem();
fterm_data = FTerm::getFTermData(); if ( ! fterm_data )
fterm_data = FTerm::getFTermData();
fsystem = FTerm::getFSystem(); fsystem = FTerm::getFSystem();
term_detection = FTerm::getFTermDetection(); term_detection = FTerm::getFTermDetection();
screen_unicode_map.entries = nullptr; screen_unicode_map.entries = nullptr;
@ -188,7 +200,7 @@ void FTermLinux::init()
FTermcap::max_color = 8; FTermcap::max_color = 8;
#endif #endif
// Underline cursor // Underline cursor
setCursorStyle (fc::underscore_cursor, true); setCursorStyle (fc::underscore_cursor);
// Framebuffer color depth in bits per pixel // Framebuffer color depth in bits per pixel
framebuffer_bpp = getFramebuffer_bpp(); framebuffer_bpp = getFramebuffer_bpp();
@ -209,7 +221,7 @@ void FTermLinux::init()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermLinux::initCharMap (uInt char_map[][fc::NUM_OF_ENCODINGS]) void FTermLinux::initCharMap()
{ {
constexpr sInt16 NOT_FOUND = -1; constexpr sInt16 NOT_FOUND = -1;
@ -220,12 +232,12 @@ void FTermLinux::initCharMap (uInt char_map[][fc::NUM_OF_ENCODINGS])
{ {
for (std::size_t i = 0; i <= fc::lastCharItem; i++ ) for (std::size_t i = 0; i <= fc::lastCharItem; i++ )
{ {
auto ucs = wchar_t(char_map[i][fc::UTF8]); auto ucs = wchar_t(fc::character[i][fc::UTF8]);
sInt16 fontpos = getFontPos(ucs); sInt16 fontpos = getFontPos(ucs);
// Fix for a non-cp437 Linux console with PC charset encoding // Fix for a non-cp437 Linux console with PC charset encoding
if ( fontpos > 255 || fontpos == NOT_FOUND ) if ( fontpos > 255 || fontpos == NOT_FOUND )
char_map[i][fc::PC] = char_map[i][fc::ASCII]; fc::character[i][fc::PC] = fc::character[i][fc::ASCII];
// Character substitutions for missing characters // Character substitutions for missing characters
if ( fontpos == NOT_FOUND ) if ( fontpos == NOT_FOUND )
@ -255,7 +267,7 @@ void FTermLinux::finish()
#if defined(__x86_64__) || defined(__i386) || defined(__arm__) #if defined(__x86_64__) || defined(__i386) || defined(__arm__)
setBlinkAsIntensity (false); setBlinkAsIntensity (false);
#endif #endif
setCursorStyle (fc::default_cursor, false); setLinuxCursorStyle (fc::default_cursor);
} }
} }
@ -342,7 +354,7 @@ bool FTermLinux::loadNewFont()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FTermLinux::loadOldFont (uInt char_map[][fc::NUM_OF_ENCODINGS]) bool FTermLinux::loadOldFont()
{ {
bool retval = false; bool retval = false;
@ -367,7 +379,7 @@ bool FTermLinux::loadOldFont (uInt char_map[][fc::NUM_OF_ENCODINGS])
if ( screen_unicode_map.entries ) if ( screen_unicode_map.entries )
{ {
setUnicodeMap (&screen_unicode_map); setUnicodeMap (&screen_unicode_map);
initCharMap(char_map); initCharMap();
delete[] screen_unicode_map.entries; delete[] screen_unicode_map.entries;
screen_unicode_map.entries = nullptr; screen_unicode_map.entries = nullptr;
} }
@ -442,18 +454,14 @@ void FTermLinux::resetBeep()
std::fflush(stdout); std::fflush(stdout);
} }
//----------------------------------------------------------------------
char* FTermLinux::restoreCursorStyle()
{
// Reset to the last used Linux console cursor style
return setCursorStyle (getCursorStyle(), false);
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FKey FTermLinux::modifierKeyCorrection (const FKey& key_id) FKey FTermLinux::modifierKeyCorrection (const FKey& key_id)
{ {
// Get the current modifier key state // Get the current modifier key state
if ( ! fsystem )
fsystem = FTerm::getFSystem();
modifier_key& m = getModifierKey(); modifier_key& m = getModifierKey();
if ( ! (m.shift || m.ctrl || m.alt) ) if ( ! (m.shift || m.ctrl || m.alt) )
@ -753,6 +761,12 @@ int FTermLinux::setUnicodeMap (struct unimapdesc* unimap)
return -1; return -1;
} }
//----------------------------------------------------------------------
void FTermLinux::setLinuxCursorStyle (CursorStyle style)
{
FTerm::putstringf (CSI "?%dc", style);
}
#if defined(__x86_64__) || defined(__i386) || defined(__arm__) #if defined(__x86_64__) || defined(__i386) || defined(__arm__)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline uInt16 FTermLinux::getInputStatusRegisterOne() inline uInt16 FTermLinux::getInputStatusRegisterOne()

View File

@ -25,6 +25,8 @@
#include <vector> #include <vector>
#include "final/fapplication.h" #include "final/fapplication.h"
#include "final/fc.h"
#include "final/fcharmap.h"
#include "final/fcolorpair.h" #include "final/fcolorpair.h"
#include "final/fkeyboard.h" #include "final/fkeyboard.h"
#include "final/foptiattr.h" #include "final/foptiattr.h"
@ -140,7 +142,7 @@ void FVTerm::setTermXY (int x, int y)
term_x = term_pos->getX(); term_x = term_pos->getX();
term_y = term_pos->getY(); term_y = term_pos->getY();
const char* move_str = FTerm::moveCursor (term_x, term_y, x, y); const char* move_str = FTerm::moveCursorString (term_x, term_y, x, y);
if ( move_str ) if ( move_str )
appendOutputBuffer(move_str); appendOutputBuffer(move_str);
@ -154,7 +156,7 @@ void FVTerm::hideCursor (bool enable)
{ {
// Hides or shows the input cursor on the terminal // Hides or shows the input cursor on the terminal
const char* visibility_str = FTerm::cursorsVisibility (enable); const char* visibility_str = FTerm::cursorsVisibilityString (enable);
if ( visibility_str ) if ( visibility_str )
appendOutputBuffer(visibility_str); appendOutputBuffer(visibility_str);
@ -350,7 +352,7 @@ int FVTerm::print (term_area* area, const FString& s)
{ {
while ( *p ) while ( *p )
{ {
charData nc; // next character charData nc{}; // next character
nc.code = *p; nc.code = *p;
nc.fg_color = next_attribute.fg_color; nc.fg_color = next_attribute.fg_color;
nc.bg_color = next_attribute.bg_color; nc.bg_color = next_attribute.bg_color;

View File

@ -2379,4 +2379,58 @@ void FWidget::setColorTheme()
wc.set16ColorTheme(); wc.set16ColorTheme();
} }
// 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)
{
if ( text.isEmpty() )
return 0;
std::size_t length = text.getLength();
for (std::size_t i = 0; i < length; i++)
{
try
{
if ( i + 1 < length && text[i] == '&' )
return FKey(text[++i]);
}
catch (const std::out_of_range&)
{
return 0;
}
}
return 0;
}
} // namespace finalcut } // namespace finalcut

View File

@ -36,439 +36,14 @@ namespace finalcut
namespace fc namespace fc
{ {
static uInt character[][fc::NUM_OF_ENCODINGS] = extern uInt character[][fc::NUM_OF_ENCODINGS];
{ extern const std::size_t lastCharItem;
// .--------------------- Unicode (UTF-8)
// | .--------------- VT100
// | | .--------- PC (IBM-437)
// | | | .---- ASCII (7-Bit)
// | | | |
{0x20ac, 0, 0xee, 'E'}, // € - Euro
{0x00a3, '}', 0x9c, 'P'}, // £ - Pound
{0x00a7, '$', 0x15, '$'}, // § - Section
{0x25d8, '*', 0x08, '*'}, // ◘ - InverseBullet
{0x25d9, '*', 0x0a, '*'}, // ◙ - InverseWhiteCircle
{0x203c, '!', 0x13, '!'}, // ‼ - DoubleExclamationMark
{0x2195, 'I', 0x12, 'I'}, // ↕ - UpDownArrow
{0x2194, '-', 0x1d, '-'}, // ↔ - LeftRightArrow
{0x25ac, '_', 0x16, '_'}, // ▬ - BlackRectangle
{0x2191, '^', 0x18, '^'}, // ↑ - UpwardsArrow
{0x2193, 'v', 0x19, 'v'}, // ↓ - DownwardsArrow
{0x2192, '>', 0x1a, '>'}, // → - RightwardsArrow
{0x2190, '<', 0x1b, '<'}, // ← - LeftwardsArrow
{0x03c0, '{', 0xe3, 'n'}, // π - Pi
{0x207F, 'I', 0xfc, ' '}, // ⁿ - SuperscriptLatinSmallLetterN
{0x2265, 'z', 0xf2, '>'}, // ≥ - GreaterThanOrEqualTo
{0x2264, 'y', 0xf3, '<'}, // ≤ - LessThanOrEqualTo
{0x2260, 0, 0xd8, '#'}, // ≠ - NotEqualTo
{0x00b1, 'g', 0xf1, '#'}, // ± - PlusMinus
{0x00f7, '/', 0xf6, '/'}, // ÷ - Division sign
{0x00d7, 0, 'x', 'x'}, // × - Multiplication sign
{0x02e3, '~', 0xfc, '`'}, // ˣ - Modifier letter small x
{0x00b0, 'f', 0xb0, 'o'}, // ° - Degree
{0x2022, '`', 0x04, '*'}, // • - Bullet
{0x00b7, '`', 0xfa, '.'}, // · - small Bullet
{0x25cf, '`', 0x04, '*'}, // ● - BlackCircle
{0x2666, '`', 0x04, '*'}, // ◆ - BlackDiamondSuit
{0x2424, 'h', ' ', ' '}, // ␤ - SymbolForNewline (1)
{0x240b, 'i', ' ', ' '}, // ␋ - SymbolForVerticalTab (1)
{0x2409, 'b', ' ', ' '}, // ␉ - SymbolForHorizontalTab (1)
{0x240c, 'c', ' ', ' '}, // ␌ - SymbolForFormFeed (1)
{0x240d, 'd', ' ', ' '}, // ␍ - SymbolForCarriageReturn (1)
{0x240a, 'e', ' ', ' '}, // ␊ - SymbolForLineFeed (1)
{0x2592, 'a', 0xb0, '#'}, // ▒ - MediumShade
{0x2588, '0', 0xdb, '#'}, // █ - FullBlock
{0x25ae, '_', 0xfe, '#'}, // ▮ - BlackVerticalRectangle (1)
{0x258c, 0, 0xdd, ' '}, // ▌ - LeftHalfBlock
{0x2590, 0, 0xde, ' '}, // ▐ - RightHalfBlock
{0x2584, 0, 0xdc, ' '}, // ▄ - LowerHalfBlock
{0x2580, 0, 0xdf, ' '}, // ▀ - UpperHalfBlock
{0x2500, 'q', 0xc4, '-'}, // ─ - BoxDrawingsHorizontal
{0x2502, 'x', 0xb3, '|'}, // │ - BoxDrawingsVertical
{0x250c, 'l', 0xda, '.'}, // ┌ - BoxDrawingsDownAndRight
{0x2510, 'k', 0xbf, '.'}, // ┐ - BoxDrawingsDownAndLeft
{0x2514, 'm', 0xc0, '`'}, // └ - BoxDrawingsUpAndRight
{0x2518, 'j', 0xd9, '\''}, // ┘ - BoxDrawingsUpAndLeft
{0x253c, 'n', 0xc5, '+'}, // ┼ - BoxDrawingsCross
{0x252c, 'w', 0xc2, '+'}, // ┬ - BoxDrawingsDownAndHorizontal
{0x2524, 'u', 0xb4, '+'}, // ┤ - BoxDrawingsVerticalAndLeft
{0x251c, 't', 0xc3, '+'}, // ├ - BoxDrawingsVerticalAndRight
{0x2534, 'v', 0xc1, '+'}, // ┴ - BoxDrawingsUpAndHorizontal
{0x23ba, 'o', '~', '~'}, // ⎺ - HorizontalScanLine1 (1)
{0x23bb, 'p', 0xc4, '-'}, // ⎻ - HorizontalScanLine3 (1)
{0x23bc, 'r', 0xc4, '-'}, // ⎼ - HorizontalScanLine7 (1)
{0x23bd, 's', '_', '_'}, // ⎽ - HorizontalScanLine9 (1)
{0x25b2, '-', 0x1e, '^'}, // ▲ - BlackUpPointingTriangle
{0x25bc, '.', 0x1f, 'v'}, // ▼ - BlackDownPointingTriangle
{0x25b6, '+', 0x10, '>'}, // ▶ - BlackRightPointingTriangle
{0x25c0, ',', 0x11, '<'}, // ◀ - BlackLeftPointingTriangle (1)
{0x25ba, '+', 0x10, '>'}, // ► - BlackRightPointingPointer (1)
{0x25c4, ',', 0x11, '<'}, // ◄ - BlackLeftPointingPointer
{0x1ab4, 0, 0xb4, 0}, // ⊐ - NF_rev_left_arrow2 (2)
{0x1ab5, 0, 0xb5, 0}, // ► - NF_rev_right_arrow2 (2)
{0x1ab7, 0, 0xb7, 0}, // ) - NF_radio_button3 (2)
{0x1ab8, 0, 0xb8, 0}, // ⎤ - NF_rev_border_corner_upper_right (2)
{0x1ab9, 0, 0xb9, 0}, // ⎹ - NF_rev_border_line_right (2)
{0x1aba, 0, 0xba, 0}, // ┤ - NF_rev_border_line_vertical_left (2)
{0x1abb, 0, 0xbb, 0}, // ⎦ - NF_rev_border_corner_lower_right (2)
{0x1abc, 0, 0xbc, 0}, // ⎸ - NF_border_line_left (2)
{0x1abd, 0, 0xbd, 0}, //⎹◣ - NF_rev_up_arrow2 (2)
{0x1abe, 0, 0xbe, 0}, //⎹◤ - NF_rev_down_arrow2 (2)
{0x1ac0, 0, 0xc0, 0}, // └ - NF_border_corner_middle_lower_left (2)
{0x1ac1, 0, 0xc1, 0}, // ◢⎸ - NF_rev_up_arrow1 (2)
{0x1ac2, 0, 0xc2, 0}, // ◥⎸ - NF_rev_down_arrow1 (2)
{0x1ac3, 0, 0xc3, 0}, // ├ - NF_border_line_vertical_right (2)
{0x1ac5, 0, 0xc5, 0}, // = - NF_border_line_up_and_down (2)
{0x1ac6, 0, 0xc6, 0}, // = - NF_shadow_box_middle (2)
{0x1ac7, 0, 0xc7, 0}, // = - NF_shadow_box_hdd (2)
{0x1ac8, 0, 0xc8, 0}, // ◄ - NF_rev_left_arrow1 (2)
{0x1ac9, 0, 0xc9, 0}, // ⊏ - NF_rev_right_arrow1 (2)
{0x1aca, 0, 0xca, 0}, // [ - NF_rev_menu_button1 (2)
{0x1acb, 0, 0xcb, 0}, // - - NF_rev_menu_button2 (2)
{0x1acc, 0, 0xcc, 0}, // ┌ - NF_border_corner_middle_upper_left (2)
{0x1acd, 0, 0xcd, 0}, // = - NF_shadow_box_cd (2)
{0x1ace, 0, 0xce, 0}, // [ - NF_shadow_box_left (2)
{0x1acf, 0, 0xcf, 0}, // ┘ - NF_border_corner_middle_lower_right (2)
{0x1ad0, 0, 0xd0, 0}, // ┐ - NF_border_corner_middle_upper_right (2)
{0x1ad1, 0, 0xd1, 0}, // = - NF_shadow_box_net (2)
{0x1ad2, 0, 0xd2, 0}, // ◢ - NF_rev_up_pointing_triangle1 (2)
{0x1ad3, 0, 0xd3, 0}, // ⎣ - NF_border_corner_lower_left (2)
{0x1ad4, 0, 0xd4, 0}, // _ - NF_border_line_bottom (2)
{0x1ad5, 0, 0xd5, 0}, // O - NF_radio_button2 (2)
{0x1ad6, 0, 0xd6, 0}, // ● - NF_radio_button2_checked (2)
{0x1ad7, 0, 0xd7, 0}, // ◥ - NF_rev_down_pointing_triangle1 (2)
{0x1ad8, 0, 0xd8, 0}, // ¯ - NF_border_line_upper (2)
{0x1ad9, 0, 0xd9, 0}, // ( - NF_radio_button1 (2)
{0x1ada, 0, 0xda, 0}, // ⎡ - NF_border_corner_upper_left (2)
{0x1adc, 0, 0xdc, 0}, // ✓ - NF_shadow_box_checked (2)
{0x1ae7, 0, 0xe7, 0}, // ║ - NF_rev_border_line_right_and_left (2)
{0x1ae8, 0, 0xe8, 0}, // ◣ - NF_rev_up_pointing_triangle2 (2)
{0x1ae9, 0, 0xe9, 0}, // ◤ - NF_rev_down_pointing_triangle2 (2)
{0x1af4, 0, 0xf4, 0}, // ] - NF_rev_menu_button3 (2)
{0x1af5, 0, 0xf5, 0}, // ] - NF_shadow_box_right (2)
{0x1afb, 0, 0xfb, 0}, // ✓ - NF_check_mark (2)
{0x221a, 0, 0xfb, 'x'}, // √ - square root
{0x25cf, '`', 0x04, '*'} // ● - black circle
};
/* extern int vt100_key_to_utf8[][2];
* (1) Not defined in Windows Glyph List 4 (WGL4) extern const std::size_t lastKeyItem;
* (2) Only supported in use with newfont
*/
constexpr auto lastCharItem = \ extern wchar_t cp437_to_ucs[][2];
std::size_t((sizeof(character) / sizeof(character[0])) - 1); extern const std::size_t lastCP437Item;
static int vt100_key_to_utf8[][2] =
{
{fc::vt100_key_rarrow , fc::BlackRightPointingPointer}, // ►
{fc::vt100_key_larrow , fc::BlackLeftPointingPointer}, // ◄
{fc::vt100_key_uarrow , fc::BlackUpPointingTriangle}, // ▲
{fc::vt100_key_darrow , fc::BlackDownPointingTriangle}, // ▼
{fc::vt100_key_block , fc::FullBlock}, // █
{fc::vt100_key_nsup , fc::SuperscriptLatinSmallLetterN}, // ⁿ
{fc::vt100_key_blackrect, fc::BlackVerticalRectangle}, // ▮
{fc::vt100_key_diamond , fc::BlackDiamondSuit}, // ◆
{fc::vt100_key_ckboard , fc::MediumShade}, // ▒
{fc::vt100_key_htab , fc::SymbolForHorizontalTab}, // ␉
{fc::vt100_key_ff , fc::SymbolForFormFeed}, // ␌
{fc::vt100_key_cr , fc::SymbolForCarriageReturn}, // ␍
{fc::vt100_key_lf , fc::SymbolForLineFeed}, // ␊
{fc::vt100_key_degree , fc::Degree}, // °
{fc::vt100_key_plminus , fc::PlusMinus}, // ±
{fc::vt100_key_board , fc::SymbolForNewline}, // ␤
{fc::vt100_key_lantern , fc::SymbolForVerticalTab}, // ␋
{fc::vt100_key_lrcorner , fc::BoxDrawingsUpAndLeft}, // ┘
{fc::vt100_key_urcorner , fc::BoxDrawingsDownAndLeft}, // ┐
{fc::vt100_key_ulcorner , fc::BoxDrawingsDownAndRight}, // ┌
{fc::vt100_key_llcorner , fc::BoxDrawingsUpAndRight}, // └
{fc::vt100_key_plus , fc::BoxDrawingsCross}, // ┼
{fc::vt100_key_s1 , fc::HorizontalScanLine1}, // ⎺
{fc::vt100_key_s3 , fc::HorizontalScanLine3}, // ⎻
{fc::vt100_key_hline , fc::BoxDrawingsHorizontal}, // ─
{fc::vt100_key_s7 , fc::HorizontalScanLine7}, // ⎼
{fc::vt100_key_s9 , fc::HorizontalScanLine9}, // ⎽
{fc::vt100_key_ltee , fc::BoxDrawingsVerticalAndRight}, // ├
{fc::vt100_key_rtee , fc::BoxDrawingsVerticalAndLeft}, // ┤
{fc::vt100_key_btee , fc::BoxDrawingsUpAndHorizontal}, // ┴
{fc::vt100_key_ttee , fc::BoxDrawingsDownAndHorizontal}, // ┬
{fc::vt100_key_vline , fc::BoxDrawingsVertical}, // │
{fc::vt100_key_lequal , fc::LessThanOrEqualTo}, // ≤
{fc::vt100_key_gequal , fc::GreaterThanOrEqualTo}, // ≥
{fc::vt100_key_pi , fc::Pi}, // π
{fc::vt100_key_nequal , fc::NotEqualTo}, // ≠
{fc::vt100_key_sterling , fc::Pound}, // £
{fc::vt100_key_bullet , fc::SmallBullet}, // ·
{fc::vt100_key_diamond , fc::Bullet} // ◆
};
constexpr auto lastKeyItem = \
std::size_t((sizeof(vt100_key_to_utf8) / sizeof(vt100_key_to_utf8[0])) - 1);
static wchar_t cp437_to_ucs[][2] =
{
{0x00, 0x0000}, // null
{0x01, 0x263a}, // white smiling face
{0x02, 0x263b}, // black smiling face
{0x03, 0x2665}, // black heart suit
{0x04, 0x2666}, // black diamond suit
{0x05, 0x2663}, // black club suit
{0x06, 0x2660}, // black spade suit
{0x07, 0x2022}, // bullet
{0x08, 0x25d8}, // inverse bullet
{0x09, 0x25cb}, // white circle
{0x0a, 0x25d9}, // inverse white circle
{0x0b, 0x2642}, // male sign
{0x0c, 0x2640}, // female sign
{0x0d, 0x266a}, // eighth note
{0x0e, 0x266b}, // beamed eighth notes
{0x0f, 0x263c}, // white sun with rays
{0x10, 0x25ba}, // black right-pointing pointer
{0x11, 0x25c4}, // black left-pointing pointer
{0x12, 0x2195}, // up down arrow
{0x13, 0x203c}, // double exclamation mark
{0x14, 0x00b6}, // pilcrow sign
{0x15, 0x00a7}, // section sign
{0x16, 0x25ac}, // black rectangle
{0x17, 0x21a8}, // up down arrow with base
{0x18, 0x2191}, // upwards arrow
{0x19, 0x2193}, // downwards arrow
{0x1a, 0x2192}, // rightwards arrow
{0x1b, 0x2190}, // leftwards arrow
{0x1c, 0x221f}, // right angle
{0x1d, 0x2194}, // left right arrow
{0x1e, 0x25b2}, // black up-pointing triangle
{0x1f, 0x25bc}, // black down-pointing triangle
{0x20, 0x0020}, // space
{0x21, 0x0021}, // exclamation mark
{0x22, 0x0022}, // quotation mark
{0x23, 0x0023}, // number sign
{0x24, 0x0024}, // dollar sign
{0x25, 0x0025}, // percent sign
{0x26, 0x0026}, // ampersand
{0x27, 0x0027}, // apostrophe
{0x28, 0x0028}, // left parenthesis
{0x29, 0x0029}, // right parenthesis
{0x2a, 0x002a}, // asterisk
{0x2b, 0x002b}, // plus sign
{0x2c, 0x002c}, // comma
{0x2d, 0x002d}, // hyphen-minus
{0x2e, 0x002e}, // full stop
{0x2f, 0x002f}, // solidus
{0x30, 0x0030}, // digit zero
{0x31, 0x0031}, // digit one
{0x32, 0x0032}, // digit two
{0x33, 0x0033}, // digit three
{0x34, 0x0034}, // digit four
{0x35, 0x0035}, // digit five
{0x36, 0x0036}, // digit six
{0x37, 0x0037}, // digit seven
{0x38, 0x0038}, // digit eight
{0x39, 0x0039}, // digit nine
{0x3a, 0x003a}, // colon
{0x3b, 0x003b}, // semicolon
{0x3c, 0x003c}, // less-than sign
{0x3d, 0x003d}, // equals sign
{0x3e, 0x003e}, // greater-than sign
{0x3f, 0x003f}, // question mark
{0x40, 0x0040}, // commercial at
{0x41, 0x0041}, // latin capital letter a
{0x42, 0x0042}, // latin capital letter b
{0x43, 0x0043}, // latin capital letter c
{0x44, 0x0044}, // latin capital letter d
{0x45, 0x0045}, // latin capital letter e
{0x46, 0x0046}, // latin capital letter f
{0x47, 0x0047}, // latin capital letter g
{0x48, 0x0048}, // latin capital letter h
{0x49, 0x0049}, // latin capital letter i
{0x4a, 0x004a}, // latin capital letter j
{0x4b, 0x004b}, // latin capital letter k
{0x4c, 0x004c}, // latin capital letter l
{0x4d, 0x004d}, // latin capital letter m
{0x4e, 0x004e}, // latin capital letter n
{0x4f, 0x004f}, // latin capital letter o
{0x50, 0x0050}, // latin capital letter p
{0x51, 0x0051}, // latin capital letter q
{0x52, 0x0052}, // latin capital letter r
{0x53, 0x0053}, // latin capital letter s
{0x54, 0x0054}, // latin capital letter t
{0x55, 0x0055}, // latin capital letter u
{0x56, 0x0056}, // latin capital letter v
{0x57, 0x0057}, // latin capital letter w
{0x58, 0x0058}, // latin capital letter x
{0x59, 0x0059}, // latin capital letter y
{0x5a, 0x005a}, // latin capital letter z
{0x5b, 0x005b}, // left square bracket
{0x5c, 0x005c}, // reverse solidus
{0x5d, 0x005d}, // right square bracket
{0x5e, 0x005e}, // circumflex accent
{0x5f, 0x005f}, // low line
{0x60, 0x0060}, // grave accent
{0x61, 0x0061}, // latin small letter a
{0x62, 0x0062}, // latin small letter b
{0x63, 0x0063}, // latin small letter c
{0x64, 0x0064}, // latin small letter d
{0x65, 0x0065}, // latin small letter e
{0x66, 0x0066}, // latin small letter f
{0x67, 0x0067}, // latin small letter g
{0x68, 0x0068}, // latin small letter h
{0x69, 0x0069}, // latin small letter i
{0x6a, 0x006a}, // latin small letter j
{0x6b, 0x006b}, // latin small letter k
{0x6c, 0x006c}, // latin small letter l
{0x6d, 0x006d}, // latin small letter m
{0x6e, 0x006e}, // latin small letter n
{0x6f, 0x006f}, // latin small letter o
{0x70, 0x0070}, // latin small letter p
{0x71, 0x0071}, // latin small letter q
{0x72, 0x0072}, // latin small letter r
{0x73, 0x0073}, // latin small letter s
{0x74, 0x0074}, // latin small letter t
{0x75, 0x0075}, // latin small letter u
{0x76, 0x0076}, // latin small letter v
{0x77, 0x0077}, // latin small letter w
{0x78, 0x0078}, // latin small letter x
{0x79, 0x0079}, // latin small letter y
{0x7a, 0x007a}, // latin small letter z
{0x7b, 0x007b}, // left curly bracket
{0x7c, 0x007c}, // vertical line
{0x7d, 0x007d}, // right curly bracket
{0x7e, 0x007e}, // tilde
{0x7f, 0x007f}, // house
{0x80, 0x00c7}, // latin capital letter c with cedilla
{0x81, 0x00fc}, // latin small letter u with diaeresis
{0x82, 0x00e9}, // latin small letter e with acute
{0x83, 0x00e2}, // latin small letter a with circumflex
{0x84, 0x00e4}, // latin small letter a with diaeresis
{0x85, 0x00e0}, // latin small letter a with grave
{0x86, 0x00e5}, // latin small letter a with ring above
{0x87, 0x00e7}, // latin small letter c with cedilla
{0x88, 0x00ea}, // latin small letter e with circumflex
{0x89, 0x00eb}, // latin small letter e with diaeresis
{0x8a, 0x00e8}, // latin small letter e with grave
{0x8b, 0x00ef}, // latin small letter i with diaeresis
{0x8c, 0x00ee}, // latin small letter i with circumflex
{0x8d, 0x00ec}, // latin small letter i with grave
{0x8e, 0x00c4}, // latin capital letter a with diaeresis
{0x8f, 0x00c5}, // latin capital letter a with ring above
{0x90, 0x00c9}, // latin capital letter e with acute
{0x91, 0x00e6}, // latin small ligature ae
{0x92, 0x00c6}, // latin capital ligature ae
{0x93, 0x00f4}, // latin small letter o with circumflex
{0x94, 0x00f6}, // latin small letter o with diaeresis
{0x95, 0x00f2}, // latin small letter o with grave
{0x96, 0x00fb}, // latin small letter u with circumflex
{0x97, 0x00f9}, // latin small letter u with grave
{0x98, 0x00ff}, // latin small letter y with diaeresis
{0x99, 0x00d6}, // latin capital letter o with diaeresis
{0x9a, 0x00dc}, // latin capital letter u with diaeresis
{0x9b, 0x00a2}, // cent sign
{0x9c, 0x00a3}, // pound sign
{0x9d, 0x00a5}, // yen sign
{0x9e, 0x20a7}, // peseta sign
{0x9f, 0x0192}, // latin small letter f with hook
{0xa0, 0x00e1}, // latin small letter a with acute
{0xa1, 0x00ed}, // latin small letter i with acute
{0xa2, 0x00f3}, // latin small letter o with acute
{0xa3, 0x00fa}, // latin small letter u with acute
{0xa4, 0x00f1}, // latin small letter n with tilde
{0xa5, 0x00d1}, // latin capital letter n with tilde
{0xa6, 0x00aa}, // feminine ordinal indicator
{0xa7, 0x00ba}, // masculine ordinal indicator
{0xa8, 0x00bf}, // inverted question mark
{0xa9, 0x2310}, // reversed not sign
{0xaa, 0x00ac}, // not sign
{0xab, 0x00bd}, // vulgar fraction one half
{0xac, 0x00bc}, // vulgar fraction one quarter
{0xad, 0x00a1}, // inverted exclamation mark
{0xae, 0x00ab}, // left-pointing double angle quotation mark
{0xaf, 0x00bb}, // right-pointing double angle quotation mark
{0xb0, 0x2591}, // light shade
{0xb1, 0x2592}, // medium shade
{0xb2, 0x2593}, // dark shade
{0xb3, 0x2502}, // box drawings light vertical
{0xb4, 0x2524}, // box drawings light vertical and left
{0xb5, 0x2561}, // box drawings vertical single and left double
{0xb6, 0x2562}, // box drawings vertical double and left single
{0xb7, 0x2556}, // box drawings down double and left single
{0xb8, 0x2555}, // box drawings down single and left double
{0xb9, 0x2563}, // box drawings double vertical and left
{0xba, 0x2551}, // box drawings double vertical
{0xbb, 0x2557}, // box drawings double down and left
{0xbc, 0x255d}, // box drawings double up and left
{0xbd, 0x255c}, // box drawings up double and left single
{0xbe, 0x255b}, // box drawings up single and left double
{0xbf, 0x2510}, // box drawings light down and left
{0xc0, 0x2514}, // box drawings light up and right
{0xc1, 0x2534}, // box drawings light up and horizontal
{0xc2, 0x252c}, // box drawings light down and horizontal
{0xc3, 0x251c}, // box drawings light vertical and right
{0xc4, 0x2500}, // box drawings light horizontal
{0xc5, 0x253c}, // box drawings light vertical and horizontal
{0xc6, 0x255e}, // box drawings vertical single and right double
{0xc7, 0x255f}, // box drawings vertical double and right single
{0xc8, 0x255a}, // box drawings double up and right
{0xc9, 0x2554}, // box drawings double down and right
{0xca, 0x2569}, // box drawings double up and horizontal
{0xcb, 0x2566}, // box drawings double down and horizontal
{0xcc, 0x2560}, // box drawings double vertical and right
{0xcd, 0x2550}, // box drawings double horizontal
{0xce, 0x256c}, // box drawings double vertical and horizontal
{0xcf, 0x2567}, // box drawings up single and horizontal double
{0xd0, 0x2568}, // box drawings up double and horizontal single
{0xd1, 0x2564}, // box drawings down single and horizontal double
{0xd2, 0x2565}, // box drawings down double and horizontal single
{0xd3, 0x2559}, // box drawings up double and right single
{0xd4, 0x2558}, // box drawings up single and right double
{0xd5, 0x2552}, // box drawings down single and right double
{0xd6, 0x2553}, // box drawings down double and right single
{0xd7, 0x256b}, // box drawings vertical double and horizontal single
{0xd8, 0x256a}, // box drawings vertical single and horizontal double
{0xd9, 0x2518}, // box drawings light up and left
{0xda, 0x250c}, // box drawings light down and right
{0xdb, 0x2588}, // full block
{0xdc, 0x2584}, // lower half block
{0xdd, 0x258c}, // left half block
{0xde, 0x2590}, // right half block
{0xdf, 0x2580}, // upper half block
{0xe0, 0x03b1}, // greek small letter alpha
{0xe1, 0x00df}, // latin small letter sharp s
{0xe2, 0x0393}, // greek capital letter gamma
{0xe3, 0x03c0}, // greek small letter pi
{0xe4, 0x03a3}, // greek capital letter sigma
{0xe5, 0x03c3}, // greek small letter sigma
{0xe6, 0x00b5}, // micro sign
{0xe7, 0x03c4}, // greek small letter tau
{0xe8, 0x03a6}, // greek capital letter phi
{0xe9, 0x0398}, // greek capital letter theta
{0xea, 0x03a9}, // greek capital letter omega
{0xeb, 0x03b4}, // greek small letter delta
{0xec, 0x221e}, // infinity
{0xed, 0x03c6}, // greek small letter phi
{0xee, 0x03b5}, // greek small letter epsilon
{0xef, 0x2229}, // intersection
{0xf0, 0x2261}, // identical to
{0xf1, 0x00b1}, // plus-minus sign
{0xf2, 0x2265}, // greater-than or equal to
{0xf3, 0x2264}, // less-than or equal to
{0xf4, 0x2320}, // top half integral
{0xf5, 0x2321}, // bottom half integral
{0xf6, 0x00f7}, // division sign
{0xf7, 0x2248}, // almost equal to
{0xf8, 0x00b0}, // degree sign
{0xf9, 0x2219}, // bullet operator
{0xfa, 0x00b7}, // middle dot
{0xfb, 0x221a}, // square root
{0xfc, 0x207f}, // superscript latin small letter n
{0xfd, 0x00b2}, // superscript two
{0xfe, 0x25a0}, // black square
{0xff, 0x00a0} // no-break space
};
constexpr auto lastCP437Item = \
std::size_t((sizeof(cp437_to_ucs) / sizeof(cp437_to_ucs[0])) - 1);
} // namespace fc } // namespace fc

View File

@ -31,9 +31,9 @@
#include <final/fapplication.h> #include <final/fapplication.h>
#include <final/fbuttongroup.h> #include <final/fbuttongroup.h>
#include <final/fbutton.h> #include <final/fbutton.h>
#include "final/fc.h" #include <final/fc.h>
#include "final/fcolorpair.h" #include <final/fcolorpair.h>
#include "final/fcharmap.h" #include <final/fcharmap.h>
#include <final/fcheckbox.h> #include <final/fcheckbox.h>
#include <final/fcheckmenuitem.h> #include <final/fcheckmenuitem.h>
#include <final/fdialog.h> #include <final/fdialog.h>
@ -75,15 +75,15 @@
#include <final/fwidget.h> #include <final/fwidget.h>
#if defined(UNIT_TEST) #if defined(UNIT_TEST)
#include "final/ftermlinux.h" #include <final/ftermlinux.h>
#include "final/ftermfreebsd.h" #include <final/ftermfreebsd.h>
#include "final/ftermopenbsd.h" #include <final/ftermopenbsd.h>
#elif defined(__linux__) #elif defined(__linux__)
#include "final/ftermlinux.h" #include <final/ftermlinux.h>
#elif defined(__FreeBSD__) || defined(__DragonFly__) #elif defined(__FreeBSD__) || defined(__DragonFly__)
#include "final/ftermfreebsd.h" #include <final/ftermfreebsd.h>
#elif defined(__NetBSD__) || defined(__OpenBSD__) #elif defined(__NetBSD__) || defined(__OpenBSD__)
#include "final/ftermopenbsd.h" #include <final/ftermopenbsd.h>
#endif #endif
#undef USE_FINAL_H #undef USE_FINAL_H

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2015-2018 Markus Gans * * Copyright 2015-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -27,9 +27,6 @@
#error "Only <final/final.h> can be included directly." #error "Only <final/final.h> can be included directly."
#endif #endif
#include <string>
#include "final/ftypes.h"
namespace finalcut namespace finalcut
{ {

View File

@ -336,47 +336,9 @@ inline void FOptiMove::set_eat_newline_glitch (const bool& bcap)
{ eat_nl_glitch = bcap; } { eat_nl_glitch = bcap; }
// FOptiMove non-member function // FOptiMove non-member function forward declaration
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void printDurations (const FOptiMove& om) void printDurations (const FOptiMove&);
{
std::cout << " speed: "
<< om.baudrate << " baud\r\n";
std::cout << " char_duration: "
<< om.char_duration << " ms\r\n";
std::cout << " cursor_home: "
<< om.F_cursor_home.duration << " ms\r\n";
std::cout << " cursor_to_ll: "
<< om.F_cursor_to_ll.duration << " ms\r\n";
std::cout << " carriage_return: "
<< om.F_carriage_return.duration << " ms\r\n";
std::cout << " tab: "
<< om.F_tab.duration << " ms\r\n";
std::cout << " back_tab: "
<< om.F_back_tab.duration << " ms\r\n";
std::cout << " cursor_up: "
<< om.F_cursor_up.duration << " ms\r\n";
std::cout << " cursor_down: "
<< om.F_cursor_down.duration << " ms\r\n";
std::cout << " cursor_left: "
<< om.F_cursor_left.duration << " ms\r\n";
std::cout << " cursor_right: "
<< om.F_cursor_right.duration << " ms\r\n";
std::cout << " cursor_address: "
<< om.F_cursor_address.duration << " ms\r\n";
std::cout << " column_address: "
<< om.F_column_address.duration << " ms\r\n";
std::cout << " row_address: "
<< om.F_row_address.duration << " ms\r\n";
std::cout << " parm_up_cursor: "
<< om.F_parm_up_cursor.duration << " ms\r\n";
std::cout << " parm_down_cursor: "
<< om.F_parm_down_cursor.duration << " ms\r\n";
std::cout << " parm_left_cursor: "
<< om.F_parm_left_cursor.duration << " ms\r\n";
std::cout << "parm_right_cursor: "
<< om.F_parm_right_cursor.duration << " ms\r\n";
}
} // namespace finalcut } // namespace finalcut

View File

@ -257,11 +257,8 @@ class FTerm final
static bool setOldFont(); static bool setOldFont();
static int openConsole(); static int openConsole();
static int closeConsole(); static int closeConsole();
static char* moveCursor (int, int, int, int); static char* moveCursorString (int, int, int, int);
static char* cursorsVisibility (bool); static char* cursorsVisibilityString (bool);
static void printMoveDurations();
static char* enableCursor();
static char* disableCursor();
static void detectTermSize(); static void detectTermSize();
static void setTermSize (const FSize&); static void setTermSize (const FSize&);
static void setTermTitle (const FString&); static void setTermTitle (const FString&);
@ -380,6 +377,8 @@ class FTerm final
static void restoreColorPalette(); static void restoreColorPalette();
static void setInsertCursorStyle(); static void setInsertCursorStyle();
static void setOverwriteCursorStyle(); static void setOverwriteCursorStyle();
static char* enableCursorString();
static char* disableCursorString();
static void enableMouse(); static void enableMouse();
static void disableMouse(); static void disableMouse();
static void enableApplicationEscKey(); static void enableApplicationEscKey();

View File

@ -70,6 +70,7 @@ namespace finalcut
// class forward declaration // class forward declaration
class FSystem; class FSystem;
class FTermData;
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// class FTermFreeBSD // class FTermFreeBSD
@ -104,7 +105,7 @@ class FTermFreeBSD final
static bool isFreeBSDConsole(); static bool isFreeBSDConsole();
// Mutators // Mutators
static bool setCursorStyle (CursorStyle, bool); static bool setCursorStyle (CursorStyle);
static void enableChangeCursorStyle(); static void enableChangeCursorStyle();
static void disableChangeCursorStyle(); static void disableChangeCursorStyle();
static void enableMetaSendsEscape(); static void enableMetaSendsEscape();
@ -114,9 +115,8 @@ class FTermFreeBSD final
// Methods // Methods
static void init(); static void init();
static void initCharMap (uInt[][fc::NUM_OF_ENCODINGS]); static void initCharMap();
static void finish(); static void finish();
static void restoreCursorStyle();
private: private:
// Methods // Methods
@ -124,6 +124,7 @@ class FTermFreeBSD final
static bool setFreeBSDAltKey (uInt); static bool setFreeBSDAltKey (uInt);
static bool setFreeBSDAlt2Meta(); static bool setFreeBSDAlt2Meta();
static bool resetFreeBSDAlt2Meta(); static bool resetFreeBSDAlt2Meta();
static bool setFreeBSDCursorStyle (CursorStyle);
// Data Members // Data Members
static uInt bsd_alt_keymap; static uInt bsd_alt_keymap;
@ -131,6 +132,7 @@ class FTermFreeBSD final
static bool change_cursorstyle; static bool change_cursorstyle;
static bool meta_sends_escape; static bool meta_sends_escape;
static FSystem* fsystem; static FSystem* fsystem;
static FTermData* fterm_data;
}; };
#pragma pack(pop) #pragma pack(pop)

View File

@ -71,6 +71,9 @@ class FTermDetection;
class FTermLinux final class FTermLinux final
{ {
public: public:
// Typedef
typedef fc::linuxConsoleCursorStyle CursorStyle;
// Constructors // Constructors
FTermLinux() = default; FTermLinux() = default;
@ -86,10 +89,11 @@ class FTermLinux final
// Accessors // Accessors
const char* getClassName() const; const char* getClassName() const;
static fc::linuxConsoleCursorStyle getCursorStyle(); static fc::linuxConsoleCursorStyle getCursorStyle();
static char* getCursorStyleString();
static int getFramebufferBpp(); static int getFramebufferBpp();
// Mutators // Mutators
static char* setCursorStyle (fc::linuxConsoleCursorStyle, bool); static bool setCursorStyle (CursorStyle);
static bool setPalette (FColor, int, int, int); static bool setPalette (FColor, int, int, int);
static void setUTF8 (bool); static void setUTF8 (bool);
@ -100,16 +104,16 @@ class FTermLinux final
// Methods // Methods
static void init(); static void init();
static void initCharMap (uInt[][fc::NUM_OF_ENCODINGS]); static void initCharMap();
static void finish(); static void finish();
static bool loadVGAFont(); static bool loadVGAFont();
static bool loadNewFont(); static bool loadNewFont();
static bool loadOldFont (uInt[][fc::NUM_OF_ENCODINGS]); static bool loadOldFont();
static bool saveColorMap(); static bool saveColorMap();
static bool resetColorMap(); static bool resetColorMap();
static void setBeep (int, int); static void setBeep (int, int);
static void resetBeep(); static void resetBeep();
static char* restoreCursorStyle();
static FKey modifierKeyCorrection (const FKey&); static FKey modifierKeyCorrection (const FKey&);
private: private:
@ -145,6 +149,7 @@ class FTermLinux final
static int setScreenFont ( uChar[], uInt, uInt, uInt static int setScreenFont ( uChar[], uInt, uInt, uInt
, bool = false ); , bool = false );
static int setUnicodeMap (struct unimapdesc*); static int setUnicodeMap (struct unimapdesc*);
static void setLinuxCursorStyle (fc::linuxConsoleCursorStyle);
// Methods // Methods
#if defined(__x86_64__) || defined(__i386) || defined(__arm__) #if defined(__x86_64__) || defined(__i386) || defined(__arm__)
@ -179,8 +184,7 @@ class FTermLinux final
static FTermData* fterm_data; static FTermData* fterm_data;
static FSystem* fsystem; static FSystem* fsystem;
static FTermDetection* term_detection; static FTermDetection* term_detection;
static fc::linuxConsoleCursorStyle static CursorStyle linux_console_cursor_style;
linux_console_cursor_style;
static console_font_op screen_font; static console_font_op screen_font;
static unimapdesc screen_unicode_map; static unimapdesc screen_unicode_map;
static ColorMap saved_color_map; static ColorMap saved_color_map;

View File

@ -316,8 +316,6 @@ class FVTerm
virtual FVTerm& print(); virtual FVTerm& print();
static void beep(); static void beep();
static void redefineDefaultColors (bool); static void redefineDefaultColors (bool);
static char* moveCursor (int, int, int, int);
static void printMoveDurations();
protected: protected:
// Enumeration // Enumeration
@ -1060,14 +1058,6 @@ inline void FVTerm::beep()
inline void FVTerm::redefineDefaultColors (bool enable) inline void FVTerm::redefineDefaultColors (bool enable)
{ FTerm::redefineDefaultColors(enable); } { FTerm::redefineDefaultColors(enable); }
//----------------------------------------------------------------------
inline char* FVTerm::moveCursor (int xold, int yold, int xnew, int ynew)
{ return FTerm::moveCursor (xold, yold, xnew, ynew); }
//----------------------------------------------------------------------
inline void FVTerm::printMoveDurations()
{ return FTerm::printMoveDurations(); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FVTerm::setPrintArea (term_area* area) inline void FVTerm::setPrintArea (term_area* area)
{ print_area = area; } { print_area = area; }

View File

@ -1005,58 +1005,11 @@ const wchar_t CHECKED_RADIO_BUTTON[4] =
'\0' '\0'
}; };
// non-member functions // non-member function forward declarations
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline char* createBlankArray (std::size_t size) char* createBlankArray (std::size_t);
{ void destroyBlankArray (char[]);
char* blank; FKey getHotkey (const FString&);
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;
}
//----------------------------------------------------------------------
inline void destroyBlankArray (char blank[])
{
delete[] blank;
}
//----------------------------------------------------------------------
inline FKey getHotkey (const FString& text)
{
if ( text.isEmpty() )
return 0;
std::size_t length = text.getLength();
for (std::size_t i = 0; i < length; i++)
{
try
{
if ( i + 1 < length && text[i] == '&' )
return FKey(text[++i]);
}
catch (const std::out_of_range&)
{
return 0;
}
}
return 0;
}
} // namespace finalcut } // namespace finalcut

View File

@ -673,15 +673,14 @@ void ftermfreebsdTest::freebsdConsoleTest()
freebsd.disableChangeCursorStyle(); freebsd.disableChangeCursorStyle();
freebsd.init(); freebsd.init();
CPPUNIT_ASSERT ( keymap.key[left_alt].map[0] == 7 ); CPPUNIT_ASSERT ( keymap.key[left_alt].map[0] == 7 );
std::cerr << "cursur style: " << freebsd.getCursorStyle() << "\n";
CPPUNIT_ASSERT ( freebsd.getCursorStyle() == finalcut::fc::normal_cursor ); CPPUNIT_ASSERT ( freebsd.getCursorStyle() == finalcut::fc::normal_cursor );
freebsd.enableMetaSendsEscape(); freebsd.enableMetaSendsEscape();
freebsd.enableChangeCursorStyle(); freebsd.enableChangeCursorStyle();
freebsd.init(); freebsd.init();
CPPUNIT_ASSERT ( keymap.key[left_alt].map[0] == META ); CPPUNIT_ASSERT ( keymap.key[left_alt].map[0] == META );
CPPUNIT_ASSERT ( freebsd.getCursorStyle() == finalcut::fc::destructive_cursor ); CPPUNIT_ASSERT ( freebsd.getCursorStyle() == finalcut::fc::destructive_cursor );
freebsd.setCursorStyle(finalcut::fc::blink_cursor, false); freebsd.setCursorStyle(finalcut::fc::blink_cursor);
freebsd.restoreCursorStyle(); freebsd.setCursorStyle(freebsd.getCursorStyle());
CPPUNIT_ASSERT ( freebsd.getCursorStyle() == finalcut::fc::blink_cursor ); CPPUNIT_ASSERT ( freebsd.getCursorStyle() == finalcut::fc::blink_cursor );
CPPUNIT_ASSERT ( finalcut::fc::character[2][finalcut::fc::PC] == 21 ); CPPUNIT_ASSERT ( finalcut::fc::character[2][finalcut::fc::PC] == 21 );
@ -703,7 +702,7 @@ void ftermfreebsdTest::freebsdConsoleTest()
CPPUNIT_ASSERT ( finalcut::fc::character[60][finalcut::fc::PC] == 17 ); CPPUNIT_ASSERT ( finalcut::fc::character[60][finalcut::fc::PC] == 17 );
CPPUNIT_ASSERT ( finalcut::fc::character[105][finalcut::fc::PC] == 4 ); CPPUNIT_ASSERT ( finalcut::fc::character[105][finalcut::fc::PC] == 4 );
freebsd.initCharMap (finalcut::fc::character); freebsd.initCharMap();
CPPUNIT_ASSERT ( finalcut::fc::character[2][finalcut::fc::PC] == 36 ); CPPUNIT_ASSERT ( finalcut::fc::character[2][finalcut::fc::PC] == 36 );
CPPUNIT_ASSERT ( finalcut::fc::character[3][finalcut::fc::PC] == 42 ); CPPUNIT_ASSERT ( finalcut::fc::character[3][finalcut::fc::PC] == 42 );
@ -739,13 +738,14 @@ void ftermfreebsdTest::freebsdConsoleTest()
CPPUNIT_ASSERT ( ! data->hasShadowCharacter() ); CPPUNIT_ASSERT ( ! data->hasShadowCharacter() );
CPPUNIT_ASSERT ( ! data->hasHalfBlockCharacter() ); CPPUNIT_ASSERT ( ! data->hasHalfBlockCharacter() );
freebsd.setCursorStyle (finalcut::fc::normal_cursor, false); data->setCursorHidden (false);
freebsd.setCursorStyle (finalcut::fc::normal_cursor);
CPPUNIT_ASSERT ( fsystest->getCursorType() == finalcut::fc::normal_cursor ); CPPUNIT_ASSERT ( fsystest->getCursorType() == finalcut::fc::normal_cursor );
freebsd.setCursorStyle (finalcut::fc::blink_cursor, false); freebsd.setCursorStyle (finalcut::fc::blink_cursor);
CPPUNIT_ASSERT ( fsystest->getCursorType() == finalcut::fc::blink_cursor ); CPPUNIT_ASSERT ( fsystest->getCursorType() == finalcut::fc::blink_cursor );
freebsd.setCursorStyle (finalcut::fc::destructive_cursor, false); freebsd.setCursorStyle (finalcut::fc::destructive_cursor);
CPPUNIT_ASSERT ( fsystest->getCursorType() == finalcut::fc::destructive_cursor ); CPPUNIT_ASSERT ( fsystest->getCursorType() == finalcut::fc::destructive_cursor );
std::string& characters = fsystest->getCharacters(); std::string& characters = fsystest->getCharacters();

View File

@ -38,24 +38,6 @@
#include <conemu.h> #include <conemu.h>
#include <final/final.h> #include <final/final.h>
#define CPPUNIT_ASSERT_CSTRING(expected, actual) \
check_c_string (expected, actual, CPPUNIT_SOURCELINE())
//----------------------------------------------------------------------
void check_c_string ( const char* s1
, const char* s2
, CppUnit::SourceLine sourceLine )
{
if ( s1 == 0 && s2 == 0 ) // Strings are equal
return;
if ( s1 && s2 && std::strcmp (s1, s2) == 0 ) // Strings are equal
return;
::CppUnit::Asserter::fail ("Strings are not equal", sourceLine);
}
namespace test namespace test
{ {
@ -1600,13 +1582,15 @@ void FTermLinuxTest::linuxConsoleTest()
CPPUNIT_ASSERT ( characters == CSI "10;750]" CSI "11;125]" ); CPPUNIT_ASSERT ( characters == CSI "10;750]" CSI "11;125]" );
characters.clear(); characters.clear();
linux.initCharMap (finalcut::fc::character); linux.initCharMap();
auto& character_map = data->getCharSubstitutionMap(); auto& character_map = data->getCharSubstitutionMap();
CPPUNIT_ASSERT ( character_map.size() == 3 ); CPPUNIT_ASSERT ( character_map.size() == 3 );
CPPUNIT_ASSERT ( character_map[finalcut::fc::BlackCircle] == L'*' ); CPPUNIT_ASSERT ( character_map[finalcut::fc::BlackCircle] == L'*' );
CPPUNIT_ASSERT ( character_map[finalcut::fc::Times] == L'x' ); CPPUNIT_ASSERT ( character_map[finalcut::fc::Times] == L'x' );
CPPUNIT_ASSERT ( character_map[L'ˣ'] == L'' ); CPPUNIT_ASSERT ( character_map[L'ˣ'] == L'' );
linux.finish();
closeConEmuStdStreams(); closeConEmuStdStreams();
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} }
@ -1619,7 +1603,6 @@ void FTermLinuxTest::linuxConsoleTest()
std::cerr << "waitpid error" << std::endl; std::cerr << "waitpid error" << std::endl;
} }
linux.finish();
delete fsys; delete fsys;
} }
@ -1653,7 +1636,7 @@ void FTermLinuxTest::linuxCursorStyleTest()
data->supportShadowCharacter (false); data->supportShadowCharacter (false);
data->supportHalfBlockCharacter (false); data->supportHalfBlockCharacter (false);
data->supportCursorOptimisation (true); data->supportCursorOptimisation (true);
data->setCursorHidden (true); data->setCursorHidden (false);
data->useAlternateScreen (false); data->useAlternateScreen (false);
data->setASCIIConsole (true); data->setASCIIConsole (true);
data->setVT100Console (false); data->setVT100Console (false);
@ -1667,8 +1650,6 @@ void FTermLinuxTest::linuxCursorStyleTest()
term_detection = finalcut::FTerm::getFTermDetection(); term_detection = finalcut::FTerm::getFTermDetection();
finalcut::FTermLinux linux; finalcut::FTermLinux linux;
term_detection->setLinuxTerm(true);
pid_t pid = forkConEmu(); pid_t pid = forkConEmu();
if ( isConEmuChildProcess(pid) ) if ( isConEmuChildProcess(pid) )
@ -1689,65 +1670,102 @@ void FTermLinuxTest::linuxCursorStyleTest()
term_detection->detect(); term_detection->detect();
linux.init(); linux.init();
char* cursorstyle; test::FSystemTest* fsystest = static_cast<test::FSystemTest*>(fsys);
cursorstyle = linux.setCursorStyle (finalcut::fc::default_cursor, false); std::string& characters = fsystest->getCharacters();
CPPUNIT_ASSERT_CSTRING ( cursorstyle, CSI "?0c" ); characters.clear();
linux.setCursorStyle (finalcut::fc::default_cursor);
CPPUNIT_ASSERT ( characters == CSI "?0c" );
CPPUNIT_ASSERT ( linux.getCursorStyle() == finalcut::fc::default_cursor ); CPPUNIT_ASSERT ( linux.getCursorStyle() == finalcut::fc::default_cursor );
cursorstyle = linux.setCursorStyle (finalcut::fc::invisible_cursor, false); characters.clear();
CPPUNIT_ASSERT_CSTRING ( cursorstyle, CSI "?1c" ); linux.setCursorStyle (finalcut::fc::invisible_cursor);
CPPUNIT_ASSERT ( characters == CSI "?1c" );
CPPUNIT_ASSERT ( linux.getCursorStyle() == finalcut::fc::invisible_cursor ); CPPUNIT_ASSERT ( linux.getCursorStyle() == finalcut::fc::invisible_cursor );
cursorstyle = linux.setCursorStyle (finalcut::fc::underscore_cursor, false); characters.clear();
CPPUNIT_ASSERT_CSTRING ( cursorstyle, CSI "?2c" ); linux.setCursorStyle (finalcut::fc::underscore_cursor);
CPPUNIT_ASSERT ( characters == CSI "?2c" );
CPPUNIT_ASSERT ( linux.getCursorStyle() == finalcut::fc::underscore_cursor ); CPPUNIT_ASSERT ( linux.getCursorStyle() == finalcut::fc::underscore_cursor );
cursorstyle = linux.setCursorStyle (finalcut::fc::lower_third_cursor, false); characters.clear();
CPPUNIT_ASSERT_CSTRING ( cursorstyle, CSI "?3c" ); linux.setCursorStyle (finalcut::fc::lower_third_cursor);
CPPUNIT_ASSERT ( characters == CSI "?3c" );
CPPUNIT_ASSERT ( linux.getCursorStyle() == finalcut::fc::lower_third_cursor ); CPPUNIT_ASSERT ( linux.getCursorStyle() == finalcut::fc::lower_third_cursor );
cursorstyle = linux.setCursorStyle (finalcut::fc::lower_half_cursor, false); characters.clear();
CPPUNIT_ASSERT_CSTRING ( cursorstyle, CSI "?4c" ); linux.setCursorStyle (finalcut::fc::lower_half_cursor);
CPPUNIT_ASSERT ( characters == CSI "?4c" );
CPPUNIT_ASSERT ( linux.getCursorStyle() == finalcut::fc::lower_half_cursor ); CPPUNIT_ASSERT ( linux.getCursorStyle() == finalcut::fc::lower_half_cursor );
cursorstyle = linux.setCursorStyle (finalcut::fc::two_thirds_cursor, false); characters.clear();
CPPUNIT_ASSERT_CSTRING ( cursorstyle, CSI "?5c" ); linux.setCursorStyle (finalcut::fc::two_thirds_cursor);
CPPUNIT_ASSERT ( characters == CSI "?5c" );
CPPUNIT_ASSERT ( linux.getCursorStyle() == finalcut::fc::two_thirds_cursor ); CPPUNIT_ASSERT ( linux.getCursorStyle() == finalcut::fc::two_thirds_cursor );
cursorstyle = linux.setCursorStyle (finalcut::fc::full_block_cursor, false); characters.clear();
CPPUNIT_ASSERT_CSTRING ( cursorstyle, CSI "?6c" ); linux.setCursorStyle (finalcut::fc::full_block_cursor);
CPPUNIT_ASSERT ( characters == CSI "?6c" );
CPPUNIT_ASSERT ( linux.getCursorStyle() == finalcut::fc::full_block_cursor ); CPPUNIT_ASSERT ( linux.getCursorStyle() == finalcut::fc::full_block_cursor );
characters.clear();
cursorstyle = linux.setCursorStyle (finalcut::fc::default_cursor, true); linux.setCursorStyle (finalcut::fc::default_cursor);
CPPUNIT_ASSERT_CSTRING ( cursorstyle, "" ); CPPUNIT_ASSERT ( characters == CSI "?0c" );
CPPUNIT_ASSERT ( linux.getCursorStyle() == finalcut::fc::default_cursor ); CPPUNIT_ASSERT ( linux.getCursorStyle() == finalcut::fc::default_cursor );
cursorstyle = linux.restoreCursorStyle(); characters.clear();
CPPUNIT_ASSERT_CSTRING ( cursorstyle, CSI "?0c" ); linux.setCursorStyle (linux.getCursorStyle());
CPPUNIT_ASSERT ( characters == CSI "?0c" );
CPPUNIT_ASSERT ( linux.getCursorStyle() == finalcut::fc::default_cursor ); CPPUNIT_ASSERT ( linux.getCursorStyle() == finalcut::fc::default_cursor );
cursorstyle = linux.setCursorStyle (finalcut::fc::invisible_cursor, true); characters.clear();
CPPUNIT_ASSERT_CSTRING ( cursorstyle, "" ); data->setCursorHidden (true);
linux.setCursorStyle (finalcut::fc::invisible_cursor);
data->setCursorHidden (false);
CPPUNIT_ASSERT ( characters == "" );
CPPUNIT_ASSERT ( linux.getCursorStyle() == finalcut::fc::invisible_cursor ); CPPUNIT_ASSERT ( linux.getCursorStyle() == finalcut::fc::invisible_cursor );
cursorstyle = linux.restoreCursorStyle(); characters.clear();
CPPUNIT_ASSERT_CSTRING ( cursorstyle, CSI "?1c" ); linux.setCursorStyle (linux.getCursorStyle());
cursorstyle = linux.setCursorStyle (finalcut::fc::underscore_cursor, true); CPPUNIT_ASSERT ( characters == CSI "?1c" );
CPPUNIT_ASSERT_CSTRING ( cursorstyle, "" ); characters.clear();
data->setCursorHidden (true);
linux.setCursorStyle (finalcut::fc::underscore_cursor);
data->setCursorHidden (false);
CPPUNIT_ASSERT ( characters == "" );
CPPUNIT_ASSERT ( linux.getCursorStyle() == finalcut::fc::underscore_cursor ); CPPUNIT_ASSERT ( linux.getCursorStyle() == finalcut::fc::underscore_cursor );
cursorstyle = linux.restoreCursorStyle(); characters.clear();
CPPUNIT_ASSERT_CSTRING ( cursorstyle, CSI "?2c" ); linux.setCursorStyle (linux.getCursorStyle());
cursorstyle = linux.setCursorStyle (finalcut::fc::lower_third_cursor, true); CPPUNIT_ASSERT ( characters == CSI "?2c" );
CPPUNIT_ASSERT_CSTRING ( cursorstyle, "" ); characters.clear();
data->setCursorHidden (true);
linux.setCursorStyle (finalcut::fc::lower_third_cursor);
data->setCursorHidden (false);
CPPUNIT_ASSERT ( characters == "" );
CPPUNIT_ASSERT ( linux.getCursorStyle() == finalcut::fc::lower_third_cursor ); CPPUNIT_ASSERT ( linux.getCursorStyle() == finalcut::fc::lower_third_cursor );
cursorstyle = linux.restoreCursorStyle(); characters.clear();
CPPUNIT_ASSERT_CSTRING ( cursorstyle, CSI "?3c" ); linux.setCursorStyle (linux.getCursorStyle());
cursorstyle = linux.setCursorStyle (finalcut::fc::lower_half_cursor, true); CPPUNIT_ASSERT ( characters == CSI "?3c" );
CPPUNIT_ASSERT_CSTRING ( cursorstyle, "" ); characters.clear();
data->setCursorHidden (true);
linux.setCursorStyle (finalcut::fc::lower_half_cursor);
data->setCursorHidden (false);
CPPUNIT_ASSERT ( characters == "" );
CPPUNIT_ASSERT ( linux.getCursorStyle() == finalcut::fc::lower_half_cursor ); CPPUNIT_ASSERT ( linux.getCursorStyle() == finalcut::fc::lower_half_cursor );
cursorstyle = linux.restoreCursorStyle(); characters.clear();
CPPUNIT_ASSERT_CSTRING ( cursorstyle, CSI "?4c" ); linux.setCursorStyle (linux.getCursorStyle());
cursorstyle = linux.setCursorStyle (finalcut::fc::two_thirds_cursor, true); CPPUNIT_ASSERT ( characters == CSI "?4c" );
CPPUNIT_ASSERT_CSTRING ( cursorstyle, "" ); characters.clear();
data->setCursorHidden (true);
linux.setCursorStyle (finalcut::fc::two_thirds_cursor);
data->setCursorHidden (false);
CPPUNIT_ASSERT ( characters == "" );
CPPUNIT_ASSERT ( linux.getCursorStyle() == finalcut::fc::two_thirds_cursor ); CPPUNIT_ASSERT ( linux.getCursorStyle() == finalcut::fc::two_thirds_cursor );
cursorstyle = linux.restoreCursorStyle(); characters.clear();
CPPUNIT_ASSERT_CSTRING ( cursorstyle, CSI "?5c" ); linux.setCursorStyle (linux.getCursorStyle());
cursorstyle = linux.setCursorStyle (finalcut::fc::full_block_cursor, true); CPPUNIT_ASSERT ( characters == CSI "?5c" );
CPPUNIT_ASSERT_CSTRING ( cursorstyle, "" ); characters.clear();
data->setCursorHidden (true);
linux.setCursorStyle (finalcut::fc::full_block_cursor);
data->setCursorHidden (false);
CPPUNIT_ASSERT ( characters == "" );
CPPUNIT_ASSERT ( linux.getCursorStyle() == finalcut::fc::full_block_cursor ); CPPUNIT_ASSERT ( linux.getCursorStyle() == finalcut::fc::full_block_cursor );
cursorstyle = linux.restoreCursorStyle(); characters.clear();
CPPUNIT_ASSERT_CSTRING ( cursorstyle, CSI "?6c" ); linux.setCursorStyle (linux.getCursorStyle());
CPPUNIT_ASSERT ( characters == CSI "?6c" );
characters.clear();
linux.finish();
closeConEmuStdStreams(); closeConEmuStdStreams();
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
@ -1761,7 +1779,6 @@ void FTermLinuxTest::linuxCursorStyleTest()
std::cerr << "waitpid error" << std::endl; std::cerr << "waitpid error" << std::endl;
} }
linux.finish();
delete fsys; delete fsys;
} }
@ -2026,6 +2043,8 @@ void FTermLinuxTest::linuxColorPaletteTest()
CPPUNIT_ASSERT ( linux.resetColorMap() == true ); CPPUNIT_ASSERT ( linux.resetColorMap() == true );
linux.finish();
closeConEmuStdStreams(); closeConEmuStdStreams();
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} }
@ -2038,7 +2057,6 @@ void FTermLinuxTest::linuxColorPaletteTest()
std::cerr << "waitpid error" << std::endl; std::cerr << "waitpid error" << std::endl;
} }
linux.finish();
delete fsys; delete fsys;
} }
@ -2148,7 +2166,7 @@ void FTermLinuxTest::linuxFontTest()
CPPUNIT_ASSERT ( font.data[249 * 32 + 14] == 0x00 ); CPPUNIT_ASSERT ( font.data[249 * 32 + 14] == 0x00 );
CPPUNIT_ASSERT ( font.data[249 * 32 + 15] == 0x00 ); CPPUNIT_ASSERT ( font.data[249 * 32 + 15] == 0x00 );
linux.loadOldFont(finalcut::fc::character); linux.loadOldFont();
CPPUNIT_ASSERT ( ! linux.isVGAFontUsed() ); CPPUNIT_ASSERT ( ! linux.isVGAFontUsed() );
CPPUNIT_ASSERT ( ! linux.isNewFontUsed() ); CPPUNIT_ASSERT ( ! linux.isNewFontUsed() );
@ -2170,6 +2188,8 @@ void FTermLinuxTest::linuxFontTest()
CPPUNIT_ASSERT ( font.data[249 * 32 + 14] == 0x00 ); CPPUNIT_ASSERT ( font.data[249 * 32 + 14] == 0x00 );
CPPUNIT_ASSERT ( font.data[249 * 32 + 15] == 0x00 ); CPPUNIT_ASSERT ( font.data[249 * 32 + 15] == 0x00 );
linux.finish();
closeConEmuStdStreams(); closeConEmuStdStreams();
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} }
@ -2182,7 +2202,6 @@ void FTermLinuxTest::linuxFontTest()
std::cerr << "waitpid error" << std::endl; std::cerr << "waitpid error" << std::endl;
} }
linux.finish();
delete fsys; delete fsys;
} }