diff --git a/FL/Fl_Text_Display.H b/FL/Fl_Text_Display.H index 22853bb46..fe84076a6 100644 --- a/FL/Fl_Text_Display.H +++ b/FL/Fl_Text_Display.H @@ -558,9 +558,8 @@ protected: int mNLinesDeleted; /* Number of lines deleted during buffer modification (only used when resynchronization is suppressed) */ - int mModifyingTabDistance; /* Whether tab distance is being - modified */ - + int mModifyingTabDistance; /* Whether tab distance is being modified XXX: UNUSED */ + mutable double mColumnScale; /* Width in pixels of an average character. This value is calculated as needed (lazy eval); it needs to be mutable so that it can be calculated diff --git a/src/Fl_Text_Display.cxx b/src/Fl_Text_Display.cxx index 36b381721..b70327898 100644 --- a/src/Fl_Text_Display.cxx +++ b/src/Fl_Text_Display.cxx @@ -97,82 +97,90 @@ static int scroll_x = 0; */ Fl_Text_Display::Fl_Text_Display(int X, int Y, int W, int H, const char* l) : Fl_Group(X, Y, W, H, l) { - int i; - mMaxsize = 0; + // Member initialization: same order as declared in .H file + // Any Fl_Text_Display methods should only be called /after/ all + // members initialized; avoids methods referencing uninitialized values. + // damage_range1_start = damage_range1_end = -1; damage_range2_start = damage_range2_end = -1; - dragPos = dragging = 0; - dragType = DRAG_CHAR; - display_insert_position_hint = 0; - shortcut_ = 0; + mCursorPos = 0; + mCursorOn = 0; + mCursorOldY = -100; + mCursorToHint = NO_HINT; + mCursorStyle = NORMAL_CURSOR; + mCursorPreferredXPos = -1; + mNVisibleLines = 1; + mNBufferLines = 0; + mBuffer = NULL; + mStyleBuffer = NULL; + mFirstChar = 0; + mLastChar = 0; + mContinuousWrap = 0; + mWrapMarginPix = 0; + mLineStarts = new int[mNVisibleLines]; + { // This code unused unless mNVisibleLines is ever initialized >1 + for (int i=1; icallback((Fl_Callback*)h_scrollbar_cb, this); + mHScrollBar->type(FL_HORIZONTAL); + + mVScrollBar = new Fl_Scrollbar(0,0,1,1); + mVScrollBar->callback((Fl_Callback*)v_scrollbar_cb, this); + + scrollbar_width_ = 0; // 0: default from Fl::scrollbar_size() + scrollbar_align_ = FL_ALIGN_BOTTOM_RIGHT; + + dragPos = 0; + dragType = DRAG_CHAR; + dragging = 0; + display_insert_position_hint = 0; text_area.x = 0; text_area.y = 0; text_area.w = 0; text_area.h = 0; - mVScrollBar = new Fl_Scrollbar(0,0,1,1); - mVScrollBar->callback((Fl_Callback*)v_scrollbar_cb, this); - mHScrollBar = new Fl_Scrollbar(0,0,1,1); - mHScrollBar->callback((Fl_Callback*)h_scrollbar_cb, this); - mHScrollBar->type(FL_HORIZONTAL); + shortcut_ = 0; + textfont_ = FL_HELVETICA; // textfont() + textsize_ = FL_NORMAL_SIZE; // textsize() + textcolor_ = FL_FOREGROUND_COLOR; // textcolor() + mLineNumLeft = 0; + mLineNumWidth = 0; - end(); - - scrollbar_width_ = 0; // 0: uses Fl::scrollbar_size() - scrollbar_align_ = FL_ALIGN_BOTTOM_RIGHT; - - mCursorOn = 0; - mCursorPos = 0; - mCursorOldY = -100; - mCursorToHint = NO_HINT; - mCursorStyle = NORMAL_CURSOR; - mCursorPreferredXPos = -1; - mBuffer = 0; - mFirstChar = 0; - mLastChar = 0; - mNBufferLines = 0; - mTopLineNum = mTopLineNumHint = 1; - mAbsTopLineNum = 1; - mNeedAbsTopLineNum = 0; - mHorizOffset = mHorizOffsetHint = 0; - - mCursor_color = FL_FOREGROUND_COLOR; - - mStyleBuffer = 0; - mStyleTable = 0; - mNStyles = 0; - mNVisibleLines = 1; - mLineStarts = new int[mNVisibleLines]; - mLineStarts[0] = 0; - for (i=1; i