SGRoptimizer improved

This commit is contained in:
Markus Gans 2020-02-20 00:06:39 +01:00
parent 164487096c
commit b23974858e
3 changed files with 20 additions and 4 deletions

View File

@ -1,5 +1,6 @@
2020-02-19 Markus Gans <guru.mail@muenster.de>
* Some small code improvements
* SGRoptimizer improved
2020-02-16 Markus Gans <guru.mail@muenster.de>
* Printing a FStyle object allows you to change video attributes

View File

@ -21,7 +21,7 @@
***********************************************************************/
#include <cstring>
#include <iostream>
#include "final/fc.h"
#include "final/sgr_optimizer.h"
@ -86,6 +86,10 @@ void SGRoptimizer::findParameter()
start = NOT_SET;
}
// Other content
if ( ! csi_parameter.empty() && i > csi_parameter.back().end + 2 )
break;
if ( esc && seq[i] == '[' ) // Esc [
csi = true;

View File

@ -269,11 +269,22 @@ void FOptiAttrTest::sgrOptimizerTest()
sgr_optimizer.optimize();
CPPUNIT_ASSERT_CSTRING ( buffer, C_STR(CSI "0;38;5;20;48;5;229m") );
std::strcpy(buffer, CSI "m" CSI "38;5;20m" XXXX<<< CSI "48;5;229m");
std::strcpy(buffer, CSI "m" CSI "38;5;20m" CSI "11;16H");
sgr_optimizer.optimize();
CPPUNIT_ASSERT_CSTRING ( buffer, C_STR(CSI "0;38;5;20;48;5;229m") );
CPPUNIT_ASSERT_CSTRING ( buffer, C_STR(CSI "0;38;5;20m" CSI "11;16H") );
std::strcpy(buffer, CSI "1;1H" CSI "m" CSI "38;5;35m");
sgr_optimizer.optimize();
CPPUNIT_ASSERT_CSTRING ( buffer, C_STR(CSI "1;1H" CSI "0;38;5;35m") );
std::strcpy(buffer, CSI "m" CSI "38;5;20m" CSI "11;16H" CSI "48;5;229m");
sgr_optimizer.optimize();
CPPUNIT_ASSERT_CSTRING ( buffer, C_STR(CSI "0;38;5;20m" CSI "11;16H" CSI "48;5;229m") );
std::strcpy(buffer, CSI "m" CSI "38;5;20m" "ABC" CSI "48;5;229m");
sgr_optimizer.optimize();
CPPUNIT_ASSERT_CSTRING ( buffer, C_STR(CSI "0;38;5;20mABC" CSI "48;5;229m") );
std::strcpy(buffer, CSI "m" CSI "1m" CSI "2m" CSI "3m" CSI "4m"
CSI "5m" CSI "7m" CSI "8m" CSI "9m");