diff options
| -rw-r--r-- | gtk/ScintillaGTK.cxx | 13 | ||||
| -rw-r--r-- | include/Scintilla.h | 2 | ||||
| -rw-r--r-- | include/Scintilla.iface | 26 | ||||
| -rw-r--r-- | src/Editor.cxx | 11 | ||||
| -rw-r--r-- | src/Editor.h | 1 | ||||
| -rw-r--r-- | win32/ScintillaWin.cxx | 38 | 
6 files changed, 67 insertions, 24 deletions
diff --git a/gtk/ScintillaGTK.cxx b/gtk/ScintillaGTK.cxx index 95139f318..386a0bff4 100644 --- a/gtk/ScintillaGTK.cxx +++ b/gtk/ScintillaGTK.cxx @@ -717,10 +717,15 @@ bool ScintillaGTK::ModifyScrollBars(int nMax, int nPage) {  		modified = true;  	} -	if (GTK_ADJUSTMENT(adjustmenth)->upper != 2000 || -	        GTK_ADJUSTMENT(adjustmenth)->page_size != 200) { -		GTK_ADJUSTMENT(adjustmenth)->upper = 2000; -		GTK_ADJUSTMENT(adjustmenth)->page_size = 200; +	PRectangle rcText = GetTextRectangle(); +	int horizEndPreferred = scrollWidth; +	if (horizEndPreferred < 0) +		horizEndPreferred = 0; +	unsigned int pageWidth = rcText.Width(); +	if (GTK_ADJUSTMENT(adjustmenth)->upper != horizEndPreferred || +	        GTK_ADJUSTMENT(adjustmenth)->page_size != pageWidth) { +		GTK_ADJUSTMENT(adjustmenth)->upper = horizEndPreferred; +		GTK_ADJUSTMENT(adjustmenth)->page_size = pageWidth;  		gtk_adjustment_changed(GTK_ADJUSTMENT(adjustmenth));  		modified = true;  	} diff --git a/include/Scintilla.h b/include/Scintilla.h index 99b3ee0b1..2f763de0f 100644 --- a/include/Scintilla.h +++ b/include/Scintilla.h @@ -359,6 +359,8 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,  #define SC_CACHE_DOCUMENT 3  #define SCI_SETLAYOUTCACHE 2272  #define SCI_GETLAYOUTCACHE 2273 +#define SCI_SETSCROLLWIDTH 2274 +#define SCI_GETSCROLLWIDTH 2275  #define SCI_LINEDOWN 2300  #define SCI_LINEDOWNEXTEND 2301  #define SCI_LINEUP 2302 diff --git a/include/Scintilla.iface b/include/Scintilla.iface index 4d1c94818..c49ca40e0 100644 --- a/include/Scintilla.iface +++ b/include/Scintilla.iface @@ -765,13 +765,13 @@ get int GetDirectFunction=2184(,)  # the function returned by GetDirectFunction.  get int GetDirectPointer=2185(,) -# Set to overtype (true) or insert mode +# Set to overtype (true) or insert mode.  set void SetOvertype=2186(bool overtype,)  # Returns true if overtype mode is active otherwise false is returned.  get bool GetOvertype=2187(,) -# Set the width of the insert mode caret +# Set the width of the insert mode caret.  set void SetCaretWidth=2188(int pixelWidth,)  # Returns the width of the insert mode caret @@ -900,25 +900,25 @@ get bool GetBackSpaceUnIndents=2263(,)  val SC_TIME_FOREVER=10000000 -# Sets the time the mouse must sit still to generate a mouse dwell event +# Sets the time the mouse must sit still to generate a mouse dwell event.  set void SetMouseDwellTime=2264(int periodMilliseconds,) -# Retrieve the time the mouse must sit still to generate a mouse dwell event +# Retrieve the time the mouse must sit still to generate a mouse dwell event.  get int GetMouseDwellTime=2265(,) -# Get position of start of word +# Get position of start of word.  fun int WordStartPosition=2266(position pos, bool onlyWordCharacters) -# Get position of end of word +# Get position of end of word.  fun int WordEndPosition=2267(position pos, bool onlyWordCharacters)  val SC_WRAP_NONE=0  val SC_WRAP_WORD=1 -# Sets whether text is word wrapped +# Sets whether text is word wrapped.  set void SetWrapMode=2268(int mode,) -# Retrieve whether text is word wrapped +# Retrieve whether text is word wrapped.  get int GetWrapMode=2269(,)  val SC_CACHE_NONE=0 @@ -926,12 +926,18 @@ val SC_CACHE_CARET=1  val SC_CACHE_PAGE=2  val SC_CACHE_DOCUMENT=3 -# Sets the degree of caching of layout information +# Sets the degree of caching of layout information.  set void SetLayoutCache=2272(int mode,) -# Retrieve the degree of caching of layout information +# Retrieve the degree of caching of layout information.  get int GetLayoutCache=2273(,) +# Sets the document width assumed for scrolling. +set void SetScrollWidth=2274(int pixelWidth,) + +# Retrieve the document width assumed for scrolling. +get int GetScrollWidth=2275(,) +  ## Start of key messages  # Move caret down one line.  fun void LineDown=2300(,) diff --git a/src/Editor.cxx b/src/Editor.cxx index 57856dc37..4e430b0d7 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -326,6 +326,7 @@ Editor::Editor() {  	xOffset = 0;  	xCaretMargin = 50;  	horizontalScrollBarVisible = true; +	scrollWidth = 2000;  	pixmapLine = Surface::Allocate();  	pixmapSelMargin = Surface::Allocate(); @@ -4668,6 +4669,16 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {  	case SCI_GETLAYOUTCACHE:  		return llc.GetLevel(); +	case SCI_SETSCROLLWIDTH: +		PLATFORM_ASSERT(wParam > 0); +		if (wParam > 0) +			scrollWidth = wParam; +		SetScrollBars(); +		break; + +	case SCI_GETSCROLLWIDTH: +		return scrollWidth; +  	case SCI_GETCOLUMN:  		return pdoc->GetColumn(wParam); diff --git a/src/Editor.h b/src/Editor.h index d784f478e..ba35c83c3 100644 --- a/src/Editor.h +++ b/src/Editor.h @@ -200,6 +200,7 @@ protected:	// ScintillaBase subclass needs access to much of Editor  	int xOffset;		///< Horizontal scrolled amount in pixels  	int xCaretMargin;	///< Ensure this many pixels visible on both sides of caret  	bool horizontalScrollBarVisible; +	int scrollWidth;  	Surface *pixmapLine;  	Surface *pixmapSelMargin; diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx index b5db2a3ae..553077b0e 100644 --- a/win32/ScintillaWin.cxx +++ b/win32/ScintillaWin.cxx @@ -898,7 +898,7 @@ bool ScintillaWin::ModifyScrollBars(int nMax, int nPage) {  	sci.fMask = SIF_PAGE | SIF_RANGE;  	::GetScrollInfo(MainHWND(), SB_VERT, &sci);  	if ((sci.nMin != 0) ||  -			(sci.nMax != nMax) || +		(sci.nMax != nMax) ||  	        (sci.nPage != static_cast<unsigned int>(nPage)) ||  	        (sci.nPos != 0)) {  		//Platform::DebugPrintf("Scroll info changed %d %d %d %d %d\n", @@ -912,16 +912,31 @@ bool ScintillaWin::ModifyScrollBars(int nMax, int nPage) {  		::SetScrollInfo(MainHWND(), SB_VERT, &sci, TRUE);  		modified = true;  	} -	int horizStart = 0; -	int horizEnd = 2000; -	int horizEndPreferred = 2000; + +	PRectangle rcText = GetTextRectangle(); +	int horizEndPreferred = scrollWidth; +	if (horizEndPreferred < 0) +		horizEndPreferred = 0;  	if (!horizontalScrollBarVisible || (wrapState != eWrapNone))  		horizEndPreferred = 0; -	if (!::GetScrollRange(MainHWND(), SB_HORZ, &horizStart, &horizEnd) || -	        horizStart != 0 || horizEnd != horizEndPreferred) { -		::SetScrollRange(MainHWND(), SB_HORZ, 0, horizEndPreferred, TRUE); -		//Platform::DebugPrintf("Horiz Scroll info changed\n"); +	unsigned int pageWidth = rcText.Width(); +	sci.fMask = SIF_PAGE | SIF_RANGE; +	::GetScrollInfo(MainHWND(), SB_HORZ, &sci); +	if ((sci.nMin != 0) ||  +		(sci.nMax != horizEndPreferred) || +		(sci.nPage != pageWidth) || +	        (sci.nPos != 0)) { +		sci.fMask = SIF_PAGE | SIF_RANGE; +		sci.nMin = 0; +		sci.nMax = horizEndPreferred; +		sci.nPage = pageWidth; +		sci.nPos = 0; +		sci.nTrackPos = 1; +		::SetScrollInfo(MainHWND(), SB_HORZ, &sci, TRUE);  		modified = true; +		if (scrollWidth < static_cast<int>(pageWidth)) { +			HorizontalScrollTo(0); +		}  	}  	return modified;  } @@ -1528,7 +1543,7 @@ void ScintillaWin::HorizontalScrollMessage(WPARAM wParam) {  	case SB_LINEUP:  		xPos -= 20;  		break; -	case SB_LINEDOWN: +	case SB_LINEDOWN:	// May move past the logical end  		xPos += 20;  		break;  	case SB_PAGEUP: @@ -1536,12 +1551,15 @@ void ScintillaWin::HorizontalScrollMessage(WPARAM wParam) {  		break;  	case SB_PAGEDOWN:  		xPos += pageWidth; +		if (xPos > scrollWidth - rcText.Width()) {	// Hit the end exactly +			xPos = scrollWidth - rcText.Width(); +		}  		break;  	case SB_TOP:  		xPos = 0;  		break;  	case SB_BOTTOM: -		xPos = 2000; +		xPos = scrollWidth;  		break;  	case SB_THUMBPOSITION:  		xPos = HiWord(wParam);  | 
