mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 14:16:07 -06:00
CodeEditor, ide: Word wrap
git-svn-id: svn://ultimatepp.org/upp/trunk@11473 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
a70d0b7d4a
commit
5dff5fc989
8 changed files with 61 additions and 12 deletions
|
|
@ -987,6 +987,36 @@ bool CodeEditor::Key(dword code, int count) {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
if(wordwrap && code > 0 && code < 65535) {
|
||||
int limit = GetBorderColumn();
|
||||
int pos = GetCursor();
|
||||
int lp = pos;
|
||||
int l = GetLinePos(lp);
|
||||
if(limit > 10 && GetColumnLine(pos).x >= limit && lp == GetLineLength(l)) {
|
||||
int lp0 = GetPos(l);
|
||||
WString ln = GetWLine(l);
|
||||
int wl = GetGPos(l, limit) - lp0;
|
||||
while(wl > 0 && ln[wl - 1] != ' ')
|
||||
wl--;
|
||||
int sl = wl - 1;
|
||||
while(sl > 0 && ln[wl - 1] != '\n' && ln[sl - 1] == ' ')
|
||||
sl--;
|
||||
wordwrap = false;
|
||||
Remove(lp0 + sl, pos - (lp0 + sl));
|
||||
SetCursor(lp0 + sl);
|
||||
Put('\n');
|
||||
for(int i = 0; i < wl && findarg(ln[i], ' ', '\t') >= 0; i++)
|
||||
Put(ln[i]);
|
||||
for(int i = wl; i < ln.GetCount(); i++)
|
||||
Put(ln[i]);
|
||||
while(count--)
|
||||
Put(code);
|
||||
FinishPut();
|
||||
wordwrap = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
if(code >= 32 && code < 128 && count == 1) {
|
||||
IndentInsert(code, 1);
|
||||
return true;
|
||||
|
|
@ -1101,6 +1131,7 @@ CodeEditor::CodeEditor() {
|
|||
tippos = -1;
|
||||
selkind = SEL_CHARS;
|
||||
withfindreplace = true;
|
||||
wordwrap = false;
|
||||
}
|
||||
|
||||
CodeEditor::~CodeEditor() {}
|
||||
|
|
|
|||
|
|
@ -225,13 +225,13 @@ protected:
|
|||
|
||||
// EditorSyntax rm_ins;
|
||||
|
||||
char rmb;
|
||||
int highlight_bracket_pos0;
|
||||
int highlight_bracket_pos;
|
||||
bool bracket_flash;
|
||||
int bracket_start;
|
||||
char rmb;
|
||||
int highlight_bracket_pos0;
|
||||
int highlight_bracket_pos;
|
||||
bool bracket_flash;
|
||||
int bracket_start;
|
||||
|
||||
bool barline : 1;
|
||||
bool barline;
|
||||
double stat_edit_time;
|
||||
Time last_key_time;
|
||||
|
||||
|
|
@ -241,6 +241,7 @@ protected:
|
|||
bool persistent_find_replace;
|
||||
bool do_ff_restore_pos;
|
||||
bool withfindreplace;
|
||||
bool wordwrap;
|
||||
|
||||
int ff_start_pos;
|
||||
|
||||
|
|
@ -483,6 +484,7 @@ public:
|
|||
bool GetMarkLines() { return mark_lines; }
|
||||
void AutoEnclose(bool b) { auto_enclose = b; }
|
||||
void BarLine(bool b) { barline = b; }
|
||||
void WordWrap(bool b) { wordwrap = b; }
|
||||
|
||||
void PersistentFindReplace(bool b = true) { persistent_find_replace = b; }
|
||||
bool IsPersistentFindReplace() const { return persistent_find_replace; }
|
||||
|
|
|
|||
|
|
@ -170,7 +170,7 @@ void Sentinel(Stream& s, const char *txt)
|
|||
|
||||
void Ide::Serialize(Stream& s)
|
||||
{
|
||||
int version = 12;
|
||||
int version = 13;
|
||||
Sentinel(s, "before 12341234");
|
||||
s.Magic(0x12341234);
|
||||
Sentinel(s, "after magic");
|
||||
|
|
@ -215,6 +215,10 @@ void Ide::Serialize(Stream& s)
|
|||
s % tabs_stacking;
|
||||
if(version >= 11)
|
||||
s % spellcheck_comments;
|
||||
if(version >= 13) {
|
||||
s % wordwrap_comments;
|
||||
s % wordwrap;
|
||||
}
|
||||
bool dummy_force_crlf = false;
|
||||
s % dummy_force_crlf;
|
||||
if(version >= 1)
|
||||
|
|
|
|||
|
|
@ -184,12 +184,10 @@ void Ide::InsertInclude(Bar& bar)
|
|||
bar.Add("All #includes", THISBACK1(InsertText, all));
|
||||
}
|
||||
|
||||
void Ide::InsertAdvanced(Bar& bar)
|
||||
void Ide::ToggleWordwrap()
|
||||
{
|
||||
bool b = !editor.IsReadOnly();
|
||||
bar.Add(b, "Insert", THISBACK(InsertMenu));
|
||||
bar.Add(b, "Insert #include", THISBACK(InsertInclude));
|
||||
bar.Add(b, "Advanced", THISBACK(EditSpecial));
|
||||
wordwrap = !wordwrap;
|
||||
SetupEditor();
|
||||
}
|
||||
|
||||
void Ide::EditorMenu(Bar& bar)
|
||||
|
|
|
|||
|
|
@ -598,6 +598,7 @@ public:
|
|||
bool auto_check;
|
||||
int spellcheck_comments;
|
||||
bool wordwrap_comments;
|
||||
bool wordwrap;
|
||||
/*
|
||||
astyle code formatter control vars
|
||||
added 2008.01.27 by Massimo Del Fedele
|
||||
|
|
@ -809,6 +810,7 @@ public:
|
|||
void InsertInclude(Bar& bar);
|
||||
void InsertAdvanced(Bar& bar);
|
||||
void EditorMenu(Bar& bar);
|
||||
void ToggleWordwrap();
|
||||
|
||||
void OnlineSearchMenu(Bar& menu);
|
||||
void OnlineSearch();
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ KEY(SPACESTOTABS, "Spaces to tabs", 0)
|
|||
KEY(TABSTOSPACES, "Tabs to spaces", 0)
|
||||
KEY(LINEENDINGS, "Remove trailing tabs and spaces", 0)
|
||||
KEY(DUPLICATELINE, "Duplicate line", K_CTRL_D)
|
||||
KEY(WORDWRAP, "Word wrap", K_ALT_W)
|
||||
|
||||
KEY(FORMATCODE, "Format code in editor", 0)
|
||||
|
||||
|
|
|
|||
|
|
@ -115,6 +115,16 @@ void Ide::OnlineSearchMenu(Bar& menu)
|
|||
menu.Add(b, AK_GOOGLEUPP, IdeImg::GoogleUpp(), THISBACK(OnlineSearchOnTheOfficialSite));
|
||||
}
|
||||
|
||||
void Ide::InsertAdvanced(Bar& bar)
|
||||
{
|
||||
bool b = !editor.IsReadOnly();
|
||||
bar.Add(AK_WORDWRAP, THISBACK(ToggleWordwrap))
|
||||
.Check(wordwrap);
|
||||
bar.Add(b, "Insert", THISBACK(InsertMenu));
|
||||
bar.Add(b, "Insert #include", THISBACK(InsertInclude));
|
||||
bar.Add(b, "Advanced", THISBACK(EditSpecial));
|
||||
}
|
||||
|
||||
void Ide::EditSpecial(Bar& menu)
|
||||
{
|
||||
bool b = !editor.IsReadOnly();
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ void Ide::SetupEditor(int f, String hl, String path)
|
|||
findarg(hl, "cpp", "java", "js", "cs", "json", "css", "lay", "sch", "t", "usc") >= 0);
|
||||
|
||||
editor.WordwrapComments(wordwrap_comments);
|
||||
editor.WordWrap(wordwrap);
|
||||
}
|
||||
|
||||
void Ide::SetupEditor()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue