CtrlLib: LineEdit::ShowSpaces

git-svn-id: svn://ultimatepp.org/upp/trunk@3351 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2011-04-17 20:28:29 +00:00
parent d0f51114ce
commit a08f12f625
3 changed files with 55 additions and 8 deletions

View file

@ -19,6 +19,7 @@ LineEdit::LineEdit() {
bordercolor = Null;
overwrite = false;
filter = NULL;
showspaces = false;
}
LineEdit::~LineEdit() {}
@ -142,10 +143,25 @@ void LineEdit::Paint0(Draw& w) {
q++;
gp = ngp;
}
else if(txt[q] == ' ') {
LLOG("Highlight -> space[" << q << "] paper = " << h.paper);
if(pass == 0) {
w.DrawRect(gp * fsz.cx - scx, y, fsz.cx * l, fsz.cy, h.paper);
if(showspaces && h.paper != SColorHighlight && q < tx.GetLength()) {
Color c = Blend(SColorLight, SColorHighlight);
w.DrawRect(gp * fsz.cx - scx + fsz.cx / 2, y + fsz.cy / 2,
1, 1, c);
}
if(bordercolumn > 0 && bordercolumn >= gp && bordercolumn < gp + 1)
w.DrawRect((bordercolumn - sc.x) * fsz.cx, y, 1, fsz.cy, bordercolor);
}
q++;
gp++;
}
else {
bool cjk = IsCJKIdeograph(txt[q]);
int p = q + 1;
while(p < len && h == hl[p] && txt[p] != '\t' && IsCJKIdeograph(txt[p]) == cjk && p - q < 128)
while(p < len && h == hl[p] && txt[p] != '\t' && txt[p] != ' ' && IsCJKIdeograph(txt[p]) == cjk && p - q < 128)
p++;
int l = p - q;
int ll = cjk ? 2 * l : l;

View file

@ -256,6 +256,7 @@ protected:
bool overwrite;
Scroller scroller;
Point caretpos;
bool showspaces;
void Paint0(Draw& w);
@ -337,6 +338,8 @@ public:
bool IsNoHorzScrollbar() const { return nohbar; }
LineEdit& ShowTabs(bool st = true) { showtabs = st; Refresh(); return *this; }
bool IsShowTabs() const { return showtabs; }
LineEdit& ShowSpaces(bool ss = true) { showspaces = ss; Refresh(); return *this; }
bool IsShowSpacess() const { return showspaces; }
LineEdit& WithCutLine(bool b) { cutline = b; return *this; }
LineEdit& NoCutLine() { return WithCutLine(false); }
bool IsWithCutLine() const { return cutline; }

View file

@ -266,24 +266,52 @@ rollbar]([@(0.0.255) bool]_[*@3 b]_`=_[@(0.0.255) true])&]
is off.&]
[s3; &]
[s4; &]
[s5;:LineEdit`:`:ShowTabs`(bool`): [_^LineEdit^ LineEdit][@(0.0.255) `&]_[* ShowTabs]([@(0.0.255) b
ool]_[*@3 st]_`=_[@(0.0.255) true])&]
[s5;:LineEdit`:`:IsNoHorzScrollbar`(`)const: [@(0.0.255) bool]_[* IsNoHorzScrollbar]()_[@(0.0.255) c
onst]&]
[s2;%% Returns status of NoHrozScrollbar.&]
[s3; &]
[s4; &]
[s5;:LineEdit`:`:IsShowTabs`(`)const: [@(0.0.255) bool]_[* IsShowTabs]()_[@(0.0.255) const]&]
[s5;:LineEdit`:`:ShowTabs`(bool`): [_^LineEdit^ LineEdit][@(0.0.255) `&]_[* ShowTabs]([@(0.0.255) b
ool]_[*@3 st]_`=_[@(0.0.255) true])&]
[s2;%% In this mode widget displays tabulators with faint graphics.
Default is off.&]
[s3; &]
[s4; &]
[s5;:LineEdit`:`:WithCutLine`(bool`): [_^LineEdit^ LineEdit][@(0.0.255) `&]_[* WithCutLine](
[@(0.0.255) bool]_[*@3 b])&]
[s5;:LineEdit`:`:IsShowTabs`(`)const: [@(0.0.255) bool]_[* IsShowTabs]()_[@(0.0.255) const]&]
[s2;%% Returns status of ShowTabs..&]
[s3; &]
[s4; &]
[s5;:LineEdit`:`:NoCutLine`(`): [_^LineEdit^ LineEdit][@(0.0.255) `&]_[* NoCutLine]()&]
[s5;:LineEdit`:`:ShowSpaces`(bool`): [_^LineEdit^ LineEdit][@(0.0.255) `&]_[* ShowSpaces]([@(0.0.255) b
ool]_[*@3 ss]_`=_[@(0.0.255) true])&]
[s2;%% In this mode widget displays spaces with faint dots. Default
is off..&]
[s3;%% &]
[s4; &]
[s5;:LineEdit`:`:IsShowSpacess`(`)const: [@(0.0.255) bool]_[* IsShowSpacess]()_[@(0.0.255) c
onst]&]
[s2;%% Returns status of ShowSpaces.&]
[s3; &]
[s4; &]
[s5;:LineEdit`:`:WithCutLine`(bool`): [_^LineEdit^ LineEdit][@(0.0.255) `&]_[* WithCutLine](
[@(0.0.255) bool]_[*@3 b])&]
[s2;%% In this mode widget calls CutLine when user presses Ctrl`+Y
or Ctrl`+L. Default is on.&]
[s3; &]
[s0; &]
[s4; &]
[s5;:LineEdit`:`:NoCutLine`(`): [_^LineEdit^ LineEdit][@(0.0.255) `&]_[* NoCutLine]()&]
[s2;%% Switches WithCutLine off.&]
[s3;%% &]
[s4; &]
[s5;:LineEdit`:`:IsWithCutLine`(`)const: [@(0.0.255) bool]_[* IsWithCutLine]()_[@(0.0.255) c
onst]&]
[s2;%% Returns status of WithCutLine.&]
[s3; &]
[s4; &]
[s5;:LineEdit`:`:SetFilter`(int`(`*`)`(int c`)`): [_^LineEdit^ LineEdit][@(0.0.255) `&]_[* S
etFilter]([@(0.0.255) int]_(`*[*@3 f])([@(0.0.255) int]_c))&]
[s2;%% Sets the filter of characters processed. Filter function can
alter characters before they are inserted into the text. If filter
function returns zero, character is rejected.&]
[s0; &]
[s0; &]
[ {{10000@3 [s0;%% [*@(229)4 LineEdit`::Highlight]]}}&]