aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--gtk/ScintillaGTK.cxx3
-rw-r--r--include/Scintilla.h4
-rw-r--r--include/Scintilla.iface9
-rw-r--r--src/ContractionState.cxx90
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<linesInDoc; lineInDoc++) {
+ lines[lineInDoc].displayLine = linesInDisplay;
+ if (lines[lineInDoc].visible) {
+ linesInDisplay += lines[lineInDoc].height;
+ }
+ }
+ if (sizeDocLines < linesInDisplay) {
+ delete []docLines;
+ docLines = new int[linesInDisplay + growSize];
+ if (docLines) {
+ sizeDocLines = linesInDisplay + growSize;
+ } else {
+ return;
+ }
+ }
+
+ int lineInDisplay=0;
for (int line=0; line<linesInDoc; line++) {
- lines[line].displayLine = lineDisplay;
if (lines[line].visible) {
- lines[lineDisplay].docLine = line;
- lineDisplay++;
+ for (int linePiece=0; linePiece<lines[line].height; linePiece++) {
+ docLines[lineInDisplay] = line;
+ lineInDisplay++;
+ }
}
}
valid = true;
@@ -50,6 +71,9 @@ void ContractionState::Clear() {
size = 0;
linesInDoc = 1;
linesInDisplay = 1;
+ delete []docLines;
+ docLines = 0;
+ sizeDocLines = 0;
}
int ContractionState::LinesInDoc() const {
@@ -57,6 +81,9 @@ int ContractionState::LinesInDoc() const {
}
int ContractionState::LinesDisplayed() const {
+ if (size != 0) {
+ MakeValid();
+ }
return linesInDisplay;
}
@@ -79,7 +106,11 @@ int ContractionState::DocFromDisplay(int lineDisplay) const {
if (size == 0)
return lineDisplay;
MakeValid();
- return lines[lineDisplay].docLine;
+ if (docLines) { // Valid allocation
+ return docLines[lineDisplay];
+ } else {
+ return 0;
+ }
}
void ContractionState::Grow(int sizeNew) {
@@ -113,13 +144,15 @@ void ContractionState::InsertLines(int lineDoc, int lineCount) {
Grow(linesInDoc + lineCount + growSize);
}
linesInDoc += lineCount;
- linesInDisplay += lineCount;
for (int i = linesInDoc; i >= 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<lineCount;d++) {
lines[lineDoc+d].visible = true; // Should inherit visibility from context ?
+ lines[lineDoc+d].height = 1;
lines[lineDoc+d].expanded = true;
}
valid = false;
@@ -134,7 +167,7 @@ void ContractionState::DeleteLines(int lineDoc, int lineCount) {
int deltaDisplayed = 0;
for (int d=0;d<lineCount;d++) {
if (lines[lineDoc+d].visible)
- deltaDisplayed--;
+ deltaDisplayed -= lines[lineDoc+d].height;
}
for (int i = lineDoc; i < linesInDoc-lineCount; i++) {
if (i != 0) // Line zero is always visible
@@ -157,10 +190,10 @@ bool ContractionState::GetVisible(int lineDoc) const {
}
bool ContractionState::SetVisible(int lineDocStart, int lineDocEnd, bool visible) {
- if (lineDocStart == 0)
- lineDocStart++;
- if (lineDocStart > 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;