diff options
| author | Matthias Melcher <github@matthiasm.com> | 2024-02-18 13:29:37 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-18 13:29:37 +0100 |
| commit | 2f343ad64dfc6a006660198f5757214114f38d7a (patch) | |
| tree | 6e581e057eff7db1e4cd800c7574ca491e9fedf7 /FL/Fl_Terminal.H | |
| parent | eb4916344b7cd92ac1a4aa862976808c96dbfcde (diff) | |
Fix Terminal character position and add word selection (#906)
* Improve horizontal interactive selection
* Using half-character positions to implement selection
similar to Fl_Input.
* Add word and line selection
* Fix vertical position of text
Diffstat (limited to 'FL/Fl_Terminal.H')
| -rw-r--r-- | FL/Fl_Terminal.H | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/FL/Fl_Terminal.H b/FL/Fl_Terminal.H index 1a63fdaa7..46d9403ba 100644 --- a/FL/Fl_Terminal.H +++ b/FL/Fl_Terminal.H @@ -669,30 +669,34 @@ private: // Class to manage mouse selection // class FL_EXPORT Selection { + Fl_Terminal *terminal_; int srow_, scol_, erow_, ecol_; // selection start/end. NOTE: start *might* be > end int push_row_, push_col_; // global row/col for last FL_PUSH + bool push_char_right_; Fl_Color selectionbgcolor_; Fl_Color selectionfgcolor_; int state_ ; // 0=none, 1=started, 2=extended, 3=done bool is_selection_; // false: no selection public: - Selection(void); + Selection(Fl_Terminal *terminal); int srow(void) const { return srow_; } int scol(void) const { return scol_; } int erow(void) const { return erow_; } int ecol(void) const { return ecol_; } - void push_clear() { push_row_ = push_col_ = -1; } - void push_rowcol(int row,int col) { push_row_ = row; push_col_ = col; } - void start_push() { start(push_row_, push_col_); } - bool dragged_off(int row,int col) { return (push_row_ != row) || (push_col_ != col); } + void push_clear() { push_row_ = push_col_ = -1; push_char_right_ = false; } + void push_rowcol(int row,int col,bool char_right) { + push_row_ = row; push_col_ = col; push_char_right_ = char_right; } + void start_push() { start(push_row_, push_col_, push_char_right_); } + bool dragged_off(int row,int col,bool char_right) { + return (push_row_ != row) || (push_col_+push_char_right_ != col+char_right); } void selectionfgcolor(Fl_Color val) { selectionfgcolor_ = val; } void selectionbgcolor(Fl_Color val) { selectionbgcolor_ = val; } Fl_Color selectionfgcolor(void) const { return selectionfgcolor_; } Fl_Color selectionbgcolor(void) const { return selectionbgcolor_; } bool is_selection(void) const { return is_selection_; } bool get_selection(int &srow,int &scol,int &erow,int &ecol) const; // guarantees return (start < end) - bool start(int row, int col); - bool extend(int row, int col); + bool start(int row, int col, bool char_right); + bool extend(int row, int col, bool char_right); void end(void); void select(int srow, int scol, int erow, int ecol); bool clear(void); @@ -882,8 +886,8 @@ protected: CharStyle& current_style(void) const; void current_style(const CharStyle& sty); private: - int x_to_glob_col(int X, int grow, int &gcol) const; - int xy_to_glob_rowcol(int X, int Y, int &grow, int &gcol) const; + int x_to_glob_col(int X, int grow, int &gcol, bool &gcr) const; + int xy_to_glob_rowcol(int X, int Y, int &grow, int &gcol, bool &gcr) const; protected: int w_to_col(int W) const; int h_to_row(int H) const; @@ -906,6 +910,8 @@ protected: const char* selection_text(void) const; void clear_mouse_selection(void); bool selection_extend(int X,int Y); + void select_word(int grow, int gcol); + void select_line(int grow); void scroll(int rows); void insert_rows(int count); void delete_rows(int count); |
