diff --git a/ChangeLog b/ChangeLog index 0d720c41..e6b04a2d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2018-11-24 Markus Gans + * Improved Sun Microsystems workstation console quirks + 2018-11-21 Markus Gans * New type FKey for key inputs * The integer type of FPoint and FRect changed from short to int diff --git a/README.md b/README.md index 1347b99e..47c30e97 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ ============================================ ### Building and code analysis +*Latest release:*
+     [![Latest Release](https://img.shields.io/github/release/gansm/finalcut.svg)](https://github.com/gansm/finalcut/releases)
*Travis CI:*
     [![Build Status](https://travis-ci.org/gansm/finalcut.svg?branch=master)](https://travis-ci.org/gansm/finalcut)
*Coverity Scan:*
@@ -11,6 +13,7 @@ *Class Reference:*
     [![documented](https://codedocs.xyz/gansm/finalcut.svg)](https://codedocs.xyz/gansm/finalcut/hierarchy.html) +### Description The FINAL CUT is a C++ class library and widget toolkit with full mouse support for creating a [text-based user interface](https://en.wikipedia.org/wiki/Text-based_user_interface). The library supports the programmer to develop an application for the text console. It allows the simultaneous handling of multiple text windows on the screen. The structure of the Qt framework was originally the inspiration for the C++ class design of FINAL CUT. It provides common controls like dialog boxes, push buttons, check boxes, radio buttons, input lines, list boxes, status bars and so on. diff --git a/examples/term-attributes.cpp b/examples/term-attributes.cpp index 92a14cae..30a474ce 100644 --- a/examples/term-attributes.cpp +++ b/examples/term-attributes.cpp @@ -269,7 +269,10 @@ void AttribDemo::printAltCharset() } else { - if ( parent->bgcolor == 0 || parent->bgcolor == 16 ) + if ( (parent->bgcolor <= 8) + || (parent->bgcolor >= 16 && parent->bgcolor <= 231 + && (parent->bgcolor - 16) % 36 <= 17) + || (parent->bgcolor >= 232 && parent->bgcolor <= 243) ) setColor (finalcut::fc::White, parent->bgcolor); else setColor (finalcut::fc::Black, parent->bgcolor); diff --git a/src/fkey_map.cpp b/src/fkey_map.cpp index 61f69b98..85f79a19 100644 --- a/src/fkey_map.cpp +++ b/src/fkey_map.cpp @@ -36,6 +36,7 @@ fkeymap Fkey[] = { fc::Fkey_clear , 0, "kC" }, // clear-screen or erase key { fc::Fkey_ctab , 0, "kt" }, // clear-tab key { fc::Fkey_dc , 0, "kD" }, // delete-character key + { fc::Fkey_dc , 0, "kDx"}, // keypad delete { fc::Fkey_dl , 0, "kL" }, // delete-line key { fc::Fkey_down , 0, "kd" }, // down-arrow key { fc::Fkey_down , 0, "kdx"}, // down-arrow key diff --git a/src/ftermcapquirks.cpp b/src/ftermcapquirks.cpp index 87d239e3..0b0226ba 100644 --- a/src/ftermcapquirks.cpp +++ b/src/ftermcapquirks.cpp @@ -390,6 +390,87 @@ void FTermcapQuirks::sunConsole() { // Sun Microsystems workstation console eat_nl_glitch fix FTermcap::eat_nl_glitch = true; + + // Sun Microsystems workstation console parameter cursor control + TCAP(fc::t_parm_up_cursor) = \ + C_STR(CSI "%p1%dA"); + + TCAP(fc::t_parm_down_cursor) = \ + C_STR(CSI "%p1%dB"); + + TCAP(fc::t_parm_right_cursor) = \ + C_STR(CSI "%p1%dC"); + + TCAP(fc::t_parm_left_cursor) = \ + C_STR(CSI "%p1%dD"); + + // Sun Microsystems workstation console keys + for (int i = 0; fc::Fkey[i].tname[0] != 0; i++) + { + if ( std::strncmp(fc::Fkey[i].tname, "K2", 2) == 0 ) + fc::Fkey[i].string = C_STR(CSI "218z"); // center of keypad + + if ( std::strncmp(fc::Fkey[i].tname, "kb", 2) == 0 ) + fc::Fkey[i].string = C_STR("\b"); // backspace key + + if ( std::strncmp(fc::Fkey[i].tname, "kD", 2) == 0 + && std::strlen(fc::Fkey[i].tname) == 2 ) + fc::Fkey[i].string = C_STR("\177"); // delete-character key + + if ( std::strncmp(fc::Fkey[i].tname, "@7", 2) == 0 ) + fc::Fkey[i].string = C_STR(CSI "220z"); // end key + + if ( std::strncmp(fc::Fkey[i].tname, "k;", 2) == 0 ) + fc::Fkey[i].string = C_STR(CSI "233z"); // F10 function key + + if ( std::strncmp(fc::Fkey[i].tname, "F1", 2) == 0 ) + fc::Fkey[i].string = C_STR(CSI "234z"); // F11 function key + + if ( std::strncmp(fc::Fkey[i].tname, "F2", 2) == 0 ) + fc::Fkey[i].string = C_STR(CSI "235z"); // F12 function key + + if ( std::strncmp(fc::Fkey[i].tname, "kh", 2) == 0 ) + fc::Fkey[i].string = C_STR(CSI "214z"); // home key + + if ( std::strncmp(fc::Fkey[i].tname, "kI", 2) == 0 ) + fc::Fkey[i].string = C_STR(CSI "247z"); // insert-character key + + if ( std::strncmp(fc::Fkey[i].tname, "kN", 2) == 0 ) + fc::Fkey[i].string = C_STR(CSI "222z"); // next-page key + + if ( std::strncmp(fc::Fkey[i].tname, "%7", 2) == 0 ) + fc::Fkey[i].string = C_STR(CSI "194z"); // options key + + if ( std::strncmp(fc::Fkey[i].tname, "kP", 2) == 0 ) + fc::Fkey[i].string = C_STR(CSI "216z"); // prev-page key + + if ( std::strncmp(fc::Fkey[i].tname, "&5", 2) == 0 ) + fc::Fkey[i].string = C_STR(CSI "193z"); // resume key + + if ( std::strncmp(fc::Fkey[i].tname, "&8", 2) == 0 ) + fc::Fkey[i].string = C_STR(CSI "195z"); // undo key + + if ( std::strncmp(fc::Fkey[i].tname, "K2", 2) == 0 ) + fc::Fkey[i].string = C_STR(CSI "218z"); // center of keypad + + if ( std::strncmp(fc::Fkey[i].tname, "kDx", 3) == 0 ) + fc::Fkey[i].string = C_STR(CSI "249z"); // keypad delete + + if ( std::strncmp(fc::Fkey[i].tname, "@8x", 3) == 0 ) + fc::Fkey[i].string = C_STR(CSI "250z"); // enter/send key + + if ( std::strncmp(fc::Fkey[i].tname, "KP1", 3) == 0 ) + fc::Fkey[i].string = C_STR(CSI "212z"); // keypad slash + + if ( std::strncmp(fc::Fkey[i].tname, "KP2", 3) == 0 ) + fc::Fkey[i].string = C_STR(CSI "213z"); // keypad asterisk + + if ( std::strncmp(fc::Fkey[i].tname, "KP3", 3) == 0 ) + fc::Fkey[i].string = C_STR(CSI "254z"); // keypad minus sign + + if ( std::strncmp(fc::Fkey[i].tname, "KP4", 3) == 0 ) + fc::Fkey[i].string = C_STR(CSI "253z"); // keypad plus sign + } } //---------------------------------------------------------------------- diff --git a/src/include/final/fterm.h b/src/include/final/fterm.h index bfa4699e..4d023480 100644 --- a/src/include/final/fterm.h +++ b/src/include/final/fterm.h @@ -264,7 +264,7 @@ class FTerm static void putstringf (const char[], ...) #if defined(__clang__) - __attribute__((__format__ (__printf__, 1, 2))) + __attribute__ ((__format__ (__printf__, 1, 2))) #elif defined(__GNUC__) __attribute__ ((format (printf, 1, 2))) #endif diff --git a/test/ftermcapquirks-test.cpp b/test/ftermcapquirks-test.cpp index 5913c9b9..5f801300 100644 --- a/test/ftermcapquirks-test.cpp +++ b/test/ftermcapquirks-test.cpp @@ -660,6 +660,12 @@ void FTermcapQuirksTest::teratermTest() //---------------------------------------------------------------------- void FTermcapQuirksTest::sunTest() { + finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapMap(); + const int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; + + for (int i = 0; i < last_item; i++) + memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0])); + finalcut::FTermData data; finalcut::FTermcap::eat_nl_glitch = false; finalcut::FTermcapQuirks quirks; @@ -671,6 +677,102 @@ void FTermcapQuirksTest::sunTest() quirks.terminalFixup(); CPPUNIT_ASSERT ( finalcut::FTermcap::eat_nl_glitch == true ); + CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_parm_up_cursor].string + , C_STR(CSI "%p1%dA") ); + CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_parm_down_cursor].string + , C_STR(CSI "%p1%dB") ); + CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_parm_right_cursor].string + , C_STR(CSI "%p1%dC") ); + CPPUNIT_ASSERT_CSTRING ( caps[finalcut::fc::t_parm_left_cursor].string + , C_STR(CSI "%p1%dD") ); + + for (int i = 0; finalcut::fc::Fkey[i].tname[0] != 0; i++) + { + if ( std::strncmp(finalcut::fc::Fkey[i].tname, "K2", 2) == 0 ) // center of keypad + CPPUNIT_ASSERT_CSTRING ( finalcut::fc::Fkey[i].string + , C_STR(CSI "218z") ); + + if ( std::strncmp(finalcut::fc::Fkey[i].tname, "kb", 2) == 0 ) // backspace key + CPPUNIT_ASSERT_CSTRING ( finalcut::fc::Fkey[i].string + , C_STR("\b") ); + + if ( std::strncmp(finalcut::fc::Fkey[i].tname, "kD", 2) == 0 + && std::strlen(finalcut::fc::Fkey[i].tname) == 2 ) // delete-character key + CPPUNIT_ASSERT_CSTRING ( finalcut::fc::Fkey[i].string + , C_STR("\177") ); + + if ( std::strncmp(finalcut::fc::Fkey[i].tname, "@7", 2) == 0 ) // end key + CPPUNIT_ASSERT_CSTRING ( finalcut::fc::Fkey[i].string + , C_STR(CSI "220z") ); + + if ( std::strncmp(finalcut::fc::Fkey[i].tname, "k;", 2) == 0 ) // F10 function key + CPPUNIT_ASSERT_CSTRING ( finalcut::fc::Fkey[i].string + , C_STR(CSI "233z") ); + + if ( std::strncmp(finalcut::fc::Fkey[i].tname, "F1", 2) == 0 ) // F11 function key + CPPUNIT_ASSERT_CSTRING ( finalcut::fc::Fkey[i].string + , C_STR(CSI "234z") ); + + if ( std::strncmp(finalcut::fc::Fkey[i].tname, "F2", 2) == 0 ) // F12 function key + CPPUNIT_ASSERT_CSTRING ( finalcut::fc::Fkey[i].string + , C_STR(CSI "235z") ); + + if ( std::strncmp(finalcut::fc::Fkey[i].tname, "kh", 2) == 0 ) // home key + CPPUNIT_ASSERT_CSTRING ( finalcut::fc::Fkey[i].string + , C_STR(CSI "214z") ); + + if ( std::strncmp(finalcut::fc::Fkey[i].tname, "kI", 2) == 0 ) // insert-character key + CPPUNIT_ASSERT_CSTRING ( finalcut::fc::Fkey[i].string + , C_STR(CSI "247z") ); + + if ( std::strncmp(finalcut::fc::Fkey[i].tname, "kN", 2) == 0 ) // next-page key + CPPUNIT_ASSERT_CSTRING ( finalcut::fc::Fkey[i].string + , C_STR(CSI "222z") ); + + if ( std::strncmp(finalcut::fc::Fkey[i].tname, "%7", 2) == 0 ) // options key + CPPUNIT_ASSERT_CSTRING ( finalcut::fc::Fkey[i].string + , C_STR(CSI "194z") ); + + if ( std::strncmp(finalcut::fc::Fkey[i].tname, "kP", 2) == 0 ) // prev-page key + CPPUNIT_ASSERT_CSTRING ( finalcut::fc::Fkey[i].string + , C_STR(CSI "216z") ); + + if ( std::strncmp(finalcut::fc::Fkey[i].tname, "&5", 2) == 0 ) // resume key + CPPUNIT_ASSERT_CSTRING ( finalcut::fc::Fkey[i].string + , C_STR(CSI "193z") ); + + if ( std::strncmp(finalcut::fc::Fkey[i].tname, "&8", 2) == 0 ) // undo key + CPPUNIT_ASSERT_CSTRING ( finalcut::fc::Fkey[i].string + , C_STR(CSI "195z") ); + + if ( std::strncmp(finalcut::fc::Fkey[i].tname, "K2", 2) == 0 ) // center of keypad + CPPUNIT_ASSERT_CSTRING ( finalcut::fc::Fkey[i].string + , C_STR(CSI "218z") ); + + if ( std::strncmp(finalcut::fc::Fkey[i].tname, "kDx", 3) == 0 ) // keypad delete + CPPUNIT_ASSERT_CSTRING ( finalcut::fc::Fkey[i].string + , C_STR(CSI "249z") ); + + if ( std::strncmp(finalcut::fc::Fkey[i].tname, "@8x", 3) == 0 ) // enter/send key + CPPUNIT_ASSERT_CSTRING ( finalcut::fc::Fkey[i].string + , C_STR(CSI "250z") ); + + if ( std::strncmp(finalcut::fc::Fkey[i].tname, "KP1", 3) == 0 ) // keypad slash + CPPUNIT_ASSERT_CSTRING ( finalcut::fc::Fkey[i].string + , C_STR(CSI "212z") ); + + if ( std::strncmp(finalcut::fc::Fkey[i].tname, "KP2", 3) == 0 ) // keypad asterisk + CPPUNIT_ASSERT_CSTRING ( finalcut::fc::Fkey[i].string + , C_STR(CSI "213z") ); + + if ( std::strncmp(finalcut::fc::Fkey[i].tname, "KP3", 3) == 0 ) // keypad minus sign + CPPUNIT_ASSERT_CSTRING ( finalcut::fc::Fkey[i].string + , C_STR(CSI "254z") ); + + if ( std::strncmp(finalcut::fc::Fkey[i].tname, "KP4", 3) == 0 ) // keypad plus sign + CPPUNIT_ASSERT_CSTRING ( finalcut::fc::Fkey[i].string + , C_STR(CSI "253z") ); + } detect.setSunTerminal (false); }