1 // Copyright (C) 2007 Mark Pustjens <pustjens@dds.nl>
2 // Copyright (C) 2010-2015 Petr Pavlu <setup@dagobah.cz>
4 // This file is part of CenterIM.
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/>.
20 /// Wrapper for curses functions.
22 /// @ingroup cppconsui
24 #ifndef CONSUICURSES_H
25 #define CONSUICURSES_H
27 #include "CppConsUI.h"
53 ViewPort(int screen_x
, int screen_y
, int view_x
, int view_y
, int view_width
,
55 virtual ~ViewPort() {}
57 /// Adds a string to the screen.
59 /// First two variants require NUL-terminated strings.
61 int x
, int y
, int w
, const char *str
, Error
&error
, int *printed
= nullptr);
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);
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_
; }
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
);
98 // CONSUI_DISABLE_COPY(ViewPort);
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
;
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
);
129 bool initColorPair(int idx
, int fg
, int bg
, int *res
, Error
&error
);
131 int getColorPairCount();
133 int erase(Error
&error
);
134 int clear(Error
&error
);
135 int refresh(Error
&error
);
137 int beep(Error
&error
);
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: