libt3widget
main.h
1 /* Copyright (C) 2011-2012 G.P. Halkes
2  This program is free software: you can redistribute it and/or modify
3  it under the terms of the GNU General Public License version 3, as
4  published by the Free Software Foundation.
5 
6  This program is distributed in the hope that it will be useful,
7  but WITHOUT ANY WARRANTY; without even the implied warranty of
8  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9  GNU General Public License for more details.
10 
11  You should have received a copy of the GNU General Public License
12  along with this program. If not, see <http://www.gnu.org/licenses/>.
13 */
14 #ifndef T3_WIDGET_MAIN_H
15 #define T3_WIDGET_MAIN_H
16 
17 #include <t3widget/util.h>
18 #include <t3widget/dialogs/dialog.h>
19 #include <t3widget/dialogs/insertchardialog.h>
20 #include <t3widget/dialogs/messagedialog.h>
21 
22 namespace t3_widget {
23 
37 #define T3_WIDGET_VERSION 0
38 
40 class T3_WIDGET_API complex_error_t {
41  public:
42  enum source_t{
43  SRC_NONE,
44  SRC_ERRNO,
45  SRC_TRANSCRIPT,
46  SRC_T3_KEY,
47  SRC_T3_WINDOW
48  };
49  private:
50  bool success;
51  source_t source;
52  int error;
53  const char *file_name;
54  int line_number;
55 
56  public:
57  complex_error_t(void);
58  complex_error_t(source_t _source, int _error, const char *_file_name = NULL, int _line_number = 0);
59  void set_error(source_t _source, int _error, const char *_file_name = NULL, int _line_number = 0);
60  bool get_success(void);
61  source_t get_source(void);
62  int get_error(void);
63  const char *get_string(void);
64 };
65 
68 class T3_WIDGET_API init_parameters_t {
69  public:
70  const char *program_name;
71  const char *term;
84 
86  static init_parameters_t *create(void);
87  private:
88  init_parameters_t(void);
89 };
90 
91 //FIXME: shouldn't these be internal?
93 T3_WIDGET_API extern insert_char_dialog_t *insert_char_dialog;
95 T3_WIDGET_API extern message_dialog_t *message_dialog;
96 
98 T3_WIDGET_API signals::connection connect_resize(const signals::slot<void, int, int> &slot);
102 T3_WIDGET_API signals::connection connect_update_notification(const signals::slot<void> &slot);
108 T3_WIDGET_API signals::connection connect_on_init(const signals::slot<void, bool> &slot);
113 T3_WIDGET_API signals::connection connect_terminal_settings_changed(const signals::slot<void> &slot);
114 
120 T3_WIDGET_API complex_error_t init(const init_parameters_t *params);
125 T3_WIDGET_API void restore(void);
131 T3_WIDGET_API void iterate(void);
136 T3_WIDGET_API int main_loop(void);
142 T3_WIDGET_API void suspend(void);
148 T3_WIDGET_API void redraw(void);
149 
155 T3_WIDGET_API void exit_main_loop(int exit_code)
156 #ifdef __GNUC__
157 __attribute__((noreturn))
158 #endif
159 ;
160 
166 T3_WIDGET_API void async_safe_exit_main_loop(int exit_code);
167 
176 T3_WIDGET_API void cleanup(void);
177 
184 T3_WIDGET_API bool set_color_mode(bool on);
188 T3_WIDGET_API void set_attribute(attribute_t attribute, t3_attr_t value);
192 T3_WIDGET_API t3_attr_t get_attribute(attribute_t attribute);
196 T3_WIDGET_API t3_attr_t get_default_attribute(attribute_t attribute, bool color_mode);
198 T3_WIDGET_API long get_version(void);
199 
201 T3_WIDGET_API long get_libt3key_version(void);
202 
204 T3_WIDGET_API long get_libt3window_version(void);
205 
207 T3_WIDGET_API void get_screen_size(int *height, int *width);
208 }; // namespace
209 
210 #endif
signals::connection connect_resize(const signals::slot< void, int, int > &slot)
Connect a callback to the resize signal.
Definition: main.cc:113
long get_version(void)
Get the version of the libt3widget library used at runtime.
Definition: main.cc:401
A class representing an error from one of the supporting libraries.
Definition: main.h:40
The t3_widget namespace is contains all classes, functions and global variables in the libt3widget li...
Definition: autocompleter.cc:18
void get_screen_size(int *height, int *width)
Get the dimensions of the screen as used by libt3widget.
Definition: main.cc:154
signals::connection connect_update_notification(const signals::slot< void > &slot)
Connect a callback to the update_notification signal.
Definition: main.cc:117
bool disable_external_clipboard
Boolean indicating whether to explicitly disable the external clipboard.
Definition: main.h:83
bool set_color_mode(bool on)
Control the color mode.
Definition: colorscheme.cc:37
void exit_main_loop(int retval)
Exit the main loop.
Definition: main.cc:368
long get_libt3window_version(void)
Get the version of the libt3window library used by libt3widget at runtime.
Definition: main.cc:409
void iterate(void)
Perform a single iteration of the main loop.
Definition: main.cc:320
long get_libt3key_version(void)
Get the version of the libt3key library used by libt3widget at runtime.
Definition: main.cc:405
void redraw(void)
Force a complete redraw of the terminal contents.
Definition: main.cc:396
message_dialog_t * message_dialog
Global message_dialog_t dialog.
Definition: main.cc:54
insert_char_dialog_t * insert_char_dialog
Global insert_char_dialog_t dialog.
Definition: main.cc:53
signals::connection connect_terminal_settings_changed(const signals::slot< void > &slot)
Connect a callback to the terminal_settings_changed signal.
Definition: main.cc:135
t3_attr_t get_attribute(attribute_t attribute)
Retrieve the setting of a default attribute.
Definition: colorscheme.cc:131
Definition: messagedialog.h:26
void cleanup(void)
Free memory used by libt3widget.
Definition: main.cc:372
Definition: insertchardialog.h:23
void restore(void)
Function to restore the terminal to the original settings.
Definition: main.cc:224
t3_attr_t get_default_attribute(attribute_t attribute, bool color_mode)
Retrieve the default setting of a default attribute.
Definition: colorscheme.cc:172
const char * program_name
Name of the program to print where appropriate.
Definition: main.h:70
complex_error_t init(const init_parameters_t *params)
Initialize the libt3widget library.
Definition: main.cc:253
void set_attribute(attribute_t attribute, t3_attr_t value)
Change the setting of a default attribute.
Definition: colorscheme.cc:70
const char * term
Override the terminal name derived from TERM.
Definition: main.h:71
void async_safe_exit_main_loop(int exit_code)
Exit the main loop from any thread or signal handler.
Definition: key.cc:729
bool separate_keypad
Boolean indicating whether keypad keys are returned as separate from the regular cursor control keys...
Definition: main.h:76
Structure holding the parameters for initialization for libt3widget.
Definition: main.h:68
void suspend(void)
Suspend execution of this program by sending a SIGSTOP signal.
Definition: main.cc:380
signals::connection connect_on_init(const signals::slot< void, bool > &slot)
Connect a callback to the on_init signal.
Definition: main.cc:126
int main_loop(void)
Run the main event loop of the libt3widget library.
Definition: main.cc:358