From a3e9b9fcf48df51d55fb1e5c2c696d73dc72c151 Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Wed, 19 Dec 2001 07:42:43 +0000 Subject: Wrapping supported. --- gtk/ScintillaGTK.cxx | 3 +- include/Scintilla.h | 4 +++ include/Scintilla.iface | 9 +++++ src/ContractionState.cxx | 90 ++++++++++++++++++++++++++++++++++++++++-------- 4 files changed, 89 insertions(+), 17 deletions(-) diff --git a/gtk/ScintillaGTK.cxx b/gtk/ScintillaGTK.cxx index cfaa70971..2967d9015 100644 --- a/gtk/ScintillaGTK.cxx +++ b/gtk/ScintillaGTK.cxx @@ -1020,7 +1020,6 @@ void ScintillaGTK::UnclaimSelection(GdkEventSelection *selection_event) { void ScintillaGTK::Resize(int width, int height) { //Platform::DebugPrintf("Resize %d %d\n", width, height); //printf("Resize %d %d\n", width, height); - DropGraphics(); // Not always needed, but some themes can have different sizes of scrollbars scrollBarWidth = GTK_WIDGET(PWidget(scrollbarv))->requisition.width; @@ -1051,7 +1050,7 @@ void ScintillaGTK::Resize(int width, int height) { alloc.height = Platform::Maximum(1, height - scrollBarHeight) + 1; gtk_widget_size_allocate(GTK_WIDGET(PWidget(scrollbarv)), &alloc); - SetScrollBars(); + ChangeSize(); } gint ScintillaGTK::PressThis(GdkEventButton *event) { diff --git a/include/Scintilla.h b/include/Scintilla.h index fb099f9ec..20c5f267a 100644 --- a/include/Scintilla.h +++ b/include/Scintilla.h @@ -344,6 +344,10 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_GETMOUSEDWELLTIME 2265 #define SCI_WORDSTARTPOSITION 2266 #define SCI_WORDENDPOSITION 2267 +#define SC_WRAP_NONE 0 +#define SC_WRAP_WORD 1 +#define SCI_SETWRAPMODE 2268 +#define SCI_GETWRAPMODE 2269 #define SCI_LINEDOWN 2300 #define SCI_LINEDOWNEXTEND 2301 #define SCI_LINEUP 2302 diff --git a/include/Scintilla.iface b/include/Scintilla.iface index 8e759c693..9e30673d7 100644 --- a/include/Scintilla.iface +++ b/include/Scintilla.iface @@ -896,6 +896,15 @@ fun int WordStartPosition=2266(position pos,) # Get position of end of word fun int WordEndPosition=2267(position pos,) +val SC_WRAP_NONE=0 +val SC_WRAP_WORD=1 + +# Sets whether text is word wrapped +set void SetWrapMode=2268(int mode,) + +# Retrieve whether text is word wrapped +get int GetWrapMode=2269(,) + ## Start of key messages # Move caret down one line. fun void LineDown=2300(,) diff --git a/src/ContractionState.cxx b/src/ContractionState.cxx index 1f1469665..362dc1ed8 100644 --- a/src/ContractionState.cxx +++ b/src/ContractionState.cxx @@ -11,8 +11,9 @@ OneLine::OneLine() { displayLine = 0; - docLine = 0; + //docLine = 0; visible = true; + height = 1; expanded = true; } @@ -22,6 +23,8 @@ ContractionState::ContractionState() { linesInDoc = 1; linesInDisplay = 1; valid = false; + docLines = 0; + sizeDocLines = 0; } ContractionState::~ContractionState() { @@ -30,14 +33,32 @@ ContractionState::~ContractionState() { void ContractionState::MakeValid() const { if (!valid) { - // Could be cleverer by keeping the index of the last still valid entry + // Could be cleverer by keeping the index of the last still valid entry // rather than invalidating all. - int lineDisplay = 0; + linesInDisplay = 0; + for (int lineInDoc=0; lineInDoc= lineDoc + lineCount; i--) { lines[i].visible = lines[i - lineCount].visible; + lines[i].height = lines[i - lineCount].height; + linesInDisplay += lines[i].height; lines[i].expanded = lines[i - lineCount].expanded; } for (int d=0;d lineDocEnd) - return false; + if (lineDocStart == 0) + lineDocStart++; + if (lineDocStart > lineDocEnd) + return false; if (size == 0) { Grow(linesInDoc + growSize); } @@ -170,7 +203,7 @@ bool ContractionState::SetVisible(int lineDocStart, int lineDocEnd, bool visible if ((lineDocStart <= lineDocEnd) && (lineDocStart >= 0) && (lineDocEnd < linesInDoc)) { for (int line=lineDocStart; line <= lineDocEnd; line++) { if (lines[line].visible != visible) { - delta += visible ? 1 : -1; + delta += visible ? lines[line].height : -lines[line].height; lines[line].visible = visible; } } @@ -181,7 +214,7 @@ bool ContractionState::SetVisible(int lineDocStart, int lineDocEnd, bool visible } bool ContractionState::GetExpanded(int lineDoc) const { - if (size == 0) + if (size == 0) return true; if ((lineDoc >= 0) && (lineDoc < linesInDoc)) { return lines[lineDoc].expanded; @@ -203,6 +236,33 @@ bool ContractionState::SetExpanded(int lineDoc, bool expanded) { return false; } +int ContractionState::GetHeight(int lineDoc) const { + if (size == 0) + return 1; + if ((lineDoc >= 0) && (lineDoc < linesInDoc)) { + return lines[lineDoc].height; + } else { + return 1; + } +} + +// Set the number of display lines needed for this line. +// Return true if this is a change. +bool ContractionState::SetHeight(int lineDoc, int height) { + if (lineDoc > linesInDoc) + return false; + if (size == 0) { + Grow(linesInDoc + growSize); + } + if (lines[lineDoc].height != height) { + lines[lineDoc].height = height; + valid = false; + return true; + } else { + return false; + } +} + void ContractionState::ShowAll() { delete []lines; lines = 0; -- cgit v1.2.3