diff options
| author | Albrecht Schlosser <fltk@aljus.de> | 2024-03-07 06:16:11 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-06 21:16:11 -0800 |
| commit | 3ac007541ebb6bfbc6217e210acf6527a2a91b6e (patch) | |
| tree | 2e4ef25a95a3cf93531d61217816afb20f7eee86 /FL/Fl_Terminal.H | |
| parent | 0f8649f3c4e4307518b451ec44ecfa5eff3074c0 (diff) | |
Add horizontal scrollbar to Terminal widget (#928)
* Checkpoint. Basic functionality seems to be working.
* Code cleanup
* Added horizontal scrollbar to Terminal widget
* Fix hscrollbar_size operation
* Applied erco-terminal-mods_v5_final.patch.txt
Final patch relating to PR 918
* Remove trailing whitespace, update copyright year
---------
Co-authored-by: Jonathan Griffitts <jonathan.griffitts@gmail.com>
Co-authored-by: Greg Ercolano <erco@seriss.com>
Co-authored-by: Albrecht Schlosser <albrechts.fltk@online.de>
Diffstat (limited to 'FL/Fl_Terminal.H')
| -rw-r--r-- | FL/Fl_Terminal.H | 52 |
1 files changed, 42 insertions, 10 deletions
diff --git a/FL/Fl_Terminal.H b/FL/Fl_Terminal.H index 196c40e06..ff1cb55c0 100644 --- a/FL/Fl_Terminal.H +++ b/FL/Fl_Terminal.H @@ -1,8 +1,8 @@ // -// Fl_Terminal.cxx - A terminal widget for Fast Light Tool Kit (FLTK). +// Fl_Terminal - A terminal widget for Fast Light Tool Kit (FLTK). // // Copyright 2022 by Greg Ercolano. -// Copyright 2023 by Bill Spitzak and others. +// Copyright 2024 by Bill Spitzak and others. // // This library is free software. Distribution and use rights are outlined in // the file "COPYING" which should have been included with this file. If this @@ -382,6 +382,16 @@ public: LF_TO_CRLF = 0x04 ///< line-feed generates a carriage return line-feed (\\n -> \\r\\n) }; + /** + \enum ScrollbarStyle + Behavior of scrollbars + */ + enum ScrollbarStyle { + SCROLLBAR_OFF = 0x00, ///< scrollbar always invisible + SCROLLBAR_AUTO = 0x01, ///< scrollbar visible if widget resized in a way that hides columns (default) + SCROLLBAR_ON = 0x02 ///< scrollbar always visible + }; + /////////////////////////////////////////////////////////////// ////// ////// Fl_Terminal Protected Classes @@ -817,15 +827,36 @@ private: /////////////////////////////////////////////////////////////// public: /** - Vertical scrollbar. Public, so that it can be accessed directly. + Vertical scrollbar. This is public so it can be accessed directly, e.g. + + - \ref Fl_Scrollbar::value(void) "scrollbar->value(void)" returns the row offset + from the bottom of the display, 0 being the bottom (default). + - \ref Fl_Scrollbar::value(int) "scrollbar->value(int)" similarly sets the row offset, + which should be in the range [0 .. Fl_Scrollbar::maximum()]. + - \ref Fl_Scrollbar::step(double) "scrollbar->step(double)" sets the smoothness + of scrolling, default is 0.25 for 4 steps of motion per column. + \todo Support scrollbar_left/right() - See Fl_Browser_::scrollbar docs + \todo Support new ScrollbarStyle */ - Fl_Scrollbar *scrollbar; // vertical scrollbar (value: rows above disp_chars[]) + Fl_Scrollbar *scrollbar; // vertical scrollbar (value: rows above disp_chars[]) + /** + Horizontal scrollbar. This is public so it can be accessed directly, e.g. + + - \ref Fl_Scrollbar::value(void) "hscrollbar->value(void)" returns the column offset + position from the left edge of the display; 0 being the left edge (default). + - \ref Fl_Scrollbar::value(int) "hscrollbar->value(int)" similarly sets the column offset, + which should be in the range [0 .. Fl_Scrollbar::maximum()]. + - \ref Fl_Scrollbar::step(double) "hscrollbar->step(double)" sets the smoothness + of scrolling, default is 0.25 for 4 steps of motion per column. + */ + Fl_Scrollbar *hscrollbar; // horizontal scrollbar private: - bool fontsize_defer_; // flag defers font calcs until first draw() (issue 837) - int scrollbar_size_; // local preference for scrollbar size - CharStyle *current_style_; // current font, attrib, color.. - OutFlags oflags_; // output translation flags (CR_TO_LF, LF_TO_CR, LF_TO_CRLF) + bool fontsize_defer_; // flag defers font calcs until first draw() (issue 837) + int scrollbar_size_; // local preference for scrollbar size + ScrollbarStyle hscrollbar_style_; + CharStyle *current_style_; // current font, attrib, color.. + OutFlags oflags_; // output translation flags (CR_TO_LF, LF_TO_CR, LF_TO_CRLF) // A ring buffer is used for the terminal's history (hist) and display (disp) buffer. // See README-Fl_Terminal.txt, section "RING BUFFER DESCRIPTION" for diagrams/info. @@ -866,8 +897,6 @@ protected: private: void create_ring(int drows, int dcols, int hrows); void init_(int X,int Y,int W,int H,const char*L,int rows,int cols,int hist,bool fontsize_defer); -protected: - int scrollbar_width(void) const; private: // Tabstops void init_tabstops(int newsize); @@ -878,6 +907,7 @@ private: // Updates void update_screen_xywh(void); void update_screen(bool font_changed); + void set_scrollbar_params(Fl_Scrollbar* scroll, int min, int max); void update_scrollbar(void); // Resize void resize_display_rows(int drows); @@ -1055,6 +1085,8 @@ public: int scrollbar_size(void) const; void scrollbar_size(int val); int scrollbar_actual_size(void) const; + void hscrollbar_style(ScrollbarStyle val); + ScrollbarStyle hscrollbar_style(void) const; // API: History int history_rows(void) const; void history_rows(int val); |
