28#include <FL/Fl_Scrollbar.H>
29#include <FL/Fl_Rect.H>
362 COLORMASK = (FG_XTERM | BG_XTERM)
387 int left_, right_, top_, bottom_;
389 Margin(
void) { left_ = right_ = top_ = bottom_ = 3; }
390 int left(
void)
const {
return left_; }
391 int right(
void)
const {
return right_; }
392 int top(
void)
const {
return top_; }
393 int bottom(
void)
const {
return bottom_; }
394 void left(
int val) { left_ = val; }
395 void right(
int val) { right_ = val; }
396 void top(
int val) { top_ = val; }
397 void bottom(
int val) { bottom_ = val; }
420 uchar attrib(
void)
const {
return attrib_; }
421 uchar charflags(
void)
const {
return charflags_; }
424 Fl_Color defaultfgcolor(
void)
const {
return defaultfgcolor_; }
425 Fl_Color defaultbgcolor(
void)
const {
return defaultbgcolor_; }
426 Fl_Font fontface(
void)
const {
return fontface_; }
427 Fl_Fontsize fontsize(
void)
const {
return fontsize_; }
428 int fontheight(
void)
const {
return fontheight_; }
429 int fontdescent(
void)
const {
return fontdescent_; }
430 int charwidth(
void)
const {
return charwidth_; }
432 void attrib(
uchar val) { attrib_ = val; }
433 void charflags(
uchar val) { charflags_ = val; }
434 void set_charflag(
uchar val) { charflags_ |= val; }
435 void clr_charflag(
uchar val) { charflags_ &= ~val; }
436 void fgcolor_uchar(
uchar val);
437 void bgcolor_uchar(
uchar val);
438 void fgcolor(
int r,
int g,
int b) { fgcolor_ = (r<<24) | (g<<16) | (b<<8); clr_charflag(FG_XTERM); }
439 void bgcolor(
int r,
int g,
int b) { bgcolor_ = (r<<24) | (g<<16) | (b<<8); clr_charflag(BG_XTERM); }
440 void fgcolor(
Fl_Color val) { fgcolor_ = val; clr_charflag(FG_XTERM); }
441 void bgcolor(
Fl_Color val) { bgcolor_ = val; clr_charflag(BG_XTERM); }
442 void defaultfgcolor(
Fl_Color val) { defaultfgcolor_ = val; }
443 void defaultbgcolor(
Fl_Color val) { defaultbgcolor_ = val; }
444 void fontface(
Fl_Font val) { fontface_ = val; update(); }
445 void fontsize(
Fl_Fontsize val) { fontsize_ = val; update(); }
447 void update_fake(
void);
449 void sgr_reset(
void) {
451 fgcolor(defaultfgcolor_);
452 bgcolor(defaultbgcolor_);
454 int onoff(
bool flag,
Attrib a) {
return (flag ? (attrib_ | a) : (attrib_ & ~a)); }
460 void sgr_blink(
bool val) { (void)val; }
481 fgcolor_ = 0xfffff000;
482 bgcolor_ = 0x00d00000;
484 int col(
void)
const {
return col_; }
485 int row(
void)
const {
return row_; }
486 int h(
void)
const {
return h_; }
487 Fl_Color fgcolor(
void)
const {
return fgcolor_; }
488 Fl_Color bgcolor(
void)
const {
return bgcolor_; }
489 void col(
int val) { col_ = val >= 0 ? val : 0; }
490 void row(
int val) { row_ = val >= 0 ? val : 0; }
491 void h(
int val) { h_ = val; }
492 void fgcolor(
Fl_Color val) { fgcolor_ = val; }
493 void bgcolor(
Fl_Color val) { bgcolor_ = val; }
494 int left(
void) { col_ = (col_>0) ? (col_-1) : 0;
return col_; }
495 int right(
void) {
return ++col_; }
496 int up(
void) { row_ = (row_>0) ? (row_-1) : 0;
return row_; }
497 int down(
void) {
return ++row_; }
498 bool is_rowcol(
int drow,
int dcol)
const;
499 void scroll(
int nrows);
500 void home(
void) { row_ = 0; col_ = 0; }
509 static const int max_utf8_ = 4;
510 char text_[max_utf8_];
517 void text_utf8_(
const char *text,
int len);
524 inline int max_utf8()
const {
return max_utf8_; }
525 void text_utf8(
const char *text,
int len,
const CharStyle& style);
526 void text_ascii(
char c,
const CharStyle& style);
527 void fl_font_set(
const CharStyle& style)
const;
532 const char* text_utf8(
void)
const {
return text_; }
534 uchar attrib(
void)
const {
return attrib_; }
535 uchar charflags(
void)
const {
return charflags_; }
539 int length(
void)
const {
return int(len_); }
540 double pwidth(
void)
const;
541 int pwidth_int(
void)
const;
544 bool is_char(
char c)
const {
return *text_ == c; }
545 void show_char(
void)
const { ::printf(
"%.*s", len_, text_); }
546 void show_char_info(
void)
const { ::fprintf(stderr,
"UTF-8('%.*s', len=%d)\n", len_, text_, len_); }
568 void new_copy(
int drows,
int dcols,
int hrows,
const CharStyle& style);
577 void clear_hist(
void);
606 inline int ring_rows(
void)
const {
return ring_rows_; }
607 inline int ring_cols(
void)
const {
return ring_cols_; }
608 inline int ring_srow(
void)
const {
return(0); }
609 inline int ring_erow(
void)
const {
return(ring_rows_ - 1); }
610 inline int hist_rows(
void)
const {
return hist_rows_; }
611 inline int hist_cols(
void)
const {
return ring_cols_; }
612 inline int hist_srow(
void)
const {
return((offset_ + 0) % ring_rows_); }
613 inline int hist_erow(
void)
const {
return((offset_ + hist_rows_ - 1) % ring_rows_); }
614 inline int disp_rows(
void)
const {
return disp_rows_; }
615 inline int disp_cols(
void)
const {
return ring_cols_; }
616 inline int disp_srow(
void)
const {
return((offset_ + hist_rows_) % ring_rows_); }
617 inline int disp_erow(
void)
const {
return((offset_ + hist_rows_ + disp_rows_ - 1) % ring_rows_); }
618 inline int offset(
void)
const {
return offset_; }
619 void offset_adjust(
int rows);
620 void hist_rows(
int val) { hist_rows_ = val; }
621 void disp_rows(
int val) { disp_rows_ = val; }
624 inline int hist_use(
void)
const {
return hist_use_; }
625 inline void hist_use(
int val) { hist_use_ = val; }
626 inline int hist_use_srow(
void)
const {
return((offset_ + hist_rows_ - hist_use_) % ring_rows_); }
627 inline Utf8Char *ring_chars(
void) {
return ring_chars_; }
628 inline Utf8Char *ring_chars(
void)
const {
return ring_chars_; }
630 bool is_hist_ring_row(
int grow)
const;
631 bool is_disp_ring_row(
int grow)
const;
633 void move_disp_row(
int src_row,
int dst_row);
634 void clear_disp_rows(
int sdrow,
int edrow,
const CharStyle& style);
635 void scroll(
int rows,
const CharStyle& style);
637 const Utf8Char* u8c_ring_row(
int row)
const;
638 const Utf8Char* u8c_hist_row(
int hrow)
const;
639 const Utf8Char* u8c_hist_use_row(
int hurow)
const;
640 const Utf8Char* u8c_disp_row(
int drow)
const;
646 Utf8Char* u8c_hist_use_row(
int hurow);
649 void create(
int drows,
int dcols,
int hrows);
652 void change_disp_rows(
int drows,
const CharStyle& style);
653 void change_disp_cols(
int dcols,
const CharStyle& style);
661 int srow_, scol_, erow_, ecol_;
662 int push_row_, push_col_;
669 int srow(
void)
const {
return srow_; }
670 int scol(
void)
const {
return scol_; }
671 int erow(
void)
const {
return erow_; }
672 int ecol(
void)
const {
return ecol_; }
673 void push_clear() { push_row_ = push_col_ = -1; }
674 void push_rowcol(
int row,
int col) { push_row_ = row; push_col_ = col; }
675 void start_push() { start(push_row_, push_col_); }
676 bool dragged_off(
int row,
int col) {
return (push_row_ != row) || (push_col_ != col); }
677 void selectionfgcolor(
Fl_Color val) { selectionfgcolor_ = val; }
678 void selectionbgcolor(
Fl_Color val) { selectionbgcolor_ = val; }
679 Fl_Color selectionfgcolor(
void)
const {
return selectionfgcolor_; }
680 Fl_Color selectionbgcolor(
void)
const {
return selectionbgcolor_; }
681 bool is_selection(
void)
const {
return is_selection_; }
682 bool get_selection(
int &srow,
int &scol,
int &erow,
int &ecol)
const;
683 bool start(
int row,
int col);
684 bool extend(
int row,
int col);
686 void select(
int srow,
int scol,
int erow,
int ecol);
688 int state(
void)
const {
return state_; }
689 void scroll(
int nrows);
705 static const int maxbuff = 80;
706 static const int maxvals = 20;
708 static const int success = 0;
709 static const int fail = -1;
710 static const int completed = 1;
720 int save_row_, save_col_;
722 int append_buff(
char c);
723 int append_val(
void);
728 char esc_mode(
void)
const;
729 void esc_mode(
char val);
730 int total_vals(
void)
const;
731 int val(
int i)
const;
732 int defvalmax(
int dval,
int max)
const;
733 bool parse_in_progress(
void)
const;
734 bool is_csi(
void)
const;
736 void save_cursor(
int row,
int col);
737 void restore_cursor(
int &row,
int &col);
749 void clear(
void) { buflen_ = clen_ = 0; }
752 bool is_continuation(
char c) {
763 return ((c & 0xc0) == 0x80);
766 const char* buf(
void)
const {
return buf_; }
768 int buflen(
void)
const {
return buflen_; }
778 bool append(
const char* p,
int len) {
779 if (len <= 0)
return true;
780 if (buflen_ + len >= (
int)
sizeof(buf_))
781 {
clear();
return false; }
783 while (len>0) { buf_[buflen_++] = *p++; len--; }
786 bool is_complete(
void)
const {
return (buflen_ && (buflen_ == clen_)); }
801 bool fontsize_defer_;
824 bool redraw_modified_;
830 const Utf8Char* u8c_ring_row(
int grow)
const;
831 const Utf8Char* u8c_hist_row(
int hrow)
const;
832 const Utf8Char* u8c_hist_use_row(
int hrow)
const;
833 const Utf8Char* u8c_disp_row(
int drow)
const;
839 Utf8Char* u8c_hist_use_row(
int hurow);
843 void create_ring(
int drows,
int dcols,
int hrows);
844 void init_(
int X,
int Y,
int W,
int H,
const char*L,
int rows,
int cols,
int hist,
bool fontsize_defer);
846 int scrollbar_width(
void)
const;
849 void init_tabstops(
int newsize);
850 void default_tabstops(
void);
851 void clear_all_tabstops(
void);
852 void set_tabstop(
void);
853 void clear_tabstop(
void);
855 void update_screen_xywh(
void);
856 void update_screen(
bool font_changed);
857 void update_scrollbar(
void);
859 void resize_display_rows(
int drows);
860 void resize_display_columns(
int dcols);
861 void refit_disp_to_screen(
void);
863 static void scrollbar_cb(
Fl_Widget*,
void*);
864 static void autoscroll_timer_cb(
void*);
865 void autoscroll_timer_cb2(
void);
866 static void redraw_timer_cb(
void*);
867 void redraw_timer_cb2(
void);
871 const CharStyle& current_style(
void)
const;
872 void current_style(
const CharStyle& sty);
874 int x_to_glob_col(
int X,
int grow,
int &gcol)
const;
875 int xy_to_glob_rowcol(
int X,
int Y,
int &grow,
int &gcol)
const;
877 int w_to_col(
int W)
const;
878 int h_to_row(
int H)
const;
880 void clear_sod(
void);
881 void clear_eod(
void);
882 void clear_eol(
void);
883 void clear_sol(
void);
884 void clear_line(
int row);
885 void clear_line(
void);
886 const Utf8Char* walk_selection(
const Utf8Char *u8c,
int &row,
int &col)
const;
887 bool get_selection(
int &srow,
int &scol,
int &erow,
int &ecol)
const;
888 bool is_selection(
void)
const;
889 bool is_inside_selection(
int row,
int col)
const;
891 bool is_hist_ring_row(
int grow)
const;
892 bool is_disp_ring_row(
int grow)
const;
894 int selection_text_len(
void)
const;
895 const char* selection_text(
void)
const;
896 void clear_mouse_selection(
void);
897 bool selection_extend(
int X,
int Y);
898 void scroll(
int rows);
899 void insert_rows(
int count);
900 void delete_rows(
int count);
901 void insert_char_eol(
char c,
int drow,
int dcol,
int rep);
902 void insert_char(
char c,
int rep);
903 void delete_chars(
int drow,
int dcol,
int rep);
904 void delete_chars(
int rep);
909 void clear_screen(
bool scroll_to_hist=
true);
910 void clear_screen_home(
bool scroll_to_hist=
true);
911 void clear_history(
void);
912 void reset_terminal(
void);
913 void cursor_home(
void);
920 void cursor_row(
int row);
921 void cursor_col(
int col);
923 int cursor_row(
void)
const;
924 int cursor_col(
void)
const;
926 void cursor_up(
int count=1,
bool do_scroll=
false);
927 void cursor_down(
int count=1,
bool do_scroll=
false);
928 void cursor_left(
int count=1);
929 void cursor_right(
int count=1,
bool do_scroll=
false);
930 void cursor_eol(
void);
931 void cursor_sol(
void);
932 void cursor_cr(
void);
933 void cursor_crlf(
int count=1);
934 void cursor_tab_right(
int count=1);
935 void cursor_tab_left(
int count=1);
936 void save_cursor(
void);
937 void restore_cursor(
void);
943 void handle_lf(
void);
944 void handle_cr(
void);
946 void handle_ctrl(
char c);
947 bool is_printable(
char c);
948 bool is_ctrl(
char c);
949 void handle_SGR(
void);
950 void handle_DECRARA(
void);
951 void handle_escseq(
char c);
953 void display_modified(
void);
954 void display_modified_clear(
void);
955 void clear_char_at_disp(
int drow,
int dcol);
956 const Utf8Char* utf8_char_at_disp(
int drow,
int dcol)
const;
957 const Utf8Char* utf8_char_at_glob(
int grow,
int gcol)
const;
958 void repeat_char(
char c,
int rep);
959 void utf8_cache_clear(
void);
960 void utf8_cache_flush(
void);
963 void putchar(
const char *text,
int len,
int drow,
int dcol);
964 void putchar(
char c,
int drow,
int dcol);
965 void print_char(
const char *text,
int len=-1);
966 void print_char(
char c);
968 void append_utf8(
const char *buf,
int len=-1);
969 void append_ascii(
const char *s);
970 void append(
const char *s,
int len=-1);
972 int handle_unknown_char(
void);
974 void draw_row_bg(
int grow,
int X,
int Y)
const;
975 void draw_row(
int grow,
int Y)
const;
976 void draw_buff(
int Y)
const;
978 void handle_selection_autoscroll(
void);
979 int handle_selection(
int e);
992 inline int ring_rows(
void)
const {
return ring_.ring_rows(); }
994 inline int ring_cols(
void)
const {
return ring_.ring_cols(); }
996 inline int ring_srow(
void)
const {
return ring_.ring_srow(); }
998 inline int ring_erow(
void)
const {
return ring_.ring_erow(); }
1000 inline int hist_rows(
void)
const {
return ring_.hist_rows(); }
1002 inline int hist_cols(
void)
const {
return ring_.hist_cols(); }
1004 inline int hist_srow(
void)
const {
return ring_.hist_srow(); }
1006 inline int hist_erow(
void)
const {
return ring_.hist_erow(); }
1008 inline int hist_use(
void)
const {
return ring_.hist_use(); }
1012 inline int disp_rows(
void)
const {
return ring_.disp_rows(); }
1014 inline int disp_cols(
void)
const {
return ring_.disp_cols(); }
1016 inline int disp_srow(
void)
const {
return ring_.disp_srow(); }
1018 inline int disp_erow(
void)
const {
return ring_.disp_erow(); }
1020 inline int offset(
void)
const {
return ring_.offset(); }
1028 int scrollbar_size(
void)
const;
1029 void scrollbar_size(
int val);
1030 int scrollbar_actual_size(
void)
const;
1032 int history_rows(
void)
const;
1033 void history_rows(
int val);
1034 int history_use(
void)
const;
1036 int display_rows(
void)
const;
1037 void display_rows(
int val);
1038 int display_columns(
void)
const;
1039 void display_columns(
int val);
1060 void margin_left(
int val);
1061 void margin_right(
int val);
1062 void margin_top(
int val);
1063 void margin_bottom(
int val);
1071 void textfgcolor_default(
Fl_Color val);
1072 void textbgcolor_default(
Fl_Color val);
1089 void textfgcolor_xterm(
uchar val);
1090 void textbgcolor_xterm(
uchar val);
1100 void textattrib(
uchar val);
1101 uchar textattrib()
const;
1103 RedrawStyle redraw_style(
void)
const;
1104 void redraw_style(RedrawStyle val);
1106 bool is_redraw_style(RedrawStyle val) {
return redraw_style_ == val; }
1108 float redraw_rate(
void)
const;
1109 void redraw_rate(
float val);
1111 bool show_unknown(
void)
const;
1112 void show_unknown(
bool val);
1114 bool ansi(
void)
const;
1115 void ansi(
bool val);
1117 int history_lines(
void)
const;
1118 void history_lines(
int val);
1120 void printf(
const char *fmt, ...);
1121 void vprintf(
const char *fmt, va_list ap);
1123 Fl_Terminal(
int X,
int Y,
int W,
int H,
const char*L=0);
1124 Fl_Terminal(
int X,
int Y,
int W,
int H,
const char*L,
int rows,
int cols,
int hist);
int Fl_Font
A font number is an index into the internal font table.
Definition Enumerations.H:1044
unsigned int Fl_Color
An FLTK color value; see also Colors
Definition Enumerations.H:1101
int Fl_Fontsize
Size of a font in pixels.
Definition Enumerations.H:1073
Fl_Boxtype
FLTK standard box types.
Definition Enumerations.H:626
Fl_Group and Fl_End classes.
The Fl_Group class is the FLTK container widget.
Definition Fl_Group.H:56
void end()
Exactly the same as current(this->parent()).
Definition Fl_Group.cxx:73
int handle(int) FL_OVERRIDE
Handles the specified event.
Definition Fl_Group.cxx:145
void resize(int, int, int, int) FL_OVERRIDE
Resizes the Fl_Group widget and all of its children.
Definition Fl_Group.cxx:823
void draw() FL_OVERRIDE
Draws the widget.
Definition Fl_Group.cxx:926
void clear()
Deletes all child widgets from memory recursively.
Definition Fl_Group.cxx:379
Rectangle with standard FLTK coordinates (X, Y, W, H).
Definition Fl_Rect.H:30
Definition Fl_Terminal.H:406
Definition Fl_Terminal.H:470
Definition Fl_Terminal.H:701
Definition Fl_Terminal.H:386
Definition Fl_Terminal.H:744
Definition Fl_Terminal.H:557
Definition Fl_Terminal.H:660
Definition Fl_Terminal.H:508
Terminal widget supporting Unicode/utf-8, ANSI/xterm escape codes with full RGB color control.
Definition Fl_Terminal.H:311
void selectionbgcolor(Fl_Color val)
Set mouse selection background color.
Definition Fl_Terminal.H:1094
int disp_srow(void) const
Return the starting row# in the display area.
Definition Fl_Terminal.H:1016
Fl_Color color(void) const
Return base widget Fl_Group's box() color()
Definition Fl_Terminal.H:1078
int hist_rows(void) const
Return the number of rows in the scrollback history.
Definition Fl_Terminal.H:1000
Fl_Color textbgcolor_default(void) const
Return text's default background color.
Definition Fl_Terminal.H:1088
int margin_left(void) const
Return the left margin; see Margins.
Definition Fl_Terminal.H:1053
Fl_Color selectionfgcolor(void) const
Get mouse selection foreground color.
Definition Fl_Terminal.H:1096
Attrib
Bits for the per-character attributes, which control text features such as italic,...
Definition Fl_Terminal.H:337
@ NORMAL
all attributes off
Definition Fl_Terminal.H:338
@ ITALIC
italic font text
Definition Fl_Terminal.H:341
@ DIM
dim text; color slightly darker than normal
Definition Fl_Terminal.H:340
@ STRIKEOUT
strikeout text
Definition Fl_Terminal.H:346
@ UNDERLINE
underlined text
Definition Fl_Terminal.H:342
@ BOLD
bold text: uses bold font, color brighter than normal
Definition Fl_Terminal.H:339
@ INVERSE
inverse text; fg/bg color are swapped
Definition Fl_Terminal.H:344
Fl_Color selectionbgcolor(void) const
Get mouse selection background color.
Definition Fl_Terminal.H:1098
int offset(void) const
Returns the current offset into the ring buffer.
Definition Fl_Terminal.H:1020
int margin_bottom(void) const
Return the bottom margin; see Margins.
Definition Fl_Terminal.H:1059
Fl_Scrollbar * scrollbar
Vertical scrollbar.
Definition Fl_Terminal.H:799
int margin_top(void) const
Return the top margin; see Margins.
Definition Fl_Terminal.H:1057
int hist_srow(void) const
Return the starting row# of the scrollback history.
Definition Fl_Terminal.H:1004
Fl_Font textfont(void) const
Return text font used to draw all text in the terminal.
Definition Fl_Terminal.H:1074
int disp_erow(void) const
Return the ending row# in the display area.
Definition Fl_Terminal.H:1018
Fl_Color textfgcolor(void) const
Return text's current foreground color.
Definition Fl_Terminal.H:1082
Fl_Fontsize textsize(void) const
Return text font size used to draw all text in the terminal.
Definition Fl_Terminal.H:1076
int ring_cols(void) const
Return the number of columns in the ring buffer.
Definition Fl_Terminal.H:994
CharFlags
Per-character 8 bit flags (uchar) used to manage special states for characters.
Definition Fl_Terminal.H:353
int hist_cols(void) const
Return the number of columns in the scrollback history.
Definition Fl_Terminal.H:1002
Fl_Color textbgcolor(void) const
Return text's current background color.
Definition Fl_Terminal.H:1084
Fl_Color textfgcolor_default(void) const
Return text's default foreground color.
Definition Fl_Terminal.H:1086
RedrawStyle
Determines when Fl_Terminal calls redraw() if new text is added.
Definition Fl_Terminal.H:323
@ RATE_LIMITED
timer controlled redraws. (DEFAULT)
Definition Fl_Terminal.H:325
int margin_right(void) const
Return the right margin; see Margins.
Definition Fl_Terminal.H:1055
int ring_rows(void) const
Return the number of rows in the ring buffer.
Definition Fl_Terminal.H:992
int hist_use(void) const
Return number of rows in use by the scrollback history.
Definition Fl_Terminal.H:1008
int disp_rows(void) const
Return the number of rows in the display area.
Definition Fl_Terminal.H:1012
int hist_use_srow(void) const
Return the starting row of the "in use" scrollback history.
Definition Fl_Terminal.H:1010
int disp_cols(void) const
Return the number of columns in the display area.
Definition Fl_Terminal.H:1014
int ring_srow(void) const
Return the starting row# in the ring buffer. (Always 0)
Definition Fl_Terminal.H:996
OutFlags
Output translation flags for special control character translations.
Definition Fl_Terminal.H:369
int ring_erow(void) const
Return the ending row# in the ring buffer (Always ring_rows()-1)
Definition Fl_Terminal.H:998
Fl_Boxtype box(void) const
Returns the current box type.
Definition Fl_Terminal.H:1050
void box(Fl_Boxtype val)
Sets the box type, updates terminal margins et al.
Definition Fl_Terminal.H:1048
void selectionfgcolor(Fl_Color val)
Set mouse selection foreground color.
Definition Fl_Terminal.H:1092
Fl_Color textcolor(void) const
Return textcolor(). This is a convenience method that returns textfgcolor_default()
Definition Fl_Terminal.H:1080
int hist_erow(void) const
Return the ending row# of the scrollback history.
Definition Fl_Terminal.H:1006
#define FL_OVERRIDE
This macro makes it safe to use the C++11 keyword override with older compilers.
Definition fl_attr.h:46
unsigned char uchar
unsigned char
Definition fl_types.h:30
int fl_utf8len(char c)
Returns the byte length of the UTF-8 sequence with first byte c, or -1 if c is not valid.
Definition fl_utf8.cxx:69