From 5be8dfdbb520c0a6ca5e469a64f4691ca90872ff Mon Sep 17 00:00:00 2001 From: cxl Date: Fri, 4 Nov 2016 14:21:07 +0000 Subject: [PATCH] .Developing comment wordwrap git-svn-id: svn://ultimatepp.org/upp/trunk@10395 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/CodeEditor/CLogic.cpp | 27 +++++++++++++++++++++++ uppsrc/CodeEditor/CodeEditor.cpp | 1 - uppsrc/CodeEditor/Syntax.h | 4 ++-- uppsrc/CtrlLib/TextEdit.h | 1 + uppsrc/CtrlLib/src.tpp/LineEdit$en-us.tpp | 5 +++++ 5 files changed, 35 insertions(+), 3 deletions(-) diff --git a/uppsrc/CodeEditor/CLogic.cpp b/uppsrc/CodeEditor/CLogic.cpp index 679c92f25..80525c603 100644 --- a/uppsrc/CodeEditor/CLogic.cpp +++ b/uppsrc/CodeEditor/CLogic.cpp @@ -53,6 +53,33 @@ void CSyntax::IndentInsert(CodeEditor& e, int chr, int count) } return; } + +#ifdef _DEBUG + { + int limit = e.GetBorderColumn(); + int pos = e.GetCursor(); + int lp = pos; + int l = e.GetLinePos(lp); + if(limit > 10 && lp >= limit && lp == e.GetLineLength(l)) { + int lp0 = e.GetPos(l); + WString ln = e.GetWLine(l); + int wl = limit; + while(wl > 0 && ln[wl - 1] != '\n' && ln[wl - 1] != ' ') + wl--; + int sl = wl - 1; + while(sl > 0 && ln[wl - 1] != '\n' && ln[sl - 1] == ' ') + sl--; + e.Remove(lp0 + sl, pos - (lp0 + sl)); + e.SetCursor(lp0 + sl); + e.InsertChar('\n', 1); + for(int i = wl; i < ln.GetCount(); i++) + e.InsertChar(ln[i], 1); + e.InsertChar(chr, 1); + return; + } + } +#endif + // {, } inserted on line alone should be moved left sometimes: int cl = e.GetCursorLine(); WString l = e.GetWLine(cl); diff --git a/uppsrc/CodeEditor/CodeEditor.cpp b/uppsrc/CodeEditor/CodeEditor.cpp index 31d229c43..e5e21c79f 100644 --- a/uppsrc/CodeEditor/CodeEditor.cpp +++ b/uppsrc/CodeEditor/CodeEditor.cpp @@ -165,7 +165,6 @@ String CodeEditor::GetPasteText() return h; } - bool CodeEditor::IsCursorBracket(int pos) const { return pos == highlight_bracket_pos0 && hilite_bracket; diff --git a/uppsrc/CodeEditor/Syntax.h b/uppsrc/CodeEditor/Syntax.h index 4b0beb91b..0dfa20608 100644 --- a/uppsrc/CodeEditor/Syntax.h +++ b/uppsrc/CodeEditor/Syntax.h @@ -93,8 +93,8 @@ public: class EditorSyntax : public HighlightSetup { // Inheriting to make static members available struct SyntaxDef { Event&> factory; - String patterns; - String description; + String patterns; + String description; }; static ArrayMap& defs(); diff --git a/uppsrc/CtrlLib/TextEdit.h b/uppsrc/CtrlLib/TextEdit.h index 93a9bf6b7..115401e91 100644 --- a/uppsrc/CtrlLib/TextEdit.h +++ b/uppsrc/CtrlLib/TextEdit.h @@ -385,6 +385,7 @@ public: LineEdit& TabSize(int n); int GetTabSize() const { return tabsize; } LineEdit& BorderColumn(int col, Color c = SColorFace()); + int GetBorderColumn() const { return bordercolumn; } LineEdit& SetFont(Font f); Font GetFont() const { return font; } LineEdit& NoHorzScrollbar(bool b = true) { nohbar = b; ScrollIntoCursor(); return *this; } diff --git a/uppsrc/CtrlLib/src.tpp/LineEdit$en-us.tpp b/uppsrc/CtrlLib/src.tpp/LineEdit$en-us.tpp index 655f21d58..0cc92a2a3 100644 --- a/uppsrc/CtrlLib/src.tpp/LineEdit$en-us.tpp +++ b/uppsrc/CtrlLib/src.tpp/LineEdit$en-us.tpp @@ -308,6 +308,11 @@ rColumn]([@(0.0.255) int]_[*@3 col], [_^Color^ Color]_[*@3 c]_`=_SColorFace())&] [s2;%% Displays a border column of width [%-*@3 col] and color [%-*@3 c].&] [s3; &] [s4; &] +[s5;:Upp`:`:LineEdit`:`:GetBorderColumn`(`)const: [@(0.0.255) int]_[* GetBorderColumn]()_ +[@(0.0.255) const]&] +[s2;%% Return border column position.&] +[s3; &] +[s4; &] [s5;:LineEdit`:`:SetFont`(Font`): [_^LineEdit^ LineEdit][@(0.0.255) `&]_[* SetFont]([_^Font^ F ont]_[*@3 f])&] [s2;%% Sets the font. HighlightLine can replace this font, however,