mirror of
https://github.com/fltk/fltk.git
synced 2026-06-04 23:42:15 +08:00
Fix drawing of tab characters when display is rescaled.
The problem is announced in comment #99 of http://www.fltk.org/str.php?L3320 git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12544 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
+12
-10
@@ -454,6 +454,7 @@ void Fl_Text_Display::resize(int X, int Y, int W, int H) {
|
|||||||
#endif // DEBUG2
|
#endif // DEBUG2
|
||||||
|
|
||||||
Fl_Widget::resize(X,Y,W,H);
|
Fl_Widget::resize(X,Y,W,H);
|
||||||
|
mColumnScale = 0; // force recomputation of the width of a column when display is rescaled
|
||||||
recalc_display();
|
recalc_display();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1954,8 +1955,9 @@ int Fl_Text_Display::handle_vline(
|
|||||||
|
|
||||||
// FIXME: we need to allow two modes for FIND_INDEX: one on the edge of the
|
// FIXME: we need to allow two modes for FIND_INDEX: one on the edge of the
|
||||||
// FIXME: character for selection, and one on the character center for cursors.
|
// FIXME: character for selection, and one on the character center for cursors.
|
||||||
int i, X, startX, startIndex, style, charStyle;
|
int i, X, startIndex, style, charStyle;
|
||||||
char *lineStr;
|
char *lineStr;
|
||||||
|
double startX;
|
||||||
|
|
||||||
if ( lineStartPos == -1 ) {
|
if ( lineStartPos == -1 ) {
|
||||||
lineStr = NULL;
|
lineStr = NULL;
|
||||||
@@ -2004,12 +2006,12 @@ int Fl_Text_Display::handle_vline(
|
|||||||
charStyle = position_style(lineStartPos, lineLen, i);
|
charStyle = position_style(lineStartPos, lineLen, i);
|
||||||
if (charStyle!=style || currChar=='\t' || prevChar=='\t') {
|
if (charStyle!=style || currChar=='\t' || prevChar=='\t') {
|
||||||
// draw a segment whenever the style changes or a Tab is found
|
// draw a segment whenever the style changes or a Tab is found
|
||||||
int w = 0;
|
double w = 0;
|
||||||
if (prevChar=='\t') {
|
if (prevChar=='\t') {
|
||||||
// draw a single Tab space
|
// draw a single Tab space
|
||||||
int tab = (int)col_to_x(mBuffer->tab_distance());
|
double tab = col_to_x(mBuffer->tab_distance());
|
||||||
int xAbs = (mode==GET_WIDTH) ? startX : startX+mHorizOffset-text_area.x;
|
double xAbs = (mode==GET_WIDTH) ? startX : startX+mHorizOffset-text_area.x;
|
||||||
w = (((xAbs/tab)+1)*tab) - xAbs;
|
w = ((int(xAbs/tab)+1)*tab) - xAbs;
|
||||||
if (mode==DRAW_LINE)
|
if (mode==DRAW_LINE)
|
||||||
draw_string( style|BG_ONLY_MASK, startX, Y, startX+w, 0, 0 );
|
draw_string( style|BG_ONLY_MASK, startX, Y, startX+w, 0, 0 );
|
||||||
if (mode==FIND_INDEX && startX+w>rightClip) {
|
if (mode==FIND_INDEX && startX+w>rightClip) {
|
||||||
@@ -2021,7 +2023,7 @@ int Fl_Text_Display::handle_vline(
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// draw a text segment
|
// draw a text segment
|
||||||
w = int( string_width( lineStr+startIndex, i-startIndex, style ) );
|
w = string_width( lineStr+startIndex, i-startIndex, style );
|
||||||
if (mode==DRAW_LINE)
|
if (mode==DRAW_LINE)
|
||||||
draw_string( style, startX, Y, startX+w, lineStr+startIndex, i-startIndex );
|
draw_string( style, startX, Y, startX+w, lineStr+startIndex, i-startIndex );
|
||||||
if (mode==FIND_INDEX && startX+w>rightClip) {
|
if (mode==FIND_INDEX && startX+w>rightClip) {
|
||||||
@@ -2042,9 +2044,9 @@ int Fl_Text_Display::handle_vline(
|
|||||||
int w = 0;
|
int w = 0;
|
||||||
if (currChar=='\t') {
|
if (currChar=='\t') {
|
||||||
// draw a single Tab space
|
// draw a single Tab space
|
||||||
int tab = (int)col_to_x(mBuffer->tab_distance());
|
double tab = col_to_x(mBuffer->tab_distance());
|
||||||
int xAbs = (mode==GET_WIDTH) ? startX : startX+mHorizOffset-text_area.x;
|
double xAbs = (mode==GET_WIDTH) ? startX : startX+mHorizOffset-text_area.x;
|
||||||
w = (((xAbs/tab)+1)*tab) - xAbs;
|
w = ((int(xAbs/tab)+1)*tab) - xAbs;
|
||||||
if (mode==DRAW_LINE)
|
if (mode==DRAW_LINE)
|
||||||
draw_string( style|BG_ONLY_MASK, startX, Y, startX+w, 0, 0 );
|
draw_string( style|BG_ONLY_MASK, startX, Y, startX+w, 0, 0 );
|
||||||
if (mode==FIND_INDEX) {
|
if (mode==FIND_INDEX) {
|
||||||
@@ -2055,7 +2057,7 @@ int Fl_Text_Display::handle_vline(
|
|||||||
return lineStartPos + startIndex + ( rightClip-startX>w ? 1 : 0 );
|
return lineStartPos + startIndex + ( rightClip-startX>w ? 1 : 0 );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
w = int( string_width( lineStr+startIndex, i-startIndex, style ) );
|
w = string_width( lineStr+startIndex, i-startIndex, style );
|
||||||
if (mode==DRAW_LINE)
|
if (mode==DRAW_LINE)
|
||||||
draw_string( style, startX, Y, startX+w, lineStr+startIndex, i-startIndex );
|
draw_string( style, startX, Y, startX+w, lineStr+startIndex, i-startIndex );
|
||||||
if (mode==FIND_INDEX) {
|
if (mode==FIND_INDEX) {
|
||||||
|
|||||||
Reference in New Issue
Block a user