sdlterm/src/sdlterm.h
changeset 60 fccca2a60492
parent 58 50308ed5e4f9
child 61 15088f62c4ac
equal deleted inserted replaced
59:729fcdfe6b57 60:fccca2a60492
     8 
     8 
     9 
     9 
    10 namespace Style
    10 namespace Style
    11 {
    11 {
    12     enum {
    12     enum {
    13         BOLD      = 1 << 0,  // bold font
    13         BOLD      = 1 << 24,  // bold font
    14         UNDERLINE = 1 << 1,  // underline text
    14         UNDERLINE = 1 << 25,  // underline text
    15         STANDOUT  = 1 << 2,  // inverse bg/fg
    15         STANDOUT  = 1 << 26,  // inverse bg/fg
    16         BLINK     = 1 << 3,  // blinking
    16         BLINK     = 1 << 27,  // blinking
    17     };
    17     };
    18 };
    18 };
    19 
    19 
    20 
    20 
    21 class ColorMap
    21 class ColorMap
    74 
    74 
    75     void open_font(const char *fname_regular, const char *fname_bold, int ptsize);
    75     void open_font(const char *fname_regular, const char *fname_bold, int ptsize);
    76     void close_font();
    76     void close_font();
    77 
    77 
    78     // do not free surface returned!
    78     // do not free surface returned!
    79     SDL_Surface *render_cell(Uint32 ch, Uint32 attr);
    79     SDL_Surface *render_cell(Uint32 ch, Uint32 attr, bool blink_state);
    80 
    80 
    81     int get_cell_width() const { return _cell_width; };
    81     int get_cell_width() const { return _cell_width; };
    82     int get_cell_height() const { return _cell_height; };
    82     int get_cell_height() const { return _cell_height; };
    83 
    83 
    84 private:
    84 private:
   122 {
   122 {
   123 public:
   123 public:
   124     TerminalScreen():
   124     TerminalScreen():
   125         _screen_surface(NULL), _cells_front(0), _cells_back(0), _render(),
   125         _screen_surface(NULL), _cells_front(0), _cells_back(0), _render(),
   126         _pixel_width(0), _pixel_height(0), _width(0), _height(0),
   126         _pixel_width(0), _pixel_height(0), _width(0), _height(0),
   127         _cell_width(0), _cell_height(0) {};
   127         _cell_width(0), _cell_height(0), _blink_state(1) {};
   128     ~TerminalScreen() {};
   128     ~TerminalScreen() {};
   129 
   129 
   130     void select_font(const char *fname_regular, const char *fname_bold, int ptsize);
   130     void select_font(const char *fname_regular, const char *fname_bold, int ptsize);
   131     void resize(int pxwidth, int pxheight);
   131     void resize(int pxwidth, int pxheight);
   132 
   132 
   133     void erase();
   133     void erase();
   134     void putch(int x, int y, Uint32 ch, Uint32 attr);
   134     void putch(int x, int y, Uint32 ch, Uint32 attr);
   135     void toggle_cursor(int x, int y);
   135     void toggle_cursor(int x, int y);
       
   136     void toggle_blink() { _blink_state = !_blink_state; _draw_blink(); };
   136     void commit();
   137     void commit();
   137 
   138 
   138     // force full redraw on next commit()
   139     // force full redraw on next commit()
   139     void redraw();
   140     void redraw();
   140 
   141 
   154     int _width;  // width in characters
   155     int _width;  // width in characters
   155     int _height; // height in characters
   156     int _height; // height in characters
   156     int _cell_width;  // character cell width in pixels
   157     int _cell_width;  // character cell width in pixels
   157     int _cell_height;
   158     int _cell_height;
   158 
   159 
       
   160     int _blink_state; // 0 - blink chars hidden, 1 - visible
       
   161 
   159     void _reset_cells();
   162     void _reset_cells();
       
   163     void _draw_blink();
   160 };
   164 };
   161 
   165 
   162 
   166 
   163 struct Event
   167 struct Event
   164 {
   168 {
   221     int _mousemove_last_x;
   225     int _mousemove_last_x;
   222     int _mousemove_last_y;
   226     int _mousemove_last_y;
   223 
   227 
   224     const char *_translate_keyname(SDLKey sym);
   228     const char *_translate_keyname(SDLKey sym);
   225     static Uint32 _wait_event_callback(Uint32 interval, void *param);
   229     static Uint32 _wait_event_callback(Uint32 interval, void *param);
       
   230     static Uint32 _blink_toggle_callback(Uint32 interval, void *param);
   226 };
   231 };
   227 
   232 
   228 
   233 
   229 class SDLTermError: public std::exception
   234 class SDLTermError: public std::exception
   230 {
   235 {