perl-curses.patch 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577
  1. Index: CHANGES.RSE
  2. ===================================================================
  3. RCS file: CHANGES.RSE
  4. diff -N CHANGES.RSE
  5. --- /dev/null 1 Jan 1970 00:00:00 -0000
  6. +++ CHANGES.RSE 14 Apr 2003 10:18:10 -0000
  7. @@ -0,0 +1,27 @@
  8. +
  9. + The following changes were made by Ralf S. Engelschall <rse@engelschall.com>
  10. + to the excellent Curses::UI by Maurice Makaay <maurice@gitaar.net>.
  11. +
  12. + o Make sure that Curses::UI::Listbox draws the selected values in bold
  13. + also under "multi" and "radio" options to be consistent in look &
  14. + feel with the standard list box.
  15. +
  16. + o Add support for root->overlapping(1) (default) and
  17. + root->overlapping(0) to optimize the redrawing by reducing to
  18. + the old and new focused widgets. The default is still to redraw
  19. + everything which is necessary to support overlapping windows.
  20. +
  21. + o Add -reverse option to Curses::UI::TextEditor.
  22. +
  23. + o Add color support.
  24. +
  25. + o Fix reverse rendering for Label demo in demo-widgets.
  26. +
  27. + o Add -htmltext option to Curses::UI::Widget, corresponding
  28. + text_chop(), text_length() and text_draw() functions to
  29. + Curses::UI::Common and used the stuff in Curses::UI::Listbox
  30. + to allow in-line markup.
  31. +
  32. + o Fix top-level DESTROY (destructor) function to correctly
  33. + shutdown Curses and allow re-initializations.
  34. +
  35. Index: lib/Curses/UI.pm
  36. ===================================================================
  37. RCS file: /u/rse/wrk/cui/cvs/cui/lib/Curses/UI.pm,v
  38. retrieving revision 1.1.1.3
  39. diff -u -d -u -d -r1.1.1.3 UI.pm
  40. --- lib/Curses/UI.pm 29 Mar 2003 10:41:56 -0000 1.1.1.3
  41. +++ lib/Curses/UI.pm 21 Apr 2003 08:57:23 -0000
  42. @@ -67,6 +67,8 @@
  43. -debug => undef, # Turn on debugging mode?
  44. -language => undef, # Which language to use?
  45. -mouse_support => 1, # Do we want mouse support
  46. + -overlapping => 1, # Whether overlapping widgets are supported
  47. + -colors => 0, # Whether colors are used
  48. #user data
  49. -userdata => undef, #user internal data
  50. @@ -106,8 +108,11 @@
  51. DESTROY
  52. {
  53. my $this = shift;
  54. + my $scr = $this->{-canvasscr};
  55. + $scr->delwin() if (defined($scr));
  56. endwin();
  57. $Curses::UI::rootobject = undef;
  58. + $Curses::UI::initialized = 0;
  59. if ($this->{-clear_on_exit})
  60. {
  61. @@ -126,6 +131,8 @@
  62. sub clear_on_exit(;$) { shift()->accessor('-clear_on_exit', shift()) }
  63. sub cursor_mode(;$) { shift()->accessor('-cursor_mode', shift()) }
  64. sub lang(;$) { shift()->accessor('-language_object', shift()) }
  65. +sub overlapping(;$) { shift()->accessor('-overlapping', shift()) }
  66. +sub colors(;$) { shift()->accessor('-colors', shift()) }
  67. # TODO: document
  68. sub debug(;$)
  69. @@ -136,6 +143,61 @@
  70. }
  71. # ----------------------------------------------------------------------
  72. +# Color support
  73. +# ----------------------------------------------------------------------
  74. +
  75. +$Curses::UI::colorpairs = 0;
  76. +$Curses::UI::colorpair = {};
  77. +
  78. +sub colorpair ($$;$$)
  79. +{
  80. + my $this = shift;
  81. + my ($name, $fg, $bg) = @_;
  82. + my $colors_name2num = {
  83. + 'black' => COLOR_BLACK,
  84. + 'red' => COLOR_RED,
  85. + 'green' => COLOR_GREEN,
  86. + 'yellow' => COLOR_YELLOW,
  87. + 'blue' => COLOR_BLUE,
  88. + 'magenta' => COLOR_MAGENTA,
  89. + 'cyan' => COLOR_CYAN,
  90. + 'white' => COLOR_WHITE
  91. + };
  92. +
  93. + if (not $this->{-colors}) {
  94. + return 0;
  95. + }
  96. + if (not defined($fg) and not defined($bg)) {
  97. + return ($Curses::UI::colorpair->{$name} || 0);
  98. + }
  99. + else {
  100. + my $n = $Curses::UI::colorpair->{$name};
  101. + if (not defined($n)) {
  102. + $Curses::UI::colorpairs++;
  103. + $n = $Curses::UI::colorpairs;
  104. + }
  105. + $fg = $colors_name2num->{$fg} || 'default';
  106. + if ($fg eq 'default') {
  107. + my ($fg_d, $bg_d) = (0, 0);
  108. + pair_content(0, $fg_d, $bg_d);
  109. + $fg = $fg_d;
  110. + }
  111. + $bg = $colors_name2num->{$bg} || 'default';
  112. + if ($bg eq 'default') {
  113. + my ($fg_d, $bg_d) = (0, 0);
  114. + pair_content(0, $fg_d, $bg_d);
  115. + $bg = $bg_d;
  116. + }
  117. + init_pair($n, $fg, $bg);
  118. + if ($name eq 'default') {
  119. + assume_default_colors($fg, $bg);
  120. + }
  121. + $Curses::UI::colorpair->{$name} = $n;
  122. + return $n;
  123. + }
  124. +}
  125. +
  126. +# ----------------------------------------------------------------------
  127. # Window resizing support
  128. # ----------------------------------------------------------------------
  129. @@ -151,6 +213,23 @@
  130. initscr();
  131. noecho();
  132. raw();
  133. +
  134. + # Color support
  135. + if ($this->{-colors}) {
  136. + if (has_colors()) {
  137. + start_color();
  138. + #my $bg = -1;
  139. + #use_default_colors();
  140. + my $bg = COLOR_BLACK;
  141. + assume_default_colors(COLOR_WHITE, $bg);
  142. + $Curses::UI::colorpair->{"default"} = 0;
  143. + $Curses::UI::colorpairs = 1;
  144. + $this->colorpair('selected', 'default', 'default');
  145. + }
  146. + else {
  147. + $this->{-colors} = 0;
  148. + }
  149. + }
  150. # Mouse events if possible
  151. my $old = 0;
  152. Index: lib/Curses/UI/Common.pm
  153. ===================================================================
  154. RCS file: /u/rse/wrk/cui/cvs/cui/lib/Curses/UI/Common.pm,v
  155. retrieving revision 1.1.1.2
  156. diff -u -d -u -d -r1.1.1.2 Common.pm
  157. --- lib/Curses/UI/Common.pm 28 Mar 2003 08:22:36 -0000 1.1.1.2
  158. +++ lib/Curses/UI/Common.pm 13 Apr 2003 11:11:53 -0000
  159. @@ -35,6 +35,9 @@
  160. @EXPORT = qw(
  161. keys_to_lowercase
  162. text_wrap
  163. + text_draw
  164. + text_length
  165. + text_chop
  166. scrlength
  167. split_to_lines
  168. text_dimension
  169. @@ -213,6 +216,125 @@
  170. }
  171. return \@wrapped;
  172. +}
  173. +
  174. +sub text_tokenize {
  175. + my ($text) = @_;
  176. +
  177. + my @tokens = ();
  178. + while ($text ne '') {
  179. + if ($text =~ m/^<\/?[a-zA-Z0-9_]+>/s) {
  180. + push(@tokens, $&);
  181. + $text = $';
  182. + }
  183. + elsif ($text =~ m/^.+?(?=<\/?[a-zA-Z0-9_]+>)/s) {
  184. + push(@tokens, $&);
  185. + $text = $';
  186. + }
  187. + else {
  188. + push(@tokens, $text);
  189. + last;
  190. + }
  191. + }
  192. + return @tokens;
  193. +}
  194. +
  195. +sub text_draw($$;)
  196. +{
  197. + my $this = shift;
  198. + my ($y, $x, $text) = @_;
  199. +
  200. + if ($this->{-htmltext}) {
  201. + my @tokens = &text_tokenize($text);
  202. + foreach my $token (@tokens) {
  203. + if ($token =~ m/^<(standout|reverse|bold|underline|blink|dim)>$/s) {
  204. + my $type = $1;
  205. + if ($type eq 'standout') { $this->{-canvasscr}->attron(A_STANDOUT); }
  206. + elsif ($type eq 'reverse') { $this->{-canvasscr}->attron(A_REVERSE); }
  207. + elsif ($type eq 'bold') { $this->{-canvasscr}->attron(A_BOLD); }
  208. + elsif ($type eq 'underline') { $this->{-canvasscr}->attron(A_UNDERLINE); }
  209. + elsif ($type eq 'blink') { $this->{-canvasscr}->attron(A_BLINK); }
  210. + elsif ($type eq 'dim') { $this->{-canvasscr}->attron(A_DIM); }
  211. + }
  212. + elsif ($token =~ m/^<\/(standout|reverse|bold|underline|blink|dim)>$/s) {
  213. + my $type = $1;
  214. + if ($type eq 'standout') { $this->{-canvasscr}->attroff(A_STANDOUT); }
  215. + elsif ($type eq 'reverse') { $this->{-canvasscr}->attroff(A_REVERSE); }
  216. + elsif ($type eq 'bold') { $this->{-canvasscr}->attroff(A_BOLD); }
  217. + elsif ($type eq 'underline') { $this->{-canvasscr}->attroff(A_UNDERLINE); }
  218. + elsif ($type eq 'blink') { $this->{-canvasscr}->attroff(A_BLINK); }
  219. + elsif ($type eq 'dim') { $this->{-canvasscr}->attroff(A_DIM); }
  220. + }
  221. + else {
  222. + $this->{-canvasscr}->addstr($y, $x, $token);
  223. + $x += length($token);
  224. + }
  225. + }
  226. + }
  227. + else {
  228. + $this->{-canvasscr}->addstr($y, $x, $text);
  229. + }
  230. +}
  231. +
  232. +sub text_length {
  233. + my $this = shift;
  234. + my ($text) = @_;
  235. +
  236. + my $length = 0;
  237. + if ($this->{-htmltext}) {
  238. + my @tokens = &text_tokenize($text);
  239. + foreach my $token (@tokens) {
  240. + if ($token !~ m/^<\/?(reverse|bold|underline|blink|dim)>$/s) {
  241. + $length += length($token);
  242. + }
  243. + }
  244. + }
  245. + else {
  246. + $length = length($text);
  247. + }
  248. + return $length;
  249. +}
  250. +
  251. +sub text_chop {
  252. + my $this = shift;
  253. + my ($text, $max_length) = @_;
  254. +
  255. + if ($this->{-htmltext}) {
  256. + my @open = ();
  257. + my @tokens = &text_tokenize($text);
  258. + my $length = 0;
  259. + $text = '';
  260. + foreach my $token (@tokens) {
  261. + if ($token =~ m/^<(\/?)(reverse|bold|underline|blink|dim)>/s) {
  262. + my ($type, $name) = ($1, $2);
  263. + if (defined($type) and $type eq '/') {
  264. + pop(@open);
  265. + }
  266. + else {
  267. + push(@open, $name);
  268. + }
  269. + $text .= $token;
  270. + }
  271. + else {
  272. + $text .= $token;
  273. + $length += length($token);
  274. + if ($length > $max_length) {
  275. + $text = substr($text, 0, $max_length);
  276. + $text =~ s/.$/\$/;
  277. + while (defined($token = pop(@open))) {
  278. + $text .= "</$token>";
  279. + }
  280. + last;
  281. + }
  282. + }
  283. + }
  284. + }
  285. + else {
  286. + if (length($text) > $max_length) {
  287. + $text = substr($text, 0, $max_length);
  288. + }
  289. + }
  290. + return $text;
  291. }
  292. sub text_dimension ($;)
  293. Index: lib/Curses/UI/Label.pm
  294. ===================================================================
  295. RCS file: /u/rse/wrk/cui/cvs/cui/lib/Curses/UI/Label.pm,v
  296. retrieving revision 1.1.1.2
  297. retrieving revision 1.3
  298. diff -u -d -u -d -r1.1.1.2 -r1.3
  299. --- lib/Curses/UI/Label.pm 28 Mar 2003 08:22:35 -0000 1.1.1.2
  300. +++ lib/Curses/UI/Label.pm 28 Mar 2003 08:24:58 -0000 1.3
  301. @@ -51,6 +51,7 @@
  302. -dim => 0,
  303. -blink => 0,
  304. -paddingspaces => 0, # Pad text with spaces?
  305. + -colorpair => undef, # Color-pair attribute
  306. %userargs,
  307. @@ -104,6 +105,7 @@
  308. sub underline ($;$) { shift()->set_attribute('-underline', shift()) }
  309. sub dim ($;$) { shift()->set_attribute('-dim', shift()) }
  310. sub blink ($;$) { shift()->set_attribute('-blink', shift()) }
  311. +sub colorpair ($;$) { shift()->set_attribute('-colorpair', shift()) }
  312. sub set_attribute($$;)
  313. {
  314. @@ -183,6 +185,7 @@
  315. $this->{-canvasscr}->attron(A_UNDERLINE) if $this->{-underline};
  316. $this->{-canvasscr}->attron(A_BLINK) if $this->{-blink};
  317. $this->{-canvasscr}->attron(A_DIM) if $this->{-dim};
  318. + $this->{-canvasscr}->attron(COLOR_PAIR($this->root->colorpair($this->{-colorpair}))) if $this->{-colorpair};
  319. # Draw the text. Clip it if it is too long.
  320. my $ypos = 0;
  321. Index: lib/Curses/UI/Listbox.pm
  322. ===================================================================
  323. RCS file: /u/rse/wrk/cui/cvs/cui/lib/Curses/UI/Listbox.pm,v
  324. retrieving revision 1.1.1.3
  325. diff -u -d -u -d -r1.1.1.3 Listbox.pm
  326. --- lib/Curses/UI/Listbox.pm 29 Mar 2003 10:41:56 -0000 1.1.1.3
  327. +++ lib/Curses/UI/Listbox.pm 13 Apr 2003 11:08:27 -0000
  328. @@ -289,10 +289,7 @@
  329. (($this->{-multi} or $this->{-radio}) ? 4 : 0);
  330. # Chop length if needed.
  331. - if (($prefix_len + length($label)) > $this->canvaswidth) {
  332. - $label = substr($label, 0, ($this->canvaswidth-$prefix_len));
  333. - $label =~ s/.$/\$/;
  334. - }
  335. + $label = $this->text_chop($label, ($this->canvaswidth-$prefix_len));
  336. # Show current entry in reverse mode and
  337. # save cursor position.
  338. @@ -304,10 +301,12 @@
  339. }
  340. # Show selected element bold.
  341. - if (not $this->{-multi} and
  342. - not $this->{-radio} and
  343. - defined $this->{-selected} and
  344. - $this->{-selected} == $i) {
  345. + if ( ( not $this->{-multi}
  346. + and defined $this->{-selected}
  347. + and $this->{-selected} == $i)
  348. + or ( $this->{-multi}
  349. + and defined $this->{-selected}
  350. + and $this->{-selected}->{$i}) ) {
  351. $this->{-canvasscr}->attron(A_BOLD);
  352. }
  353. @@ -318,10 +317,7 @@
  354. );
  355. # Show label
  356. - $this->{-canvasscr}->addstr(
  357. - $y, $prefix_len,
  358. - $label
  359. - );
  360. + $this->text_draw($y, $prefix_len, $label);
  361. $this->{-canvasscr}->attroff(A_REVERSE);
  362. $this->{-canvasscr}->attroff(A_BOLD);
  363. Index: lib/Curses/UI/TextEditor.pm
  364. ===================================================================
  365. RCS file: /u/rse/wrk/cui/cvs/cui/lib/Curses/UI/TextEditor.pm,v
  366. retrieving revision 1.1.1.3
  367. retrieving revision 1.4
  368. diff -u -d -u -d -r1.1.1.3 -r1.4
  369. --- lib/Curses/UI/TextEditor.pm 29 Mar 2003 10:41:57 -0000 1.1.1.3
  370. +++ lib/Curses/UI/TextEditor.pm 29 Mar 2003 10:42:44 -0000 1.4
  371. @@ -151,6 +151,7 @@
  372. -vscrollbar => 0, # show vertical scrollbar
  373. -hscrollbar => 0, # show horizontal scrollbar
  374. -readonly => 0, # only used as viewer?
  375. + -reverse => 0, # show in reverse
  376. # Single line options
  377. -password => undef, # masquerade chars with given char
  378. @@ -451,9 +452,10 @@
  379. # Turn on underlines and fill the screen with lines
  380. # if neccessary.
  381. - if ($this->{-showlines})
  382. + if ($this->{-showlines} or $this->{-reverse})
  383. {
  384. - $this->{-canvasscr}->attron(A_UNDERLINE);
  385. + $this->{-canvasscr}->attron(A_UNDERLINE) if ($this->{-showlines});;
  386. + $this->{-canvasscr}->attron(A_REVERSE) if ($this->{-reverse});
  387. for my $y (0..$this->canvasheight-1) {
  388. $this->{-canvasscr}->addstr($y, 0, " "x($this->canvaswidth));
  389. }
  390. @@ -464,9 +466,11 @@
  391. {
  392. if (defined $this->{-search_highlight}
  393. and $this->{-search_highlight} == ($id+$this->{-yscrpos})) {
  394. - $this->{-canvasscr}->attron(A_REVERSE);
  395. + $this->{-canvasscr}->attron(A_REVERSE) if (not $this->{-reverse});
  396. + $this->{-canvasscr}->attroff(A_REVERSE) if ($this->{-reverse});
  397. } else {
  398. - $this->{-canvasscr}->attroff(A_REVERSE);
  399. + $this->{-canvasscr}->attroff(A_REVERSE) if (not $this->{-reverse});
  400. + $this->{-canvasscr}->attron(A_REVERSE) if ($this->{-reverse});
  401. }
  402. my $l = $this->{-scr_lines}->[$id + $this->{-yscrpos}];
  403. @@ -560,6 +564,7 @@
  404. }
  405. $this->{-canvasscr}->attroff(A_UNDERLINE) if $this->{-showlines};
  406. + $this->{-canvasscr}->attroff(A_REVERSE) if $this->{-reverse};
  407. $this->{-canvasscr}->noutrefresh();
  408. doupdate() unless $no_doupdate;
  409. return $this;
  410. Index: lib/Curses/UI/Widget.pm
  411. ===================================================================
  412. RCS file: /u/rse/wrk/cui/cvs/cui/lib/Curses/UI/Widget.pm,v
  413. retrieving revision 1.1.1.3
  414. diff -u -d -u -d -r1.1.1.3 Widget.pm
  415. --- lib/Curses/UI/Widget.pm 29 Mar 2003 10:41:57 -0000 1.1.1.3
  416. +++ lib/Curses/UI/Widget.pm 13 Apr 2003 11:14:54 -0000
  417. @@ -85,6 +85,7 @@
  418. -onblur => undef, # onBlur event handler
  419. -intellidraw => 1, # Support intellidraw()?
  420. -focusable => 1, # This widget can get focus
  421. + -htmltext => 1, # Recognize HTML tags in drawn text
  422. #user data
  423. -userdata => undef, #user internal data
  424. @@ -472,7 +473,7 @@
  425. my $parent = $this->parent;
  426. $parent->focus($this) if defined $parent;
  427. - $this->draw(1);
  428. + $this->draw(1) if ($this->root->overlapping);
  429. return $this;
  430. }
  431. @@ -523,6 +524,7 @@
  432. if ($this->{-sbborder}) # Square bracket ([,]) border
  433. {
  434. $this->{-borderscr}->attron(A_BOLD) if $this->{-focus};
  435. + $this->{-borderscr}->attron(COLOR_PAIR($this->root->colorpair('selected'))) if $this->{-focus};
  436. my $offset = 1;
  437. $offset++ if $this->{-vscrollbar};
  438. for my $y (0 .. $this->{-sh}-1)
  439. @@ -532,10 +534,12 @@
  440. $this->{-borderscr}->addstr($rel_y, $this->{-bw}-$offset, ']');
  441. }
  442. $this->{-borderscr}->attroff(A_BOLD) if $this->{-focus};
  443. + $this->{-borderscr}->attroff(COLOR_PAIR($this->root->colorpair('selected'))) if $this->{-focus};
  444. }
  445. elsif ($this->{-border}) # Normal border
  446. {
  447. $this->{-borderscr}->attron(A_BOLD) if $this->{-focus};
  448. + $this->{-borderscr}->attron(COLOR_PAIR($this->root->colorpair('selected'))) if $this->{-focus};
  449. if ($this->root->compat) {
  450. $this->{-borderscr}->border(
  451. '|','|','-','-',
  452. @@ -545,6 +549,7 @@
  453. $this->{-borderscr}->box(ACS_VLINE, ACS_HLINE);
  454. }
  455. $this->{-borderscr}->attroff(A_BOLD) if $this->{-focus};
  456. + $this->{-borderscr}->attroff(COLOR_PAIR($this->root->colorpair('selected'))) if $this->{-focus};
  457. # Draw a title if needed.
  458. if (defined $this->{-title})
  459. @@ -628,6 +633,7 @@
  460. # Draw the base of the scrollbar, in case
  461. # there is no border.
  462. $this->{-borderscr}->attron(A_BOLD) if $this->{-focus};
  463. + $this->{-borderscr}->attron(COLOR_PAIR($this->root->colorpair('selected'))) if $this->{-focus};
  464. $this->{-borderscr}->move($ypos_min, $xpos);
  465. $this->{-borderscr}->vline(ACS_VLINE,$scrlen);
  466. if ($this->root->compat) {
  467. @@ -636,6 +642,7 @@
  468. $this->{-borderscr}->vline(ACS_VLINE,$scrlen);
  469. }
  470. $this->{-borderscr}->attroff(A_BOLD) if $this->{-focus};
  471. + $this->{-borderscr}->attroff(COLOR_PAIR($this->root->colorpair('selected'))) if $this->{-focus};
  472. # Should an active region be drawn?
  473. my $scroll_active = ($this->{-vscrolllen} > $scrlen);
  474. @@ -693,6 +700,7 @@
  475. # Draw the base of the scrollbar, in case
  476. # there is no border.
  477. $this->{-borderscr}->attron(A_BOLD) if $this->{-focus};
  478. + $this->{-borderscr}->attron(COLOR_PAIR($this->root->colorpair('selected'))) if $this->{-focus};
  479. $this->{-borderscr}->move($ypos, $xpos_min);
  480. if ($this->root->compat) {
  481. $this->{-borderscr}->hline('-',$scrlen);
  482. @@ -700,6 +708,7 @@
  483. $this->{-borderscr}->hline(ACS_HLINE,$scrlen);
  484. }
  485. $this->{-borderscr}->attroff(A_BOLD) if $this->{-focus};
  486. + $this->{-borderscr}->attroff(COLOR_PAIR($this->root->colorpair('selected'))) if $this->{-focus};
  487. # Should an active region be drawn?
  488. my $scroll_active = ($this->{-hscrolllen} > $scrlen);
  489. @@ -959,6 +968,8 @@
  490. my $show_cursor = $this->{-nocursor} ? 0 : 1;
  491. $this->root->cursor_mode($show_cursor);
  492. + $this->draw(1) if (not $this->root->overlapping);
  493. +
  494. return $this;
  495. }
  496. @@ -967,6 +978,7 @@
  497. my $this = shift;
  498. $this->{-focus} = 0;
  499. $this->run_event('-onblur');
  500. + $this->draw(1) if (not $this->root->overlapping);
  501. return $this;
  502. }
  503. Index: examples/demo-widgets
  504. ===================================================================
  505. RCS file: /u/rse/wrk/cui/cvs/cui/examples/demo-widgets,v
  506. retrieving revision 1.1.1.2
  507. diff -u -d -u -d -r1.1.1.2 demo-widgets
  508. --- examples/demo-widgets 29 Mar 2003 10:41:58 -0000 1.1.1.2
  509. +++ examples/demo-widgets 12 Apr 2003 19:07:10 -0000
  510. @@ -1,6 +1,11 @@
  511. -#!/usr/bin/perl -w
  512. +#!/usr/lpkg/bin/perl -w
  513. use strict;
  514. use File::Temp qw( :POSIX );
  515. +use lib "../lib";
  516. +
  517. +# make KEY_BTAB (shift-tab) working in XTerm
  518. +# and also at the same time enable colors
  519. +#$ENV{TERM} = "xterm-vt220" if ($ENV{TERM} eq 'xterm');
  520. my $debug = 0;
  521. if (@ARGV and $ARGV[0] eq '-d') {
  522. @@ -22,7 +27,10 @@
  523. my $cui = new Curses::UI (
  524. -clear_on_exit => 1,
  525. -debug => $debug,
  526. + -colors => 1,
  527. );
  528. +$cui->colorpair('selected', 'red', 'default');
  529. +$cui->colorpair('white-on-red', 'white', 'red');
  530. # Demo index
  531. my $current_demo = 1;
  532. @@ -150,9 +158,10 @@
  533. $w{1}->add(undef,'Label',-text=>"dim font",-y=>5,-dim=>1 );
  534. $w{1}->add(undef,'Label',-text=>"bold font",-y=>7,-bold=>1 );
  535. -$w{1}->add(undef,'Label',-text=>"reversed font",-y=>9,-reversed => 1 );
  536. +$w{1}->add(undef,'Label',-text=>"reversed font",-y=>9,-reverse => 1 );
  537. $w{1}->add(undef,'Label',-text=>"underlined font",-x=>15,-y=>5,-underline=>1 );
  538. $w{1}->add(undef,'Label',-text=>"blinking font",-x=>15,-y=>7,-blink=>1 );
  539. +$w{1}->add(undef,'Label',-text=>"colorized font",-x=>15,-y=>9,-colorpair => 'white-on-red' );
  540. # ----------------------------------------------------------------------
  541. # Buttons demo