diff options
| author | Matthias Melcher <git@matthiasm.com> | 2021-12-08 18:55:34 +0100 |
|---|---|---|
| committer | Matthias Melcher <git@matthiasm.com> | 2021-12-08 18:55:44 +0100 |
| commit | 17c8f73a88037fbe5efde00ff7d44a2f6f51e494 (patch) | |
| tree | cda28ef9b4a9c49fffdc179cbc37f81de6eebae8 /src/Fl_Text_Display.cxx | |
| parent | 16dae3ea063ae134b8b87ca199575e904dfbb7d4 (diff) | |
STR 3460.C: Code Properties remembers the editor's scroll bar position.
Diffstat (limited to 'src/Fl_Text_Display.cxx')
| -rw-r--r-- | src/Fl_Text_Display.cxx | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/Fl_Text_Display.cxx b/src/Fl_Text_Display.cxx index a9cfcdfaf..731d7a94e 100644 --- a/src/Fl_Text_Display.cxx +++ b/src/Fl_Text_Display.cxx @@ -4146,18 +4146,25 @@ int Fl_Text_Display::handle(int event) { /* Convert an x pixel position into a column number. + The width of a column is calculated as the average width of a few + representative characters, giving a good estimate for proportional fonts. + This method does not take the possition of the scroll bars into account. + \param[in] x offset to the left edge of the text in FLTK units. + \return approximation to the corresponding text column + \see col_to_x() */ -double Fl_Text_Display::x_to_col(double y) const +double Fl_Text_Display::x_to_col(double x) const { if (!mColumnScale) { mColumnScale = string_width("Mitg", 4, 'A') / 4.0; } - return (y/mColumnScale)+0.5; + return (x/mColumnScale)+0.5; } /** Convert a column number into an x pixel position. + \see x_to_col() */ double Fl_Text_Display::col_to_x(double col) const { |
