From 6eee037fe180acd217d783aebb1e0aafda3b64b2 Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Thu, 10 Feb 2005 12:46:17 +0000 Subject: Patch from Suzumizaki-Kimitaka to add character wrap mode. --- doc/ScintillaDoc.html | 13 ++++++++++--- include/Scintilla.h | 1 + include/Scintilla.iface | 24 ++++++++++++++++++++++++ src/Editor.cxx | 19 +++++++++++++++++-- src/Editor.h | 2 +- 5 files changed, 53 insertions(+), 6 deletions(-) diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html index 51c40b36a..495d93dff 100644 --- a/doc/ScintillaDoc.html +++ b/doc/ScintillaDoc.html @@ -3582,11 +3582,15 @@ struct RangeToFormat {

SCI_SETPRINTWRAPMODE(int wrapMode)
SCI_GETPRINTWRAPMODE
These two functions get and set the printer wrap mode. wrapMode can be - set to SC_WRAP_NONE (0) or SC_WRAP_WORD (1). The default is + set to SC_WRAP_NONE (0), SC_WRAP_WORD (1) or + SC_WRAP_CHAR (2). The default is SC_WRAP_WORD, which wraps printed output so that all characters fit into the print rectangle. If you set SC_WRAP_NONE, each line of text generates one line of output and the line is truncated if it is too long to fit - into the print area.

+ into the print area.
It is important that SC_WRAP_WORD is + not only for low spec computers but for some languages/situations. This makes + wrapping after any characters but it is OK. Some language don't have whitespaces + between words.

Direct access

SCI_GETDIRECTFUNCTION
@@ -3928,7 +3932,10 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){

SCI_SETWRAPMODE(int wrapMode)
SCI_GETWRAPMODE
Set wrapMode to SC_WRAP_WORD (1) to enable line wrapping and to - SC_WRAP_NONE (0) to disable line wrapping.

+ SC_WRAP_NONE (0) to disable line wrapping. And to + SC_WRAP_CHAR (2), it is highly recommended to implement for i18n + product, enables character wrapping mode.

+

SCI_SETWRAPVISUALFLAGS(int wrapVisualFlags)
SCI_GETWRAPVISUALFLAGS
diff --git a/include/Scintilla.h b/include/Scintilla.h index f20f0de22..d263d5026 100644 --- a/include/Scintilla.h +++ b/include/Scintilla.h @@ -386,6 +386,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_WORDENDPOSITION 2267 #define SC_WRAP_NONE 0 #define SC_WRAP_WORD 1 +#define SC_WRAP_CHAR 2 #define SCI_SETWRAPMODE 2268 #define SCI_GETWRAPMODE 2269 #define SC_WRAPVISUALFLAG_NONE 0x0000 diff --git a/include/Scintilla.iface b/include/Scintilla.iface index de1377847..eaebaaeca 100644 --- a/include/Scintilla.iface +++ b/include/Scintilla.iface @@ -994,6 +994,7 @@ fun int WordEndPosition=2267(position pos, bool onlyWordCharacters) enu Wrap=SC_WRAP_ val SC_WRAP_NONE=0 val SC_WRAP_WORD=1 +val SC_WRAP_CHAR=2 # Sets whether text is word wrapped. set void SetWrapMode=2268(int mode,) @@ -1751,6 +1752,9 @@ val SCLEX_APDL=61 val SCLEX_BASH=62 val SCLEX_ASN1=63 val SCLEX_VHDL=64 +val SCLEX_CAML=65 +val SCLEX_BLITZBASIC=66 +val SCLEX_PUREBASIC=67 # When a lexer specifies its language as SCLEX_AUTOMATIC it receives a # value assigned in sequence from SCLEX_AUTOMATIC+1. @@ -1977,6 +1981,10 @@ val SCE_B_KEYWORD3=11 val SCE_B_KEYWORD4=12 val SCE_B_CONSTANT=13 val SCE_B_ASM=14 +val SCE_B_LABEL=15 +val SCE_B_ERROR=16 +val SCE_B_HEXNUMBER=17 +val SCE_B_BINNUMBER=18 # Lexical states for SCLEX_PROPERTIES lex Properties=SCLEX_PROPERTIES SCE_PROPS_ val SCE_PROPS_DEFAULT=0 @@ -2579,6 +2587,22 @@ val SCE_VHDL_STDFUNCTION=11 val SCE_VHDL_STDPACKAGE=12 val SCE_VHDL_STDTYPE=13 val SCE_VHDL_USERWORD=14 +# Lexical states for SCLEX_CAML +lex Caml=SCLEX_CAML SCE_CAML_ +val SCE_CAML_DEFAULT=0 +val SCE_CAML_IDENTIFIER=1 +val SCE_CAML_TAGNAME=2 +val SCE_CAML_KEYWORD=3 +val SCE_CAML_KEYWORD2=4 +val SCE_CAML_LINENUM=5 +val SCE_CAML_OPERATOR=6 +val SCE_CAML_NUMBER=7 +val SCE_CAML_CHAR=8 +val SCE_CAML_STRING=9 +val SCE_CAML_COMMENT=10 +val SCE_CAML_COMMENT1=11 +val SCE_CAML_COMMENT2=12 +val SCE_CAML_COMMENT3=13 # Events diff --git a/src/Editor.cxx b/src/Editor.cxx index 59bc76e9d..e049485f2 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -2063,7 +2063,12 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou continue; } if (p > 0) { - if (ll->styles[p] != ll->styles[p - 1]) { + if (wrapState == eWrapChar){ + lastGoodBreak = pdoc->MovePositionOutsideChar(p + posLineStart, -1) + - posLineStart; + p = pdoc->MovePositionOutsideChar(p + 1 + posLineStart, 1) - posLineStart; + continue; + } else if (ll->styles[p] != ll->styles[p - 1]) { lastGoodBreak = p; } else if (IsSpaceOrTab(ll->chars[p - 1]) && !IsSpaceOrTab(ll->chars[p])) { lastGoodBreak = p; @@ -6231,7 +6236,17 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return pdoc->ExtendWordSelect(wParam, 1, lParam != 0); case SCI_SETWRAPMODE: - wrapState = (wParam == SC_WRAP_WORD) ? eWrapWord : eWrapNone; + switch(wParam){ + case SC_WRAP_WORD: + wrapState = eWrapWord; + break; + case SC_WRAP_CHAR: + wrapState = eWrapChar; + break; + default: + wrapState = eWrapNone; + break; + } xOffset = 0; InvalidateStyleRedraw(); ReconfigureScrollBars(); diff --git a/src/Editor.h b/src/Editor.h index e14cb5ed9..bace500bd 100644 --- a/src/Editor.h +++ b/src/Editor.h @@ -301,7 +301,7 @@ protected: // ScintillaBase subclass needs access to much of Editor int hsEnd; // Wrapping support - enum { eWrapNone, eWrapWord } wrapState; + enum { eWrapNone, eWrapWord, eWrapChar } wrapState; bool backgroundWrapEnabled; int wrapWidth; int docLineLastWrapped; -- cgit v1.2.3