mirror of
https://github.com/fltk/fltk.git
synced 2026-05-10 05:27:55 +08:00
Fix: Wrapped Multiline Input/Output scrolls horizontally at the edges (#1414)
This commit is contained in:
+5
-5
@@ -139,7 +139,7 @@ const char* Fl_Input_::expand(const char* p, char* buf) const {
|
||||
char* e = buf+(MAXBUF-4);
|
||||
const char* lastspace = p;
|
||||
char* lastspace_out = o;
|
||||
int width_to_lastspace = 0;
|
||||
double width_to_lastspace = 0;
|
||||
int word_count = 0;
|
||||
int word_wrap;
|
||||
// const char *pe = p + strlen(p);
|
||||
@@ -155,10 +155,10 @@ const char* Fl_Input_::expand(const char* p, char* buf) const {
|
||||
|
||||
} else while (o<e) {
|
||||
if (wrap() && (p >= value_+size_ || isspace(*p & 255))) {
|
||||
word_wrap = w() - Fl::box_dw(box()) - 5; // 5 px space for cursor (#1414)
|
||||
width_to_lastspace += (int)fl_width(lastspace_out, (int) (o-lastspace_out));
|
||||
word_wrap = w() - Fl::box_dw(box()) - 4;
|
||||
width_to_lastspace += fl_width(lastspace_out, (int) (o-lastspace_out));
|
||||
if (p > lastspace+1) {
|
||||
if (word_count && width_to_lastspace > word_wrap) {
|
||||
if (word_count && (int)width_to_lastspace > word_wrap) {
|
||||
p = lastspace; o = lastspace_out; break;
|
||||
}
|
||||
word_count++;
|
||||
@@ -362,7 +362,7 @@ void Fl_Input_::drawtext(int X, int Y, int W, int H, bool draw_active) {
|
||||
} else if (curx < newscroll+threshold) {
|
||||
newscroll = curx-threshold;
|
||||
}
|
||||
if (newscroll < 0) newscroll = 0;
|
||||
if (newscroll < 0 || ((type() & FL_MULTILINE_INPUT) && (type() & FL_INPUT_WRAP))) newscroll = 0;
|
||||
if (newscroll != xscroll_) {
|
||||
xscroll_ = newscroll;
|
||||
mu_p = 0; erase_cursor_only = 0;
|
||||
|
||||
Reference in New Issue
Block a user