Update list of wide characters
[centerim5.git] / cppconsui / ConsUICurses.h
blob5a495a9e43a3eb9529008f01945d3c2ed7b083ca
1 // Copyright (C) 2007 Mark Pustjens <pustjens@dds.nl>
2 // Copyright (C) 2010-2015 Petr Pavlu <setup@dagobah.cz>
3 //
4 // This file is part of CenterIM.
5 //
6 // CenterIM is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
11 // CenterIM is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with CenterIM. If not, see <http://www.gnu.org/licenses/>.
19 /// @file
20 /// Wrapper for curses functions.
21 ///
22 /// @ingroup cppconsui
24 #ifndef CONSUICURSES_H
25 #define CONSUICURSES_H
27 #include "CppConsUI.h"
29 namespace CppConsUI {
31 namespace Curses {
33 enum LineChar {
34 LINE_HLINE,
35 LINE_VLINE,
36 LINE_LLCORNER,
37 LINE_LRCORNER,
38 LINE_ULCORNER,
39 LINE_URCORNER,
40 LINE_BTEE,
41 LINE_LTEE,
42 LINE_RTEE,
43 LINE_TTEE,
44 LINE_DARROW,
45 LINE_LARROW,
46 LINE_RARROW,
47 LINE_UARROW,
48 LINE_BULLET,
51 class ViewPort {
52 public:
53 ViewPort(int screen_x, int screen_y, int view_x, int view_y, int view_width,
54 int view_height);
55 virtual ~ViewPort() {}
57 /// Adds a string to the screen.
58 ///
59 /// First two variants require NUL-terminated strings.
60 int addString(
61 int x, int y, int w, const char *str, Error &error, int *printed = nullptr);
62 int addString(
63 int x, int y, const char *str, Error &error, int *printed = nullptr);
64 int addString(int x, int y, int w, const char *str, const char *end,
65 Error &error, int *printed = nullptr);
66 int addString(int x, int y, const char *str, const char *end, Error &error,
67 int *printed = nullptr);
69 int addChar(
70 int x, int y, UTF8::UniChar uc, Error &error, int *printed = nullptr);
71 int addLineChar(int x, int y, LineChar c, Error &error);
73 int attrOn(int attrs, Error &error);
74 int attrOff(int attrs, Error &error);
75 int changeAt(int x, int y, int n, /* attr_t */ unsigned long attr,
76 short color, Error &error);
78 int fill(int attrs, Error &error);
79 int fill(int attrs, int x, int y, int w, int h, Error &error);
80 int erase(Error &error);
82 void scroll(int scroll_x, int scroll_y);
84 int getScreenLeft() const { return screen_x_; }
85 int getScreenTop() const { return screen_y_; }
86 int getViewLeft() const { return view_x_; }
87 int getViewTop() const { return view_y_; }
88 int getViewWidth() const { return view_width_; }
89 int getViewHeight() const { return view_height_; }
91 protected:
92 int screen_x_, screen_y_;
93 int view_x_, view_y_, view_width_, view_height_;
95 bool isInViewPort(int x, int y, int w);
97 private:
98 // CONSUI_DISABLE_COPY(ViewPort);
101 struct Color {
102 const static int DEFAULT;
103 const static int BLACK;
104 const static int RED;
105 const static int GREEN;
106 const static int YELLOW;
107 const static int BLUE;
108 const static int MAGENTA;
109 const static int CYAN;
110 const static int WHITE;
113 struct Attr {
114 const static int NORMAL;
115 const static int STANDOUT;
116 const static int REVERSE;
117 const static int BLINK;
118 const static int DIM;
119 const static int BOLD;
122 const int NUM_DEFAULT_COLORS = 16;
124 int initScreen(Error &error);
125 int finalizeScreen(Error &error);
126 void setAsciiMode(bool enabled);
127 bool getAsciiMode();
129 bool initColorPair(int idx, int fg, int bg, int *res, Error &error);
130 int getColorCount();
131 int getColorPairCount();
133 int erase(Error &error);
134 int clear(Error &error);
135 int refresh(Error &error);
137 int beep(Error &error);
139 // stdscr
140 int getWidth();
141 int getHeight();
143 int resizeTerm(int width, int height, Error &error);
145 int onScreenWidth(const char *start, const char *end = nullptr);
146 int onScreenWidth(UTF8::UniChar uc, int w = 0);
148 } // namespace Curses
150 } // namespace CppConsUI
152 #endif // CONSUICURSES_H
154 // vim: set tabstop=2 shiftwidth=2 textwidth=80 expandtab: