FLTK 1.4.4

Loading...
Searching...
No Matches
Fl_Terminal.H
Go to the documentation of this file.
1//
2// Fl_Terminal - A terminal widget for Fast Light Tool Kit (FLTK).
3//
4// Copyright 2022 by Greg Ercolano.
5// Copyright 2024-2025 by Bill Spitzak and others.
6//
7// This library is free software. Distribution and use rights are outlined in
8// the file "COPYING" which should have been included with this file. If this
9// file is missing or damaged, see the license at:
10//
11// https://www.fltk.org/COPYING.php
12//
13// Please see the following page on how to report bugs and issues:
14//
15// https://www.fltk.org/bugs.php
16//
17
21
22#ifndef Fl_Terminal_H
23#define Fl_Terminal_H
24
25#include <FL/Fl.H>
26#include <FL/Fl_Window.H>
27#include <FL/Fl_Group.H>
28#include <FL/Fl_Scrollbar.H>
29#include <FL/Fl_Rect.H>
30
31#include <stdarg.h> // va_list (MinGW)
32
319
320 class FL_EXPORT Fl_Terminal : public Fl_Group {
324 public:
332 enum RedrawStyle {
333 NO_REDRAW=0,
334 RATE_LIMITED,
335 PER_WRITE
336 };
337
346 enum Attrib {
347 NORMAL = 0x00,
348 BOLD = 0x01,
349 DIM = 0x02,
350 ITALIC = 0x04,
351 UNDERLINE = 0x08,
352 _RESERVED_1 = 0x10,
353 INVERSE = 0x20,
354 _RESERVED_2 = 0x40,
355 STRIKEOUT = 0x80
356 };
357
362 enum CharFlags {
363 FG_XTERM = 0x01,
364 BG_XTERM = 0x02,
365 EOL = 0x04,
366 RESV_A = 0x08,
367 RESV_B = 0x10,
368 RESV_C = 0x20,
369 RESV_D = 0x40,
370 RESV_E = 0x80,
371 COLORMASK = (FG_XTERM | BG_XTERM)
372 };
373
378 enum OutFlags {
379 OFF = 0x00,
380 CR_TO_LF = 0x01,
381 LF_TO_CR = 0x02,
382 LF_TO_CRLF = 0x04
383 };
384
389 enum ScrollbarStyle {
390 SCROLLBAR_OFF = 0x00,
391 SCROLLBAR_AUTO = 0x01,
392 SCROLLBAR_ON = 0x02
393 };
394
400 protected:
401 // Margin Class ////////////////////////////////////////////
402 //
403 // Class to manage the terminal's margins
404 //
405 class FL_EXPORT Margin {
406 int left_, right_, top_, bottom_;
407 public:
408 Margin(void) { left_ = right_ = top_ = bottom_ = 3; }
409 int left(void) const { return left_; }
410 int right(void) const { return right_; }
411 int top(void) const { return top_; }
412 int bottom(void) const { return bottom_; }
413 void left(int val) { left_ = val; }
414 void right(int val) { right_ = val; }
415 void top(int val) { top_ = val; }
416 void bottom(int val) { bottom_ = val; }
417 };
418
419 // CharStyle Class ////////////////////////////////////////////
420 //
421 // Class to manage the terminal's character style
422 // This includes the font, color, and some cached internal
423 // info for optimized drawing speed.
424 //
425 class FL_EXPORT CharStyle {
426 uchar attrib_; // bold, underline..
427 uchar charflags_; // CharFlags (xterm color management)
428 Fl_Color fgcolor_; // foreground color for text
429 Fl_Color bgcolor_; // background color for text
430 Fl_Color defaultfgcolor_; // default fg color used by ESC[0m
431 Fl_Color defaultbgcolor_; // default bg color used by ESC[0m
432 Fl_Font fontface_; // font face
433 Fl_Fontsize fontsize_; // font size
434 int fontheight_; // font height (in pixels)
435 int fontdescent_; // font descent (pixels below font baseline)
436 int charwidth_; // width of a fixed width ASCII character
437 public:
438 CharStyle(bool fontsize_defer);
439 uchar attrib(void) const { return attrib_; }
440 uchar charflags(void) const { return charflags_; }
441 // Colors - All access to colors are by Fl_Color only.
442 // There are three ways to SET colors: Fl_Color, rgb, xterm(uchar)
443 //
444 Fl_Color fltk_fg_color(uchar ci);
445 Fl_Color fltk_bg_color(uchar ci);
446 Fl_Color fgcolor(void) const;
447 Fl_Color bgcolor(void) const;
448 Fl_Color defaultfgcolor(void) const { return defaultfgcolor_; }
449 Fl_Color defaultbgcolor(void) const { return defaultbgcolor_; }
450 Fl_Font fontface(void) const { return fontface_; }
451 Fl_Fontsize fontsize(void) const { return fontsize_; }
452 int fontheight(void) const { return fontheight_; }
453 int fontdescent(void) const { return fontdescent_; }
454 int charwidth(void) const { return charwidth_; }
455 uchar colorbits_only(uchar inflags) const;
456 void attrib(uchar val) { attrib_ = val; }
457 void charflags(uchar val) { charflags_ = val; }
458 void set_charflag(uchar val) { charflags_ |= val; }
459 void clr_charflag(uchar val) { charflags_ &= ~val; }
460 // Non-xterm colors
461 void fgcolor(int r,int g,int b) { fgcolor_ = (r<<24) | (g<<16) | (b<<8); clr_charflag(FG_XTERM); }
462 void bgcolor(int r,int g,int b) { bgcolor_ = (r<<24) | (g<<16) | (b<<8); clr_charflag(BG_XTERM); }
463 void fgcolor(Fl_Color val) { fgcolor_ = val; clr_charflag(FG_XTERM); }
464 void bgcolor(Fl_Color val) { bgcolor_ = val; clr_charflag(BG_XTERM); }
465 // Xterm colors
466 void fgcolor_xterm(Fl_Color val) { fgcolor_ = val; set_charflag(FG_XTERM); }
467 void bgcolor_xterm(Fl_Color val) { bgcolor_ = val; set_charflag(BG_XTERM); }
468 void fgcolor_xterm(uchar val);
469 void bgcolor_xterm(uchar val);
470 //
471 void defaultfgcolor(Fl_Color val) { defaultfgcolor_ = val; }
472 void defaultbgcolor(Fl_Color val) { defaultbgcolor_ = val; }
473 void fontface(Fl_Font val) { fontface_ = val; update(); }
474 void fontsize(Fl_Fontsize val) { fontsize_ = val; update(); }
475 void update(void);
476 void update_fake(void);
477 // SGR MODES: Set Graphics Rendition
478 void sgr_reset(void) { // e.g. ESC[0m
479 attrib(Fl_Terminal::NORMAL);
480 if (charflags() & FG_XTERM) fgcolor_xterm(defaultfgcolor_);
481 else fgcolor(defaultfgcolor_);
482 if (charflags() & BG_XTERM) bgcolor_xterm(defaultbgcolor_);
483 else bgcolor(defaultbgcolor_);
484 }
485 int onoff(bool flag, Attrib a) { return (flag ? (attrib_ | a) : (attrib_ & ~a)); }
486 void sgr_bold(bool val) { attrib_ = onoff(val, Fl_Terminal::BOLD); } // e.g. ESC[1m
487 void sgr_dim(bool val) { attrib_ = onoff(val, Fl_Terminal::DIM); } // e.g. ESC[2m
488 void sgr_italic(bool val) { attrib_ = onoff(val, Fl_Terminal::ITALIC); } // e.g. ESC[3m
489 void sgr_underline(bool val) { attrib_ = onoff(val, Fl_Terminal::UNDERLINE); } // e.g. ESC[3m
490 void sgr_dbl_under(bool val) { attrib_ = onoff(val, Fl_Terminal::UNDERLINE); } // e.g. ESC[21m (TODO!)
491 void sgr_blink(bool val) { (void)val; /* NOT IMPLEMENTED */ } // e.g. ESC[5m
492 void sgr_inverse(bool val) { attrib_ = onoff(val, Fl_Terminal::INVERSE); } // e.g. ESC[7m
493 void sgr_strike(bool val) { attrib_ = onoff(val, Fl_Terminal::STRIKEOUT); } // e.g. ESC[9m
494 };
495
496 protected:
497 // Cursor Class ///////////////////////////////////////////////////////////
498 //
499 // Class to manage the terminal's cursor position, color, etc.
500 //
501 class FL_EXPORT Cursor {
502 int col_; // cursor's current col (x) position on display
503 int row_; // cursor's current row (y) position on display
504 int h_; // cursor's height (affected by font size)
505 Fl_Color fgcolor_; // cursor's fg color (color of text, if any)
506 Fl_Color bgcolor_; // cursor's bg color
507 public:
508 Cursor(void) {
509 col_ = 0;
510 row_ = 0;
511 h_ = 10;
512 fgcolor_ = 0xfffff000; // wht
513 bgcolor_ = 0x00d00000; // grn
514 }
515 int col(void) const { return col_; }
516 int row(void) const { return row_; }
517 int h(void) const { return h_; }
518 Fl_Color fgcolor(void) const { return fgcolor_; }
519 Fl_Color bgcolor(void) const { return bgcolor_; }
520 void col(int val) { col_ = val >= 0 ? val : 0; }
521 void row(int val) { row_ = val >= 0 ? val : 0; }
522 void h(int val) { h_ = val; }
523 void fgcolor(Fl_Color val) { fgcolor_ = val; }
524 void bgcolor(Fl_Color val) { bgcolor_ = val; }
525 int left(void) { col_ = (col_>0) ? (col_-1) : 0; return col_; }
526 int right(void) { return ++col_; }
527 int up(void) { row_ = (row_>0) ? (row_-1) : 0; return row_; }
528 int down(void) { return ++row_; }
529 bool is_rowcol(int drow,int dcol) const;
530 void scroll(int nrows);
531 void home(void) { row_ = 0; col_ = 0; }
532 };
533
534 // Utf8Char Class ///////////////////////////////////////////////////////////
535 //
536 // Class to manage the terminal's individual UTF-8 characters.
537 // Includes fg/bg color, attributes (BOLD, UNDERLINE..)
538 //
539 class FL_EXPORT Utf8Char {
540 static const int max_utf8_ = 4; // RFC 3629 paraphrased: In UTF-8, chars are encoded with 1 to 4 octets
541 char text_[max_utf8_]; // memory for actual ASCII or UTF-8 byte contents
542 uchar len_; // length of bytes in text_[] buffer; 1 for ASCII, >1 for UTF-8
543 uchar attrib_; // attribute bits for this char (bold, underline..)
544 uchar charflags_; // CharFlags (xterm colors management)
545 Fl_Color fgcolor_; // fltk fg color (supports 8color or 24bit color set w/ESC[37;<r>;<g>;<b>m)
546 Fl_Color bgcolor_; // fltk bg color (supports 8color or 24bit color set w/ESC[47;<r>;<g>;<b>m)
547 // Private methods
548 void text_utf8_(const char *text, int len);
549 Fl_Color attr_color_(Fl_Color col, const Fl_Widget *grp) const;
550 public:
551 // Public methods
552 Utf8Char(void); // ctor
553 Utf8Char(const Utf8Char& o); // copy ctor
554 ~Utf8Char(void); // dtor
555 Utf8Char& operator=(const Utf8Char& o); // assignment
556 inline int max_utf8() const { return max_utf8_; }
557 void text_utf8(const char *text, int len, const CharStyle& style);
558 void text_ascii(char c, const CharStyle& style);
559 void fl_font_set(const CharStyle& style) const;
560
561 // Return the UTF-8 text string for this character.
562 // Use length() to get number of bytes in string, which will be 1 for ASCII chars.
563 //
564 const char* text_utf8(void) const { return text_; }
565 // Return the attribute for this char
566 uchar attrib(void) const { return attrib_; }
567 uchar charflags(void) const { return charflags_; }
568 Fl_Color fgcolor(void) const;
569 Fl_Color bgcolor(void) const;
570 // Return the length of this character in bytes (UTF-8 can be multibyte..)
571 int length(void) const { return int(len_); }
572 double pwidth(void) const;
573 int pwidth_int(void) const;
574 // Clear the character to a 'space'
575 void clear(const CharStyle& style) { text_utf8(" ", 1, style); charflags_ = 0; attrib_ = 0; }
576 bool is_char(char c) const { return *text_ == c; }
577 void show_char(void) const { ::printf("%.*s", len_, text_); }
578 void show_char_info(void) const { ::fprintf(stderr, "UTF-8('%.*s', len=%d)\n", len_, text_, len_); }
579 Fl_Color attr_fg_color(const Fl_Widget *grp) const;
580 Fl_Color attr_bg_color(const Fl_Widget *grp) const;
581 };
582
583 // RingBuffer Class ///////////////////////////////////////////////////
584 //
585 // Manages ring with indexed row/col and "history" vs. "display" concepts.
586 //
587 class FL_EXPORT RingBuffer {
588 Utf8Char *ring_chars_; // the ring UTF-8 char buffer
589 int ring_rows_; // #rows in ring total
590 int ring_cols_; // #columns in ring/hist/disp
591 int nchars_; // #chars in ring (ring_rows*ring_cols)
592 int hist_rows_; // #rows in history
593 int hist_use_; // #rows in use by history
594 int disp_rows_; // #rows in display
595 int offset_; // index offset (used for 'scrolling')
596
597 private:
598 void new_copy(int drows, int dcols, int hrows, const CharStyle& style);
599 //DEBUG void write_row(FILE *fp, Utf8Char *u8c, int cols) const {
600 //DEBUG cols = (cols != 0) ? cols : ring_cols();
601 //DEBUG for ( int col=0; col<cols; col++, u8c++ ) {
602 //DEBUG ::fprintf(fp, "%.*s", u8c->length(), u8c->text_utf8());
603 //DEBUG }
604 //DEBUG }
605 public:
606 void clear(void);
607 void clear_hist(void);
608 RingBuffer(void);
609 RingBuffer(int drows, int dcols, int hrows);
610 ~RingBuffer(void);
611
612 // Methods to access ring
613 //
614 // The 'offset' concept allows the 'history' and 'display'
615 // to be scrolled indefinitely. The 'offset' is applied
616 // to all the row accesses, and are clamped to within their bounds.
617 //
618 // For 'raw' access to the ring (without the offset concept),
619 // use the ring_chars() method, and walk from 0 - ring_rows().
620 //
621 // _____________
622 // | | <- hist_srow() <- ring_srow()
623 // | H i s t |
624 // | |
625 // |_____________| <- hist_erow()
626 // | | <- disp_srow()
627 // | D i s p |
628 // | |
629 // |_____________| <- disp_erow() <- ring_erow()
630 //
631 // \___________/
632 // ring_cols()
633 // hist_cols()
634 // disp_cols()
635 //
636 inline int ring_rows(void) const { return ring_rows_; }
637 inline int ring_cols(void) const { return ring_cols_; }
638 inline int ring_srow(void) const { return(0); }
639 inline int ring_erow(void) const { return(ring_rows_ - 1); }
640 inline int hist_rows(void) const { return hist_rows_; }
641 inline int hist_cols(void) const { return ring_cols_; }
642 inline int hist_srow(void) const { return((offset_ + 0) % ring_rows_); }
643 inline int hist_erow(void) const { return((offset_ + hist_rows_ - 1) % ring_rows_); }
644 inline int disp_rows(void) const { return disp_rows_; }
645 inline int disp_cols(void) const { return ring_cols_; }
646 inline int disp_srow(void) const { return((offset_ + hist_rows_) % ring_rows_); }
647 inline int disp_erow(void) const { return((offset_ + hist_rows_ + disp_rows_ - 1) % ring_rows_); }
648 inline int offset(void) const { return offset_; }
649 void offset_adjust(int rows);
650 void hist_rows(int val) { hist_rows_ = val; }
651 void disp_rows(int val) { disp_rows_ = val; }
652
653 // History use
654 inline int hist_use(void) const { return hist_use_; }
655 inline void hist_use(int val) { hist_use_ = val; }
656 inline int hist_use_srow(void) const { return((offset_ + hist_rows_ - hist_use_) % ring_rows_); }
657 inline Utf8Char *ring_chars(void) { return ring_chars_; } // access ring buffer directly
658 inline Utf8Char *ring_chars(void) const { return ring_chars_; } // access ring buffer directly
659
660 bool is_hist_ring_row(int grow) const;
661 bool is_disp_ring_row(int grow) const;
662 //DEBUG void show_ring_info(void) const;
663 void move_disp_row(int src_row, int dst_row);
664 void clear_disp_rows(int sdrow, int edrow, const CharStyle& style);
665 void scroll(int rows, const CharStyle& style);
666
667 const Utf8Char* u8c_ring_row(int row) const;
668 const Utf8Char* u8c_hist_row(int hrow) const;
669 const Utf8Char* u8c_hist_use_row(int hurow) const;
670 const Utf8Char* u8c_disp_row(int drow) const;
671 // Non-const versions of the above methods
672 // Using "Effective C++" ugly-as-hell syntax technique.
673 //
674 Utf8Char* u8c_ring_row(int row);
675 Utf8Char* u8c_hist_row(int hrow);
676 Utf8Char* u8c_hist_use_row(int hurow);
677 Utf8Char* u8c_disp_row(int drow);
678
679 void create(int drows, int dcols, int hrows);
680 void resize(int drows, int dcols, int hrows, const CharStyle& style);
681
682 void change_disp_rows(int drows, const CharStyle& style);
683 void change_disp_cols(int dcols, const CharStyle& style);
684 };
685
686 // Selection Class ///////////////////////////////////////////////////
687 //
688 // Class to manage mouse selection
689 //
690 class FL_EXPORT Selection {
691 Fl_Terminal *terminal_;
692 int srow_, scol_, erow_, ecol_; // selection start/end. NOTE: start *might* be > end
693 int push_row_, push_col_; // global row/col for last FL_PUSH
694 bool push_char_right_;
695 Fl_Color selectionbgcolor_;
696 Fl_Color selectionfgcolor_;
697 int state_ ; // 0=none, 1=started, 2=extended, 3=done
698 bool is_selection_; // false: no selection
699 public:
700 Selection(Fl_Terminal *terminal);
701 int srow(void) const { return srow_; }
702 int scol(void) const { return scol_; }
703 int erow(void) const { return erow_; }
704 int ecol(void) const { return ecol_; }
705 void push_clear() { push_row_ = push_col_ = -1; push_char_right_ = false; }
706 void push_rowcol(int row,int col,bool char_right) {
707 push_row_ = row; push_col_ = col; push_char_right_ = char_right; }
708 void start_push() { start(push_row_, push_col_, push_char_right_); }
709 bool dragged_off(int row,int col,bool char_right) {
710 return (push_row_ != row) || (push_col_+push_char_right_ != col+char_right); }
711 void selectionfgcolor(Fl_Color val) { selectionfgcolor_ = val; }
712 void selectionbgcolor(Fl_Color val) { selectionbgcolor_ = val; }
713 Fl_Color selectionfgcolor(void) const { return selectionfgcolor_; }
714 Fl_Color selectionbgcolor(void) const { return selectionbgcolor_; }
715 bool is_selection(void) const { return is_selection_; }
716 bool get_selection(int &srow,int &scol,int &erow,int &ecol) const; // guarantees return (start < end)
717 bool start(int row, int col, bool char_right);
718 bool extend(int row, int col, bool char_right);
719 void end(void);
720 void select(int srow, int scol, int erow, int ecol);
721 bool clear(void);
722 int state(void) const { return state_; }
723 void scroll(int nrows);
724 };
725
726 // EscapeSeq Class ///////////////////////////////////////////////////
727 //
728 // Class to handle parsing ESC sequences
729 //
730 // Holds all state information for parsing esc sequences,
731 // so sequences can span multiple block read(2) operations, etc.
732 // Handling of parsed sequences is NOT handled in this class,
733 // just the parsing of the sequences and managing generic integers.
734 //
735 class FL_EXPORT EscapeSeq {
736 public:
737 // EscapeSeq Constants
738 // Maximums
739 static const int maxbuff = 80; // character buffer
740 static const int maxvals = 20; // integer value buffer
741 // Return codes
742 static const int success = 0; // operation succeeded
743 static const int fail = -1; // operation failed
744 static const int completed = 1; // multi-step operation completed successfully
745 private:
746 char esc_mode_; // escape parsing mode state
747 char csi_; // This is an ESC[.. sequence (Ctrl Seq Introducer)
748 char buff_[maxbuff]; // escape sequence being parsed
749 char *buffp_; // parsing ptr into buff[]
750 char *buffendp_; // end of buff[] (ptr to last valid buff char)
751 char *valbuffp_; // pointer to first char in buff of integer being parsed
752 int vals_[maxvals]; // value array for parsing #'s in ESC[#;#;#..
753 int vali_; // parsing index into vals_[], 0 if none
754 int save_row_, save_col_; // used by ESC[s/u for save/restore
755
756 int append_buff(char c);
757 int append_val(void);
758
759 public:
760 EscapeSeq(void);
761 void reset(void);
762 char esc_mode(void) const;
763 void esc_mode(char val);
764 int total_vals(void) const;
765 int val(int i) const;
766 int defvalmax(int dval, int max) const;
767 bool parse_in_progress(void) const;
768 bool is_csi(void) const;
769 int parse(char c);
770 void save_cursor(int row, int col);
771 void restore_cursor(int &row, int &col);
772 };
773
774 // Partial UTF-8 Buffer Class ////////////////////////////////////////////
775 //
776 // Class to manage buffering partial UTF-8 characters between write calls.
777 //
778 class FL_EXPORT PartialUtf8Buf {
779 char buf_[10]; // buffer partial UTF-8 encoded char
780 int buflen_; // length of buffered UTF-8 encoded char
781 int clen_; // final byte length of a UTF-8 char
782 public:
783 void clear(void) { buflen_ = clen_ = 0; } // clear the buffer
784 PartialUtf8Buf(void) { clear(); } // Ctor
785 // Is byte 'c' in the middle of a UTF-8 encoded byte sequence?
786 bool is_continuation(char c) {
787 // Byte 1 Byte 2 Byte 3 ..etc..
788 // ASCII: 0xxxxxxx
789 // UTF8(2): 110xxxxx 10xxxxxx
790 // UTF8(3): 1110xxxx 10xxxxxx 10xxxxxx
791 // UTF8(4): 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
792 // UTF8(5): 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
793 // UTF8(6): 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
794 // \______/ \______________________________________________/
795 // Start byte Continuation bytes
796 // (c & 0xc0) == 0x80
797 return ((c & 0xc0) == 0x80);
798 }
799 // Access buffer
800 const char* buf(void) const { return buf_; }
801 // Access buffer length
802 int buflen(void) const { return buflen_; }
803 // Append bytes of a partial UTF-8 string to the buffer.
804 //
805 // Returns:
806 // - true if done OK. Use is_complete() to see if a complete char received.
807 // - false if buffer overrun occurred, class is clear()ed.
808 //
809 // An appropriate response to 'false' would be to print the
810 // "unknown character" and skip all subsequent UTF-8 continuation chars.
811 //
812 bool append(const char* p, int len) {
813 if (len <= 0) return true; // ignore silly requests: say we did but dont
814 if (buflen_ + len >= (int)sizeof(buf_)) // overrun check
815 { clear(); return false; } // clear self, return false
816 if (!buflen_) clen_ = fl_utf8len(*p); // first byte? save char len for later
817 while (len>0) { buf_[buflen_++] = *p++; len--; } // append byte to buffer
818 return true;
819 }
820 bool is_complete(void) const { return (buflen_ && (buflen_ == clen_)); }
821 };
822
828 public:
842 Fl_Scrollbar *scrollbar; // vertical scrollbar (value: rows above disp_chars[])
853 Fl_Scrollbar *hscrollbar; // horizontal scrollbar
854 private:
855 // Special utf8 symbols
856 const char *error_char_; // utf8 string shown for invalid utf8, bad ANSI, etc
857 bool fontsize_defer_; // flag defers font calcs until first draw() (issue 837)
858 int scrollbar_size_; // local preference for scrollbar size
859 ScrollbarStyle hscrollbar_style_;
860 CharStyle *current_style_; // current font, attrib, color..
861 OutFlags oflags_; // output translation flags (CR_TO_LF, LF_TO_CR, LF_TO_CRLF)
862
863 // A ring buffer is used for the terminal's history (hist) and display (disp) buffer.
864 // See README-Fl_Terminal.txt, section "RING BUFFER DESCRIPTION" for diagrams/info.
865 //
866 // Ring buffer
867 RingBuffer ring_; // terminal history/display ring buffer
868 Cursor cursor_; // terminal cursor (position, color, etc)
869 Margin margin_; // terminal margins (top,left,bottom,right)
870 Selection select_; // mouse selection
871 EscapeSeq escseq; // Escape sequence parsing (ESC[ xterm/vt100)
872 bool show_unknown_; // if true, show unknown chars as '¿' (default off)
873 bool ansi_; // if true, parse ansi codes (default on)
874 char *tabstops_; // array of tab stops (0|1) \__ TODO: This should probably
875 int tabstops_size_; // size of tabstops[] array / be a class "TabStops".
876 Fl_Rect scrn_; // terminal screen xywh inside box(), margins, and scrollbar
877 int autoscroll_dir_; // 0=autoscroll timer off, 3=scrolling up, 4=scrolling down
878 int autoscroll_amt_; // #pixels above or below edge, used for autoscroll speed
879 RedrawStyle redraw_style_; // NO_REDRAW, RATE_LIMITED, PER_WRITE
880 float redraw_rate_; // maximum redraw rate in seconds, default=0.10
881 bool redraw_modified_; // display modified; used by update_cb() to rate limit redraws
882 bool redraw_timer_; // if true, redraw timer is running
883 PartialUtf8Buf pub_; // handles Partial Utf8 Buffer (pub)
884
885 protected:
886 // Ring buffer management
887 const Utf8Char* u8c_ring_row(int grow) const;
888 const Utf8Char* u8c_hist_row(int hrow) const;
889 const Utf8Char* u8c_hist_use_row(int hrow) const;
890 const Utf8Char* u8c_disp_row(int drow) const;
891 // Non-const versions of the above.
892 // "Effective C++" says: implement non-const method to cast away const
893 //
894 Utf8Char* u8c_ring_row(int grow);
895 Utf8Char* u8c_hist_row(int hrow);
896 Utf8Char* u8c_hist_use_row(int hurow);
897 Utf8Char* u8c_disp_row(int drow);
898 Utf8Char* u8c_cursor(void);
899 private:
900 void create_ring(int drows, int dcols, int hrows);
901 void init_(int X,int Y,int W,int H,const char*L,int rows,int cols,int hist,bool fontsize_defer);
902 // Tabstops
903 void init_tabstops(int newsize);
904 void default_tabstops(void);
905 void clear_all_tabstops(void);
906 void set_tabstop(void);
907 void clear_tabstop(void);
908 // Updates
909 void update_screen_xywh(void);
910 void update_screen(bool font_changed);
911 void set_scrollbar_params(Fl_Scrollbar* scroll, int min, int max);
912 void update_scrollbar(void);
913 // Resize
914 void resize_display_rows(int drows);
915 void resize_display_columns(int dcols);
916 void refit_disp_to_screen(void);
917 // Callbacks
918 static void scrollbar_cb(Fl_Widget*, void*); // scrollbar manipulation
919 static void autoscroll_timer_cb(void*); // mouse drag autoscroll
920 void autoscroll_timer_cb2(void);
921 static void redraw_timer_cb(void*); // redraw rate limiting timer
922 void redraw_timer_cb2(void);
923
924 // Screen management
925 protected:
926 CharStyle& current_style(void) const;
927 void current_style(const CharStyle& sty);
928 private:
929 int x_to_glob_col(int X, int grow, int &gcol, bool &gcr) const;
930 int xy_to_glob_rowcol(int X, int Y, int &grow, int &gcol, bool &gcr) const;
931 protected:
932 int w_to_col(int W) const;
933 int h_to_row(int H) const;
934 // API: Display clear operations
935 void clear_sod(void);
936 void clear_eod(void);
937 void clear_eol(void);
938 void clear_sol(void);
939 void clear_line(int row);
940 void clear_line(void);
941 const Utf8Char* walk_selection(const Utf8Char *u8c, int &row, int &col) const;
942 bool get_selection(int &srow,int &scol,int &erow,int &ecol) const;
943 bool is_selection(void) const;
944 bool is_inside_selection(int row,int col) const;
945 private:
946 bool is_hist_ring_row(int grow) const;
947 bool is_disp_ring_row(int grow) const;
948 public:
949 int selection_text_len(void) const;
950 const char* selection_text(void) const;
951 protected:
952 void clear_mouse_selection(void);
953 bool selection_extend(int X,int Y);
954 void select_word(int grow, int gcol);
955 void select_line(int grow);
956 void scroll(int rows);
957 void insert_rows(int count);
958 void delete_rows(int count);
959 void insert_char_eol(char c, int drow, int dcol, int rep);
960 void insert_char(char c, int rep);
961 void delete_chars(int drow, int dcol, int rep);
962 void delete_chars(int rep);
963 public:
964 // API: Terminal operations
965 void clear(void);
966 void clear(Fl_Color val);
967 void clear_screen(bool scroll_to_hist=true); // ESC [ 2 J
968 void clear_screen_home(bool scroll_to_hist=true); // ESC [ H ESC [ 2 J
969 void clear_history(void); // ESC [ 3 J
970 void reset_terminal(void); // ESC c
971 void cursor_home(void); // ESC [ 0 H
972 // API: Cursor
973 void cursorfgcolor(Fl_Color val);
974 void cursorbgcolor(Fl_Color val);
975 Fl_Color cursorfgcolor(void) const;
976 Fl_Color cursorbgcolor(void) const;
977 protected:
978 void cursor_row(int row);
979 void cursor_col(int col);
980 public:
981 int cursor_row(void) const;
982 int cursor_col(void) const;
983 protected:
984 void cursor_up(int count=1, bool do_scroll=false);
985 void cursor_down(int count=1, bool do_scroll=false);
986 void cursor_left(int count=1);
987 void cursor_right(int count=1, bool do_scroll=false);
988 void cursor_eol(void);
989 void cursor_sol(void);
990 void cursor_cr(void);
991 void cursor_crlf(int count=1);
992 void cursor_tab_right(int count=1);
993 void cursor_tab_left(int count=1);
994 void save_cursor(void);
995 void restore_cursor(void);
996 // Output translation
997 public:
998 void output_translate(Fl_Terminal::OutFlags val);
999 Fl_Terminal::OutFlags output_translate(void) const;
1000 private:
1001 void handle_lf(void);
1002 void handle_cr(void);
1003 void handle_esc(void);
1004 // Printing
1005 void handle_ctrl(char c);
1006 bool is_printable(char c);
1007 bool is_ctrl(char c);
1008 void handle_SGR(void);
1009 void handle_DECRARA(void);
1010 void handle_escseq(char c);
1011 // --
1012 void display_modified(void);
1013 void display_modified_clear(void);
1014 void clear_char_at_disp(int drow, int dcol);
1015 protected:
1016 const Utf8Char* utf8_char_at_disp(int drow, int dcol) const;
1017 const Utf8Char* utf8_char_at_glob(int grow, int gcol) const;
1018 private:
1019 void repeat_char(char c, int rep);
1020 void utf8_cache_clear(void);
1021 void utf8_cache_flush(void);
1022 // API: Character display output
1023 public:
1024 void plot_char(const char *text, int len, int drow, int dcol);
1025 void plot_char(char c, int drow, int dcol);
1026 void print_char(const char *text, int len=-1);
1027 void print_char(char c);
1028 // API: String display output
1029 void append_utf8(const char *buf, int len=-1);
1030 void append_ascii(const char *s);
1031 void append(const char *s, int len=-1);
1032 protected:
1033 int handle_unknown_char(void);
1034 int handle_unknown_char(int drow, int dcol);
1035 // Drawing
1036 void draw_row_bg(int grow, int X, int Y) const;
1037 void draw_row(int grow, int Y) const;
1038 void draw_buff(int Y) const;
1039 private:
1040 void handle_selection_autoscroll(void);
1041 int handle_selection(int e);
1042 public:
1043 // FLTK: draw(), resize(), handle()
1044 void draw(void) FL_OVERRIDE;
1045 void resize(int X,int Y,int W,int H) FL_OVERRIDE;
1046 int handle(int e) FL_OVERRIDE;
1047 const char* text(bool lines_below_cursor=false) const;
1048
1049 protected:
1050 // Internal short names
1051 // Don't make these public, but allow internals and
1052 // derived classes to maintain brevity.
1053 //
1055 inline int ring_rows(void) const { return ring_.ring_rows(); }
1057 inline int ring_cols(void) const { return ring_.ring_cols(); }
1059 inline int ring_srow(void) const { return ring_.ring_srow(); }
1061 inline int ring_erow(void) const { return ring_.ring_erow(); }
1063 inline int hist_rows(void) const { return ring_.hist_rows(); }
1065 inline int hist_cols(void) const { return ring_.hist_cols(); }
1067 inline int hist_srow(void) const { return ring_.hist_srow(); }
1069 inline int hist_erow(void) const { return ring_.hist_erow(); }
1071 inline int hist_use(void) const { return ring_.hist_use(); }
1073 inline int hist_use_srow(void) const { return ring_.hist_use_srow(); }
1075 inline int disp_rows(void) const { return ring_.disp_rows(); }
1077 inline int disp_cols(void) const { return ring_.disp_cols(); }
1079 inline int disp_srow(void) const { return ring_.disp_srow(); }
1081 inline int disp_erow(void) const { return ring_.disp_erow(); }
1083 inline int offset(void) const { return ring_.offset(); }
1084
1085 // TODO: CLEAN UP WHAT'S PUBLIC, AND WHAT SHOULD BE 'PROTECTED' AND 'PRIVATE'
1086 // Some of the public stuff should, quite simply, "not be".
1087
1088 // API: Terminal features
1089 public:
1090 // API: Scrollbar
1091 int scrollbar_size(void) const;
1092 void scrollbar_size(int val);
1093 int scrollbar_actual_size(void) const;
1094 void hscrollbar_style(ScrollbarStyle val);
1095 ScrollbarStyle hscrollbar_style(void) const;
1096 // API: History
1097 int history_rows(void) const;
1098 void history_rows(int val);
1099 int history_use(void) const;
1100 // API: Display
1101 int display_rows(void) const;
1102 void display_rows(int val);
1103 int display_columns(void) const;
1104 void display_columns(int val);
1105 // API: Box
1113 void box(Fl_Boxtype val) { Fl_Group::box(val); update_screen(false); }
1115 Fl_Boxtype box(void) const { return Fl_Group::box(); }
1116 // API: Margins
1118 int margin_left(void) const { return margin_.left(); }
1120 int margin_right(void) const { return margin_.right(); }
1122 int margin_top(void) const { return margin_.top(); }
1124 int margin_bottom(void) const { return margin_.bottom(); }
1125 void margin_left(int val);
1126 void margin_right(int val);
1127 void margin_top(int val);
1128 void margin_bottom(int val);
1129 // API: Text font/size/color
1130 void textfont(Fl_Font val);
1131 void textsize(Fl_Fontsize val);
1132 void textcolor(Fl_Color val);
1133 void color(Fl_Color val);
1134 void textfgcolor(Fl_Color val);
1135 void textbgcolor(Fl_Color val);
1136 void textfgcolor_default(Fl_Color val);
1137 void textbgcolor_default(Fl_Color val);
1139 Fl_Font textfont(void) const { return current_style_->fontface(); }
1141 Fl_Fontsize textsize(void) const { return current_style_->fontsize(); }
1143 Fl_Color color(void) const { return Fl_Group::color(); }
1145 Fl_Color textcolor(void) const { return textfgcolor_default(); }
1147 Fl_Color textfgcolor(void) const { return current_style_->fgcolor(); }
1149 Fl_Color textbgcolor(void) const { return current_style_->bgcolor(); }
1151 Fl_Color textfgcolor_default(void) const { return current_style_->defaultfgcolor(); }
1153 Fl_Color textbgcolor_default(void) const { return current_style_->defaultbgcolor(); }
1154 void textfgcolor_xterm(uchar val);
1155 void textbgcolor_xterm(uchar val);
1157 void selectionfgcolor(Fl_Color val) { select_.selectionfgcolor(val); }
1159 void selectionbgcolor(Fl_Color val) { select_.selectionbgcolor(val); }
1161 Fl_Color selectionfgcolor(void) const { return select_.selectionfgcolor(); }
1163 Fl_Color selectionbgcolor(void) const { return select_.selectionbgcolor(); }
1164 // API: Text attrib
1165 void textattrib(uchar val);
1166 uchar textattrib() const;
1167 // API: Redraw style/rate
1168 RedrawStyle redraw_style(void) const;
1169 void redraw_style(RedrawStyle val);
1170 private:
1171 bool is_redraw_style(RedrawStyle val) { return redraw_style_ == val; }
1172 public:
1173 float redraw_rate(void) const;
1174 void redraw_rate(float val);
1175 // API: Show unknown/invalid utf8/ANSI sequences with an error character (¿).
1176 bool show_unknown(void) const;
1177 void show_unknown(bool val);
1181 void error_char(const char* val) { error_char_ = val; }
1184 const char* error_char(void) const { return error_char_; }
1185 // API: ANSI sequences
1186 bool ansi(void) const;
1187 void ansi(bool val);
1188 // Fl_Simple_Terminal API compatibility
1189 int history_lines(void) const;
1190 void history_lines(int val);
1191 // API: printf()
1192 void printf(const char *fmt, ...);
1193 void vprintf(const char *fmt, va_list ap);
1194 // Ctor
1195 Fl_Terminal(int X,int Y,int W,int H,const char*L=0);
1196 Fl_Terminal(int X,int Y,int W,int H,const char*L,int rows,int cols,int hist);
1197 // Dtor
1198 ~Fl_Terminal(void);
1199 // Debugging features
1200//DEBUG void show_ring_info() const { ring_.show_ring_info(); }
1201//DEBUG void write_row(FILE *fp, Utf8Char *u8c, int cols) const;
1202//DEBUG void show_buffers(RingBuffer *a, RingBuffer *b=0) const;
1203};
1204#endif
Fl_Font
int Fl_Font
A font number is an index into the internal font table.
Definition Enumerations.H:1063
Fl_Color
unsigned int Fl_Color
An FLTK color value; see also Colors.
Definition Enumerations.H:1120
Fl_Fontsize
int Fl_Fontsize
Size of a font in pixels.
Definition Enumerations.H:1092
Fl_Boxtype
Fl_Boxtype
FLTK standard box types.
Definition Enumerations.H:644
Fl.H
Fl static class.
Fl_Group.H
Fl_Group and Fl_End classes.
Fl_Window.H
Fl_Window widget .
Fl_Group::end
void end()
Exactly the same as current(this->parent()).
Definition Fl_Group.cxx:73
Fl_Group::handle
int handle(int) FL_OVERRIDE
Handles the specified event.
Definition Fl_Group.cxx:145
Fl_Group::resize
void resize(int, int, int, int) FL_OVERRIDE
Resizes the Fl_Group widget and all of its children.
Definition Fl_Group.cxx:825
Fl_Group::draw
void draw() FL_OVERRIDE
Draws the widget.
Definition Fl_Group.cxx:943
Fl_Group::clear
void clear()
Deletes all child widgets from memory recursively.
Definition Fl_Group.cxx:381
Fl_Rect
Rectangle with standard FLTK coordinates (X, Y, W, H).
Definition Fl_Rect.H:30
Fl_Scrollbar
The Fl_Scrollbar widget displays a slider with arrow buttons at the ends of the scrollbar.
Definition Fl_Scrollbar.H:41
Fl_Terminal::CharStyle
Definition Fl_Terminal.H:425
Fl_Terminal::Cursor
Definition Fl_Terminal.H:501
Fl_Terminal::EscapeSeq
Definition Fl_Terminal.H:735
Fl_Terminal::Margin
Definition Fl_Terminal.H:405
Fl_Terminal::PartialUtf8Buf
Definition Fl_Terminal.H:778
Fl_Terminal::RingBuffer
Definition Fl_Terminal.H:587
Fl_Terminal::Selection
Definition Fl_Terminal.H:690
Fl_Terminal::Selection::get_selection
bool get_selection(int &srow, int &scol, int &erow, int &ecol) const
Return selection start/end.
Definition Fl_Terminal.cxx:162
Fl_Terminal::Utf8Char
Definition Fl_Terminal.H:539
Fl_Terminal
Terminal widget supporting Unicode/utf-8, ANSI/xterm escape codes with full RGB color control.
Definition Fl_Terminal.H:320
Fl_Terminal::selectionbgcolor
void selectionbgcolor(Fl_Color val)
Set mouse selection background color.
Definition Fl_Terminal.H:1159
Fl_Terminal::printf
void printf(const char *fmt,...)
Appends printf formatted messages to the terminal.
Definition Fl_Terminal.cxx:4157
Fl_Terminal::Fl_Terminal
Fl_Terminal(int X, int Y, int W, int H, const char *L=0)
The constructor for Fl_Terminal.
Definition Fl_Terminal.cxx:3398
Fl_Terminal::select_word
void select_word(int grow, int gcol)
Select the word around the given row and column.
Definition Fl_Terminal.cxx:2191
Fl_Terminal::u8c_cursor
Utf8Char * u8c_cursor(void)
Return the Utf8Char* for character under cursor.
Definition Fl_Terminal.cxx:1189
Fl_Terminal::error_char
const char * error_char(void) const
Returns the "error character" utf8 string, which is shown for invalid utf8 or bad ANSI sequences if s...
Definition Fl_Terminal.H:1184
Fl_Terminal::insert_char
void insert_char(char c, int rep)
Insert char 'c' at the current cursor position for 'rep' times.
Definition Fl_Terminal.cxx:2312
Fl_Terminal::disp_srow
int disp_srow(void) const
Return the starting row# in the display area.
Definition Fl_Terminal.H:1079
Fl_Terminal::cursor_tab_right
void cursor_tab_right(int count=1)
Tab right, do not wrap beyond right edge.
Definition Fl_Terminal.cxx:2533
Fl_Terminal::cursor_cr
void cursor_cr(void)
Move cursor as if a CR (\r) was received.
Definition Fl_Terminal.cxx:2522
Fl_Terminal::clear_screen_home
void clear_screen_home(bool scroll_to_hist=true)
Clear the terminal screen and home the cursor.
Definition Fl_Terminal.cxx:1929
Fl_Terminal::color
Fl_Color color(void) const
Return base widget Fl_Group's box() color().
Definition Fl_Terminal.H:1143
Fl_Terminal::selection_text
const char * selection_text(void) const
Return text selection (for copy()/paste() operations).
Definition Fl_Terminal.cxx:2135
Fl_Terminal::clear_eol
void clear_eol(void)
Clear from cursor to End Of Line (EOL), like "<ESC>[K".
Definition Fl_Terminal.cxx:1959
Fl_Terminal::cursor_eol
void cursor_eol(void)
Move cursor to the last column (at the far right) on the current line.
Definition Fl_Terminal.cxx:2516
Fl_Terminal::hist_rows
int hist_rows(void) const
Return the number of rows in the scrollback history.
Definition Fl_Terminal.H:1063
Fl_Terminal::is_selection
bool is_selection(void) const
Returns true if there's a mouse selection.
Definition Fl_Terminal.cxx:1988
Fl_Terminal::textbgcolor_default
Fl_Color textbgcolor_default(void) const
Return text's default background color.
Definition Fl_Terminal.H:1153
Fl_Terminal::draw_row
void draw_row(int grow, int Y) const
Draw the specified global row, which is the row in ring_chars[].
Definition Fl_Terminal.cxx:3632
Fl_Terminal::append
void append(const char *s, int len=-1)
Appends string s to the terminal at the current cursor position using the current text color/attribut...
Definition Fl_Terminal.cxx:3280
Fl_Terminal::margin_left
int margin_left(void) const
Return the left margin; see Margins.
Definition Fl_Terminal.H:1118
Fl_Terminal::cursor_home
void cursor_home(void)
Move cursor to the home position (top/left).
Definition Fl_Terminal.cxx:2513
Fl_Terminal::draw_row_bg
void draw_row_bg(int grow, int X, int Y) const
Draw the background for the specified ring_chars[] global row grow starting at FLTK coords X and Y.
Definition Fl_Terminal.cxx:3595
Fl_Terminal::selection_extend
bool selection_extend(int X, int Y)
Extend selection to FLTK coords X,Y.
Definition Fl_Terminal.cxx:2173
Fl_Terminal::selectionfgcolor
Fl_Color selectionfgcolor(void) const
Get mouse selection foreground color.
Definition Fl_Terminal.H:1161
Fl_Terminal::w_to_col
int w_to_col(int W) const
Given a width in pixels, return number of columns that "fits" into that area.
Definition Fl_Terminal.cxx:3771
Fl_Terminal::delete_chars
void delete_chars(int drow, int dcol, int rep)
Delete char(s) at (drow,dcol) for 'rep' times.
Definition Fl_Terminal.cxx:2317
Fl_Terminal::plot_char
void plot_char(const char *text, int len, int drow, int dcol)
Plot the UTF-8 character text of length len at display position (drow,dcol).
Definition Fl_Terminal.cxx:3041
Fl_Terminal::cursor_tab_left
void cursor_tab_left(int count=1)
Tab left, do not wrap beyond left edge.
Definition Fl_Terminal.cxx:2547
Fl_Terminal::Attrib
Attrib
Bits for the per-character attributes, which control text features such as italic,...
Definition Fl_Terminal.H:346
Fl_Terminal::NORMAL
@ NORMAL
all attributes off
Definition Fl_Terminal.H:347
Fl_Terminal::ITALIC
@ ITALIC
italic font text
Definition Fl_Terminal.H:350
Fl_Terminal::DIM
@ DIM
dim text; color slightly darker than normal
Definition Fl_Terminal.H:349
Fl_Terminal::STRIKEOUT
@ STRIKEOUT
strikeout text
Definition Fl_Terminal.H:355
Fl_Terminal::UNDERLINE
@ UNDERLINE
underlined text
Definition Fl_Terminal.H:351
Fl_Terminal::BOLD
@ BOLD
bold text: uses bold font, color brighter than normal
Definition Fl_Terminal.H:348
Fl_Terminal::_RESERVED_2
@ _RESERVED_2
(reserved for internal future use)
Definition Fl_Terminal.H:354
Fl_Terminal::_RESERVED_1
@ _RESERVED_1
(reserved for internal future use)
Definition Fl_Terminal.H:352
Fl_Terminal::INVERSE
@ INVERSE
inverse text; fg/bg color are swapped
Definition Fl_Terminal.H:353
Fl_Terminal::cursor_sol
void cursor_sol(void)
Move cursor to the first column (at the far left) on the current line.
Definition Fl_Terminal.cxx:2519
Fl_Terminal::selectionbgcolor
Fl_Color selectionbgcolor(void) const
Get mouse selection background color.
Definition Fl_Terminal.H:1163
Fl_Terminal::offset
int offset(void) const
Returns the current offset into the ring buffer.
Definition Fl_Terminal.H:1083
Fl_Terminal::clear_line
void clear_line(int row)
Clear entire line for specified row.
Definition Fl_Terminal.cxx:1975
Fl_Terminal::walk_selection
const Utf8Char * walk_selection(const Utf8Char *u8c, int &row, int &col) const
Walk the mouse selection one character at a time from beginning to end, returning a Utf8Char* to the ...
Definition Fl_Terminal.cxx:2014
Fl_Terminal::cursorfgcolor
void cursorfgcolor(Fl_Color val)
Set the cursor's foreground color used for text under the cursor.
Definition Fl_Terminal.cxx:2429
Fl_Terminal::margin_bottom
int margin_bottom(void) const
Return the bottom margin; see Margins.
Definition Fl_Terminal.H:1124
Fl_Terminal::scrollbar
Fl_Scrollbar * scrollbar
Vertical scrollbar.
Definition Fl_Terminal.H:842
Fl_Terminal::is_inside_selection
bool is_inside_selection(int row, int col) const
Is global row/column inside the current mouse selection?
Definition Fl_Terminal.cxx:2082
Fl_Terminal::u8c_ring_row
const Utf8Char * u8c_ring_row(int grow) const
See docs for non-const version of u8c_ring_row(int).
Definition Fl_Terminal.cxx:1054
Fl_Terminal::selection_text_len
int selection_text_len(void) const
Return byte length of all UTF-8 chars in selection, or 0 if no selection.
Definition Fl_Terminal.cxx:2121
Fl_Terminal::u8c_disp_row
const Utf8Char * u8c_disp_row(int drow) const
See docs for non-const version of u8c_disp_row(int).
Definition Fl_Terminal.cxx:1066
Fl_Terminal::margin_top
int margin_top(void) const
Return the top margin; see Margins.
Definition Fl_Terminal.H:1122
Fl_Terminal::hist_srow
int hist_srow(void) const
Return the starting row# of the scrollback history.
Definition Fl_Terminal.H:1067
Fl_Terminal::reset_terminal
void reset_terminal(void)
Resets terminal to default colors, clears screen, history and mouse selection, homes cursor,...
Definition Fl_Terminal.cxx:2355
Fl_Terminal::textfont
Fl_Font textfont(void) const
Return text font used to draw all text in the terminal.
Definition Fl_Terminal.H:1139
Fl_Terminal::error_char
void error_char(const char *val)
Sets the "error character" utf8 string shown for invalid utf8 or bad ANSI sequences if show_unknown()...
Definition Fl_Terminal.H:1181
Fl_Terminal::cursor_left
void cursor_left(int count=1)
Moves cursor left count columns, and cursor stops (does not wrap) if it hits screen edge.
Definition Fl_Terminal.cxx:2489
Fl_Terminal::disp_erow
int disp_erow(void) const
Return the ending row# in the display area.
Definition Fl_Terminal.H:1081
Fl_Terminal::utf8_char_at_disp
const Utf8Char * utf8_char_at_disp(int drow, int dcol) const
Return Utf8Char* for char at specified display row and column.
Definition Fl_Terminal.cxx:3007
Fl_Terminal::restore_cursor
void restore_cursor(void)
Restore previously saved cursor position, if any. Used by ESC [ u.
Definition Fl_Terminal.cxx:2563
Fl_Terminal::output_translate
void output_translate(Fl_Terminal::OutFlags val)
Sets the combined output translation flags to val.
Definition Fl_Terminal.cxx:2611
Fl_Terminal::clear_eod
void clear_eod(void)
Clear from cursor to End Of Display (EOD), like "<ESC>[J<ESC>[0J".
Definition Fl_Terminal.cxx:1947
Fl_Terminal::text
const char * text(bool lines_below_cursor=false) const
Return a string copy of all lines in the terminal (including history).
Definition Fl_Terminal.cxx:3983
Fl_Terminal::textfgcolor
Fl_Color textfgcolor(void) const
Return text's current foreground color.
Definition Fl_Terminal.H:1147
Fl_Terminal::textsize
Fl_Fontsize textsize(void) const
Return text font size used to draw all text in the terminal.
Definition Fl_Terminal.H:1141
Fl_Terminal::scroll
void scroll(int rows)
Scroll the display up(+) or down(-) the specified rows.
Definition Fl_Terminal.cxx:2224
Fl_Terminal::cursor_crlf
void cursor_crlf(int count=1)
Move cursor as if a CR/LF pair (\r\n) was received.
Definition Fl_Terminal.cxx:2525
Fl_Terminal::clear_mouse_selection
void clear_mouse_selection(void)
Clear any current mouse selection.
Definition Fl_Terminal.cxx:2165
Fl_Terminal::current_style
CharStyle & current_style(void) const
Return reference to internal current style for rendering text.
Definition Fl_Terminal.cxx:1556
Fl_Terminal::save_cursor
void save_cursor(void)
Save current cursor position. Used by ESC [ s.
Definition Fl_Terminal.cxx:2558
Fl_Terminal::draw_buff
void draw_buff(int Y) const
Draws the buffer position we are scrolled to onto the FLTK screen starting at pixel position Y.
Definition Fl_Terminal.cxx:3709
Fl_Terminal::insert_rows
void insert_rows(int count)
Insert (count) rows at current cursor position.
Definition Fl_Terminal.cxx:2236
Fl_Terminal::ring_cols
int ring_cols(void) const
Return the number of columns in the ring buffer.
Definition Fl_Terminal.H:1057
Fl_Terminal::cursorbgcolor
void cursorbgcolor(Fl_Color val)
Set the cursor's background color used for the cursor itself.
Definition Fl_Terminal.cxx:2431
Fl_Terminal::CharFlags
CharFlags
Per-character 8 bit flags (uchar) used to manage special states for characters.
Definition Fl_Terminal.H:362
Fl_Terminal::BG_XTERM
@ BG_XTERM
this char's bg color is an XTERM color; can be affected by Dim+Bold
Definition Fl_Terminal.H:364
Fl_Terminal::FG_XTERM
@ FG_XTERM
this char's fg color is an XTERM color; can be affected by Dim+Bold
Definition Fl_Terminal.H:363
Fl_Terminal::EOL
@ EOL
TODO: char at EOL, used for line re-wrap during screen resizing.
Definition Fl_Terminal.H:365
Fl_Terminal::ScrollbarStyle
ScrollbarStyle
Behavior of scrollbars.
Definition Fl_Terminal.H:389
Fl_Terminal::SCROLLBAR_OFF
@ SCROLLBAR_OFF
scrollbar always invisible
Definition Fl_Terminal.H:390
Fl_Terminal::SCROLLBAR_AUTO
@ SCROLLBAR_AUTO
scrollbar visible if widget resized in a way that hides columns (default)
Definition Fl_Terminal.H:391
Fl_Terminal::SCROLLBAR_ON
@ SCROLLBAR_ON
scrollbar always visible
Definition Fl_Terminal.H:392
Fl_Terminal::clear_history
void clear_history(void)
Clears the scroll history buffer and adjusts scrollbar, forcing it to redraw().
Definition Fl_Terminal.cxx:2336
Fl_Terminal::hist_cols
int hist_cols(void) const
Return the number of columns in the scrollback history.
Definition Fl_Terminal.H:1065
Fl_Terminal::textbgcolor
Fl_Color textbgcolor(void) const
Return text's current background color.
Definition Fl_Terminal.H:1149
Fl_Terminal::textfgcolor_default
Fl_Color textfgcolor_default(void) const
Return text's default foreground color.
Definition Fl_Terminal.H:1151
Fl_Terminal::RedrawStyle
RedrawStyle
Determines when Fl_Terminal calls redraw() if new text is added.
Definition Fl_Terminal.H:332
Fl_Terminal::NO_REDRAW
@ NO_REDRAW
app must call redraw() as needed to update text to screen
Definition Fl_Terminal.H:333
Fl_Terminal::PER_WRITE
@ PER_WRITE
redraw triggered after every append() / printf() / etc. operation
Definition Fl_Terminal.H:335
Fl_Terminal::RATE_LIMITED
@ RATE_LIMITED
timer controlled redraws. (DEFAULT)
Definition Fl_Terminal.H:334
Fl_Terminal::u8c_hist_use_row
const Utf8Char * u8c_hist_use_row(int hrow) const
See docs for non-const version of u8c_hist_use_row(int).
Definition Fl_Terminal.cxx:1062
Fl_Terminal::print_char
void print_char(const char *text, int len=-1)
Prints single UTF-8 char text of optional byte length len at current cursor position,...
Definition Fl_Terminal.cxx:3099
Fl_Terminal::cursor_right
void cursor_right(int count=1, bool do_scroll=false)
Moves cursor right count columns.
Definition Fl_Terminal.cxx:2501
Fl_Terminal::margin_right
int margin_right(void) const
Return the right margin; see Margins.
Definition Fl_Terminal.H:1120
Fl_Terminal::ring_rows
int ring_rows(void) const
Return the number of rows in the ring buffer.
Definition Fl_Terminal.H:1055
Fl_Terminal::textfgcolor_default
void textfgcolor_default(Fl_Color val)
Set the default text foreground color used by <ESC>c, <ESC>[0m, and reset_terminal().
Definition Fl_Terminal.cxx:1793
Fl_Terminal::utf8_char_at_glob
const Utf8Char * utf8_char_at_glob(int grow, int gcol) const
Return Utf8Char* for char at specified global (grow,gcol).
Definition Fl_Terminal.cxx:3021
Fl_Terminal::hist_use
int hist_use(void) const
Return number of rows in use by the scrollback history.
Definition Fl_Terminal.H:1071
Fl_Terminal::disp_rows
int disp_rows(void) const
Return the number of rows in the display area.
Definition Fl_Terminal.H:1075
Fl_Terminal::hist_use_srow
int hist_use_srow(void) const
Return the starting row of the "in use" scrollback history.
Definition Fl_Terminal.H:1073
Fl_Terminal::disp_cols
int disp_cols(void) const
Return the number of columns in the display area.
Definition Fl_Terminal.H:1077
Fl_Terminal::hscrollbar
Fl_Scrollbar * hscrollbar
Horizontal scrollbar.
Definition Fl_Terminal.H:853
Fl_Terminal::ring_srow
int ring_srow(void) const
Return the starting row# in the ring buffer. (Always 0).
Definition Fl_Terminal.H:1059
Fl_Terminal::h_to_row
int h_to_row(int H) const
Given a height in pixels, return number of rows that "fits" into that area.
Definition Fl_Terminal.cxx:3779
Fl_Terminal::get_selection
bool get_selection(int &srow, int &scol, int &erow, int &ecol) const
Return mouse selection's start/end position in the ring buffer, if any.
Definition Fl_Terminal.cxx:2067
Fl_Terminal::OutFlags
OutFlags
Output translation flags for special control character translations.
Definition Fl_Terminal.H:378
Fl_Terminal::LF_TO_CR
@ LF_TO_CR
line-feed generates a carriage return (\n -> \r)
Definition Fl_Terminal.H:381
Fl_Terminal::CR_TO_LF
@ CR_TO_LF
carriage return generates a vertical line-feed (\r -> \n)
Definition Fl_Terminal.H:380
Fl_Terminal::OFF
@ OFF
no output translation
Definition Fl_Terminal.H:379
Fl_Terminal::LF_TO_CRLF
@ LF_TO_CRLF
line-feed generates a carriage return line-feed (\n -> \r\n)
Definition Fl_Terminal.H:382
Fl_Terminal::ring_erow
int ring_erow(void) const
Return the ending row# in the ring buffer (Always ring_rows()-1).
Definition Fl_Terminal.H:1061
Fl_Terminal::box
Fl_Boxtype box(void) const
Returns the current box type.
Definition Fl_Terminal.H:1115
Fl_Terminal::box
void box(Fl_Boxtype val)
Sets the box type, updates terminal margins et al.
Definition Fl_Terminal.H:1113
Fl_Terminal::cursor_col
void cursor_col(int col)
Move cursor to the specified column col.
Definition Fl_Terminal.cxx:2445
Fl_Terminal::cursor_up
void cursor_up(int count=1, bool do_scroll=false)
Moves cursor up count lines.
Definition Fl_Terminal.cxx:2456
Fl_Terminal::selectionfgcolor
void selectionfgcolor(Fl_Color val)
Set mouse selection foreground color.
Definition Fl_Terminal.H:1157
Fl_Terminal::select_line
void select_line(int grow)
Select the entire row.
Definition Fl_Terminal.cxx:2214
Fl_Terminal::cursor_down
void cursor_down(int count=1, bool do_scroll=false)
Moves cursor down count lines.
Definition Fl_Terminal.cxx:2472
Fl_Terminal::u8c_hist_row
const Utf8Char * u8c_hist_row(int hrow) const
See docs for non-const version of u8c_hist_row(int).
Definition Fl_Terminal.cxx:1058
Fl_Terminal::clear_sod
void clear_sod(void)
Clear from cursor to Start Of Display (EOD), like "<ESC>[1J".
Definition Fl_Terminal.cxx:1935
Fl_Terminal::textcolor
Fl_Color textcolor(void) const
Return textcolor(). This is a convenience method that returns textfgcolor_default().
Definition Fl_Terminal.H:1145
Fl_Terminal::clear_screen
void clear_screen(bool scroll_to_hist=true)
Clear the terminal screen only; does not affect the cursor position.
Definition Fl_Terminal.cxx:1907
Fl_Terminal::cursor_row
void cursor_row(int row)
Move cursor to the specified row row.
Definition Fl_Terminal.cxx:2441
Fl_Terminal::insert_char_eol
void insert_char_eol(char c, int drow, int dcol, int rep)
Insert char 'c' for 'rep' times at display row 'drow' and column 'dcol'.
Definition Fl_Terminal.cxx:2283
Fl_Terminal::handle_unknown_char
int handle_unknown_char(void)
Handle an unknown char by either emitting an error symbol to the tty, or do nothing,...
Definition Fl_Terminal.cxx:3294
Fl_Terminal::hist_erow
int hist_erow(void) const
Return the ending row# of the scrollback history.
Definition Fl_Terminal.H:1069
Fl_Terminal::append_utf8
void append_utf8(const char *buf, int len=-1)
Append NULL terminated UTF-8 string to terminal.
Definition Fl_Terminal.cxx:3154
Fl_Terminal::clear_sol
void clear_sol(void)
Clear from cursor to Start Of Line (SOL), like "<ESC>[1K".
Definition Fl_Terminal.cxx:1967
Fl_Terminal::append_ascii
void append_ascii(const char *s)
Append NULL terminated ASCII string to terminal, slightly more efficient than append_utf8().
Definition Fl_Terminal.cxx:3210
Fl_Terminal::delete_rows
void delete_rows(int count)
Delete (count) rows at cursor position.
Definition Fl_Terminal.cxx:2258
Fl_Widget::color
Fl_Color color() const
Gets the background color of the widget.
Definition Fl_Widget.H:455
Fl_Widget::h
int h() const
Gets the widget height.
Definition Fl_Widget.H:376
Fl_Widget::box
Fl_Boxtype box() const
Gets the box type of the widget.
Definition Fl_Widget.H:440
FL_OVERRIDE
#define FL_OVERRIDE
This macro makes it safe to use the C++11 keyword override with older compilers.
Definition fl_attr.h:46
uchar
unsigned char uchar
unsigned char
Definition fl_types.h:30
fl_utf8len
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