File: cursesscreen.H

package info (click to toggle)
cone 0.89-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 25,628 kB
  • ctags: 14,171
  • sloc: ansic: 85,400; cpp: 82,903; sh: 11,713; makefile: 1,732; perl: 832; yacc: 291; sed: 16
file content (92 lines) | stat: -rw-r--r-- 1,631 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
** Copyright 2002-2011, Double Precision Inc.
**
** See COPYING for distribution information.
*/

#ifndef cursesscreen_H
#define cursesscreen_H

#include "../curses/curses_config.h"
#include "../unicode/unicode.h"
#include "cursescontainer.H"

#if HAVE_NCURSESW_CURSES_H
#include <ncursesw/curses.h>
#else
#include <curses.h>
#endif

#include <iconv.h>
#include <vector>

//
// A libcurses implementation.  A CursesScreen object is typically the
// root object of the Curses hierarchy.  The constructor initializes libcurses,
// the destructor cleans it up.
//

class CursesScreen : public CursesContainer {

	int save_w, save_h; // Fix some libcurses.a resizing bugs.

	int inputcounter;

	bool underline_hack;

	// Read keyboard input, convert to unicode_chars

	class KeyReader {

		iconv_t h;

		std::vector<char> input_buf;
		std::vector<char> winput_buf;

		size_t winput_cnt;

	public:
		KeyReader();
		~KeyReader();

		void operator<<(char);

		bool operator>>(unicode_char &);
	};

	KeyReader keyreader;

	class repltabs_spaces;

public:
	CursesScreen();
	~CursesScreen();

	// Calculate max size.
	int getWidth() const;
	int getHeight() const;

	void flush();
	void draw();

	bool writeText(const char *text, int row, int col,
		       const Curses::CursesAttr &attr) const;

	bool writeText(const std::vector<unicode_char> &text, int row, int col,
		       const Curses::CursesAttr &attr) const;

	// Return keyboard input.  Returns Key::nokey() if no keyboard input
	// isavailable.
	Key getKey();

	void beepError();
private:

	Key doGetKey();
	Key doGetPlainKey(unicode_char);

public:
	void resized();
};

#endif