File: text.h

package info (click to toggle)
eboard 1.1.1-4
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 2,548 kB
  • ctags: 2,803
  • sloc: cpp: 24,724; perl: 1,012; sh: 866; makefile: 66
file content (184 lines) | stat: -rw-r--r-- 4,358 bytes parent folder | download | duplicates (5)
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
/* $Id: text.h,v 1.25 2008/02/22 14:34:30 bergo Exp $ */

/*

    eboard - chess client
    http://eboard.sourceforge.net
    Copyright (C) 2000-2007 Felipe Paulo Guazzi Bergo
    bergo@seul.org

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

*/



#ifndef EBOARD_TEXT_H
#define EBOARD_TEXT_H 1

#include "eboard.h"
#include "widgetproxy.h"
#include "ntext.h"
#include "notebook.h"
#include "history.h"
#include "util.h"
#include "stl.h"

class OutputPane {
 public:
  virtual ~OutputPane();
  virtual void append(char *msg,int color,Importance imp=IM_NORMAL)=0;
  virtual void append(char *msg,char *msg2,int color,Importance imp=IM_NORMAL)=0;
  virtual void updateScrollBack()=0;
  virtual void updateFont()=0;
  virtual void setBackground(int color)=0;
};

class Searchable {
 public:
  virtual ~Searchable() {}
  virtual void execSearch()=0;
  string SearchString;
};

class TextFilter {
 public:
  TextFilter();
  ~TextFilter();
  
  void set(const char *t);
  const char *getString();

  bool accept(char *textline);

 private:
  string FilterString;
  bool AcceptedLast;
  void cleanUp();
  vector<ExtPatternMatcher *> thefilter;
};

class Text : public NText,
             public NotebookInsider,
             public OutputPane,
             public Searchable {
 public:
 Text();
 virtual ~Text();

  void append(char *msg,int color,Importance imp=IM_NORMAL);
  void append(char *msg,char *msg2,int color,Importance imp=IM_NORMAL);

  void pageUp();
  void pageDown();

  void setBackground(int color);
  void updateScrollBack();
  void updateFont();

  void saveBuffer();

  void findText();
  void findTextNext();

  void execSearch();

  TextFilter Filter;

 private:
  int linecount;
  int LastMatch;
};

class TextSet : public OutputPane {
 public:
  TextSet();
  ~TextSet();

  void addTarget(Text *target);
  void removeTarget(Text *target);

  void append(char *msg,int color,Importance imp=IM_NORMAL);
  void append(char *msg,char *msg2,int color,Importance imp=IM_NORMAL);

  void pageUp();
  void pageDown();

  void updateScrollBack();
  void updateFont();
  void setBackground(int color);

 private:
  list<Text *> targets;
};

class DetachedConsole : public WidgetProxy {
 public:
  DetachedConsole(TextSet *yourset, ConsoleListener *cl);
  virtual ~DetachedConsole();

  const char *getFilter();

  void show();
  void setFilter(char *s);
  void setPasswordMode(int pm);

 private:
  Text *inner;
  TextSet *myset;
  GtkWidget *inputbox;
  ConsoleListener *listener;
  History::iterator hcursor;
  int focus_sig_id;
  string basetitle;
  GtkWidget *flabel;

  static int ConsoleCount;

  void injectInput();
  void historyUp();
  void historyDown();

  void clone();
  void updateFilterLabel();

  friend gint detached_delete  (GtkWidget * widget, GdkEvent * event, gpointer data);
  friend void detached_destroy (GtkWidget * widget, gpointer data);
  friend int  dc_input_key_press (GtkWidget * wid, GdkEventKey * evt,
				  gpointer data);
  friend void dc_set_filter(GtkWidget *w,gpointer data);
  friend void dc_new_console(GtkWidget *w,gpointer data);
};

gint detached_delete  (GtkWidget * widget, GdkEvent * event, gpointer data);
void detached_destroy (GtkWidget * widget, gpointer data);
int  dc_input_key_press (GtkWidget * wid, GdkEventKey * evt,
				gpointer data);
void dc_set_filter(GtkWidget *w,gpointer data);
void dc_new_console(GtkWidget *w,gpointer data);

class TextFilterDialog : public ModalDialog {
 public:
  TextFilterDialog(Text *target, GtkWidget *label2update);
 private:
  GtkWidget *pattern;
  Text *obj;
  GtkWidget *ulabel;
  friend void tfd_ok(GtkWidget *w, gpointer data);
};

void tfd_ok(GtkWidget *w, gpointer data);

#endif