2 #ifndef _F_LINUX_CONSOLE_DISPLAY_H_
3 #define _F_LINUX_CONSOLE_DISPLAY_H_
5 #include <F_Text_Display.H>
12 class F_Linux_Console_Display : public F_Text_Display {
15 coord_t old_cursor_x, old_cursor_y, cursor_x, cursor_y;
16 coord_t old_mouse_x, old_mouse_y, mouse_x, mouse_y;
17 F_Event_Type_t mouse_ev_t; // current mouse event type
18 F_Pointer_Event_Code_t mouse_ev_c; // current mouse event code
19 F_Text_Symbol symbol_under_mouse_;
20 F_Window *window_belowmouse_;
22 void put_line(coord_t x, coord_t y, dim_t len, F_Text_Symbol *src);
23 void get_line(coord_t x, coord_t y, dim_t len, F_Text_Symbol *dest);
25 inline void put_symbol_region(F_Region *region, F_Text_Symbol_Buffer &src) {
26 for (register coord_t cur_line = region->y(); cur_line < (region->y() + region->h()); cur_line++)
27 put_line(region->x(), cur_line, region->w(), src[((cur_line - region->y()) * region->w())]);
29 inline void get_symbol_region(F_Region *region, F_Text_Symbol_Buffer &dest) {
30 for (register coord_t cur_line = region->y(); cur_line < (region->y() + region->h()); cur_line++)
31 get_line(region->x(), cur_line, region->w(), dest[((cur_line - region->y()) * region->w())]);
36 F_Linux_Console_Display(FILE *vcsa, dim_t w, dim_t h) : F_Text_Display(w, h) {
38 old_mouse_x = old_mouse_y = mouse_x = mouse_y = F_MAX_COORD_T;
39 mouse_ev_t = F_EVENT_NONE;
40 mouse_ev_c = F_POINTER_NONE;
41 window_belowmouse_ = 0;
43 ~F_Linux_Console_Display() { fclose(vcsa_); }
45 // ÏÂÒÁÂÁÙ×ÁÅÔ ÓÏÂÙÔÉÑ É ÐÅÒÅÄÁÅÔ ÉÈ ÄÁÌØÛÅ - ÏËÎÁÍ/×ÉÄÖÅÔÁÍ
46 bool handle(F_Event_t &ev);
47 F_Window *window_belowmouse() { return window_belowmouse_; }
48 void window_belowmouse(F_Window *w) { window_belowmouse_ = w; }
49 // tty magic : cursor on/off
50 void cursor(bool on) {
51 if (on && (cursor_x >= 0) && (cursor_x <= w()) && (cursor_y <= h()) &&
53 fprintf(stdout, "%c%s",27,"[?25h");
55 fprintf(stdout, "%c%s",27,"[?25l");
59 void cursor(coord_t x, coord_t y);
61 void cursor(coord_t *x, coord_t *y);
62 void restore_mouse_pointer() {
63 if ((old_mouse_x == F_MAX_COORD_T) || (old_mouse_y == F_MAX_COORD_T))
65 if ((old_mouse_x < w()) && (old_mouse_y < h())) {
66 put_line(old_mouse_x, old_mouse_y, 1, &symbol_under_mouse_);
69 void draw_mouse_pointer() {
70 if ((mouse_x == F_MAX_COORD_T) || (mouse_y == F_MAX_COORD_T))
72 restore_mouse_pointer();
75 if (mouse_x > (coord_t)(w() - 1))
77 if (mouse_y > (coord_t)(h() - 1))
79 get_line(mouse_x, mouse_y, 1, &symbol_under_mouse_);
80 F_Text_Symbol t = symbol_under_mouse_;
81 bool blink = (symbol_under_mouse_.bg() & 0x8);
82 bool bright = (symbol_under_mouse_.fg() & 0x8);
84 t.fg((~symbol_under_mouse_.fg() & 0x7) | (bright ? 0x8 : 0));
85 t.bg((~symbol_under_mouse_.bg() & 0x7) | (blink ? 0x8 : 0));
86 put_line(mouse_x, mouse_y, 1, &t);
87 old_mouse_x = mouse_x;
88 old_mouse_y = mouse_y;
91 // ÓÏÈÒÁÎÑÅÍ ÜËÒÁÎ × backing store
92 get_symbol_region(this, back_buf);
93 // É ÔÏÖÅ ÓÁÍÏÅ × front store
94 get_symbol_region(this, draw_buf);
95 cursor(&old_cursor_x, &old_cursor_y);
98 put_symbol_region(this, back_buf);
99 cursor(old_cursor_x, old_cursor_y);
103 friend class F_Linux_Console_UI;
105 }; // class F_Linux_Console_Display