1 
2 /**************************************************************************
3  * Copyright (C) 2007-2015 Ruben Pollan Bella <meskio@sindominio.net>     *
4  *                                                                        *
5  *  This file is part of TuDu.                                            *
6  *                                                                        *
7  *  TuDu is free software; you can redistribute it and/or modify          *
8  *  it under the terms of the GNU General Public License as published by  *
9  *  the Free Software Foundation; version 3 of the License.        *
10  *                                                                        *
11  *  TuDu 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.                          *
15  *                                                                        *
16  *  You should have received a copy of the GNU General Public License     *
17  *  along with this program.  If not, see <http://www.gnu.org/licenses/>. *
18  **************************************************************************/
19 
20 #ifndef TEXT_H
21 #define TEXT_H
22 
23 #include "includes.h"
24 #include "window.h"
25 
26 class Text
27 {
28 public:
29 	Text& operator=(const wstring& str);
30 	bool operator!=(const wstring& str);
31 	void print(Window& win);
32 	void edit(Window& win);
33 	wstring getStr();
34 	void scroll_up(Window& win);
35 	void scroll_down(Window& win);
36 private:
37 	list<wstring> text; /* list of lines */
38 	int cursor_col;
39 	int cursor_y; /* = INT_MIN when is no editing */
40 	list<wstring>::iterator cursor_line;
41 	list<wstring>::iterator offset; /* line for start to display */
42 	int lines, cols;
43 
44 	/* begin=line for start, length=num of screen lines to fit*/
45 	wstring _getStr(list<wstring>::iterator begin, int length = 0);
46 	bool _scroll_up();
47 	bool _scroll_down();
48 	void left();
49 	void right();
50 	void up();
51 	void down();
52 	void backspace();
53 	void supr();
54 	void home();
55 	void end();
56 	void next_page();
57 	void prev_page();
58 	void new_line();
59 	void tab();
60 };
61 
62 wostream& operator<<(wostream& os, Text& t);
63 wistream& operator>>(wistream& is, Text& t);
64 
65 #endif
66