Update list of wide characters
[centerim5.git] / tests / textview.cpp
blobd9930ce311b0c51f8ec64c63d2b9408fd96725a3
1 #include <cppconsui/ColorScheme.h>
2 #include <cppconsui/KeyConfig.h>
3 #include <cppconsui/TextView.h>
4 #include <cppconsui/Window.h>
6 // TestWindow class
7 class TestWindow : public CppConsUI::Window {
8 public:
9 TestWindow();
10 virtual ~TestWindow() override {}
12 protected:
13 const int SCHEME_TEXTVIEWWINDOW = 1;
14 CppConsUI::TextView *textview;
16 private:
17 void actionToggleScrollbar();
19 CONSUI_DISABLE_COPY(TestWindow);
22 TestWindow::TestWindow() : CppConsUI::Window(0, 0, AUTOSIZE, AUTOSIZE)
24 setClosable(false);
25 setColorScheme(SCHEME_TEXTVIEWWINDOW);
27 textview = new CppConsUI::TextView(AUTOSIZE, AUTOSIZE);
28 addWidget(*textview, 1, 1);
30 const char *long_text =
31 "Lorem ipsum dolor sit amet, consectetur"
32 "adipiscing elit. Duis dui dui, interdum eget tempor auctor, viverra"
33 "suscipit velit. Phasellus vel magna odio. Duis rutrum tortor at nisi"
34 "auctor tincidunt. Mauris libero neque, faucibus sit amet semper in, "
35 "dictum ut tortor. Duis lacinia justo non lorem blandit ultrices."
36 "Nullam vel purus erat, eget aliquam massa. Aenean eget mi a nunc"
37 "lacinia consectetur sed a neque. Cras varius, dolor nec rhoncus"
38 "ultricies, leo ipsum adipiscing mi, vel feugiat ipsum urna id "
39 "metus. Cras non pulvinar nisi. Vivamus nisi lorem, tempor tristique"
40 "cursus sit amet, ultricies interdum metus. Nullam tortor tortor, "
41 "iaculis sed tempor non, tincidunt ac mi. Quisque id diam vitae diam"
42 "dictum facilisis eget ac lacus. Vivamus at gravida felis. Curabitur"
43 "fermentum mattis eros, ut auctor urna tincidunt vitae. Praesent"
44 "tincidunt laoreet lobortis.";
45 for (int i = 0; i < 128; i++)
46 textview->append(long_text, i % 7 + 1);
48 COLORSCHEME->setAttributesExt(SCHEME_TEXTVIEWWINDOW,
49 CppConsUI::ColorScheme::PROPERTY_TEXTVIEW_TEXT, 1,
50 CppConsUI::Curses::Color::RED, CppConsUI::Curses::Color::BLACK);
51 COLORSCHEME->setAttributesExt(SCHEME_TEXTVIEWWINDOW,
52 CppConsUI::ColorScheme::PROPERTY_TEXTVIEW_TEXT, 2,
53 CppConsUI::Curses::Color::GREEN, CppConsUI::Curses::Color::BLACK);
54 COLORSCHEME->setAttributesExt(SCHEME_TEXTVIEWWINDOW,
55 CppConsUI::ColorScheme::PROPERTY_TEXTVIEW_TEXT, 3,
56 CppConsUI::Curses::Color::YELLOW, CppConsUI::Curses::Color::BLACK);
57 COLORSCHEME->setAttributesExt(SCHEME_TEXTVIEWWINDOW,
58 CppConsUI::ColorScheme::PROPERTY_TEXTVIEW_TEXT, 4,
59 CppConsUI::Curses::Color::BLUE, CppConsUI::Curses::Color::BLACK);
60 COLORSCHEME->setAttributesExt(SCHEME_TEXTVIEWWINDOW,
61 CppConsUI::ColorScheme::PROPERTY_TEXTVIEW_TEXT, 5,
62 CppConsUI::Curses::Color::MAGENTA, CppConsUI::Curses::Color::BLACK);
63 COLORSCHEME->setAttributesExt(SCHEME_TEXTVIEWWINDOW,
64 CppConsUI::ColorScheme::PROPERTY_TEXTVIEW_TEXT, 6,
65 CppConsUI::Curses::Color::CYAN, CppConsUI::Curses::Color::BLACK);
66 COLORSCHEME->setAttributesExt(SCHEME_TEXTVIEWWINDOW,
67 CppConsUI::ColorScheme::PROPERTY_TEXTVIEW_TEXT, 7,
68 CppConsUI::Curses::Color::WHITE, CppConsUI::Curses::Color::BLACK);
70 declareBindable("textviewwindow", "toggle-scrollbar",
71 sigc::mem_fun(this, &TestWindow::actionToggleScrollbar),
72 InputProcessor::BINDABLE_NORMAL);
75 void TestWindow::actionToggleScrollbar()
77 textview->setScrollBar(!textview->hasScrollBar());
80 void setupTest()
82 KEYCONFIG->bindKey("textviewwindow", "toggle-scrollbar", "F1");
84 // Create the main window.
85 auto win = new TestWindow;
86 win->show();
89 // vim: set tabstop=2 shiftwidth=2 textwidth=80 expandtab