@@ -20,9 +20,9 @@ $lines = join "", @lines;
|
||||
while ($lines =~ /\G(.*?)(\/\*.*?\*\/)?/gs) {
|
||||
addstr($1);
|
||||
if ($2) {
|
||||
attron(A_BOLD);
|
||||
addstr($2);
|
||||
attroff(A_BOLD);
|
||||
attron(A_BOLD);
|
||||
addstr($2);
|
||||
attroff(A_BOLD);
|
||||
}
|
||||
}
|
||||
|
||||
|
16
perl/07.pl
16
perl/07.pl
@@ -23,20 +23,20 @@ $my_win = create_newwin($height, $width, $starty, $startx);
|
||||
|
||||
while (($ch = getch()) != KEY_F(1)) {
|
||||
if ($ch == KEY_LEFT) {
|
||||
destroy_win($my_win);
|
||||
$my_win = create_newwin($height, $width, $starty, --$startx);
|
||||
destroy_win($my_win);
|
||||
$my_win = create_newwin($height, $width, $starty, --$startx);
|
||||
}
|
||||
elsif ($ch == KEY_RIGHT) {
|
||||
destroy_win($my_win);
|
||||
$my_win = create_newwin($height, $width, $starty, ++$startx);
|
||||
destroy_win($my_win);
|
||||
$my_win = create_newwin($height, $width, $starty, ++$startx);
|
||||
}
|
||||
elsif ($ch == KEY_UP) {
|
||||
destroy_win($my_win);
|
||||
$my_win = create_newwin($height, $width, --$starty, $startx);
|
||||
destroy_win($my_win);
|
||||
$my_win = create_newwin($height, $width, --$starty, $startx);
|
||||
}
|
||||
elsif ($ch == KEY_DOWN) {
|
||||
destroy_win($my_win);
|
||||
$my_win = create_newwin($height, $width, ++$starty, $startx);
|
||||
destroy_win($my_win);
|
||||
$my_win = create_newwin($height, $width, ++$starty, $startx);
|
||||
}
|
||||
}
|
||||
|
||||
|
58
perl/08.pl
58
perl/08.pl
@@ -32,24 +32,24 @@ create_box(\%win, 1);
|
||||
|
||||
while (($ch = getch()) != KEY_F(1)) {
|
||||
if ($ch == KEY_LEFT) {
|
||||
create_box(\%win, 0);
|
||||
$win{'startx'}--;
|
||||
create_box(\%win, 1);
|
||||
create_box(\%win, 0);
|
||||
$win{'startx'}--;
|
||||
create_box(\%win, 1);
|
||||
}
|
||||
elsif ($ch == KEY_RIGHT) {
|
||||
create_box(\%win, 0);
|
||||
$win{'startx'}++;
|
||||
create_box(\%win, 1);
|
||||
create_box(\%win, 0);
|
||||
$win{'startx'}++;
|
||||
create_box(\%win, 1);
|
||||
}
|
||||
elsif ($ch == KEY_UP) {
|
||||
create_box(\%win, 0);
|
||||
$win{'starty'}--;
|
||||
create_box(\%win, 1);
|
||||
create_box(\%win, 0);
|
||||
$win{'starty'}--;
|
||||
create_box(\%win, 1);
|
||||
}
|
||||
elsif ($ch == KEY_DOWN) {
|
||||
create_box(\%win, 0);
|
||||
$win{'starty'}++;
|
||||
create_box(\%win, 1);
|
||||
create_box(\%win, 0);
|
||||
$win{'starty'}++;
|
||||
create_box(\%win, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,10 +74,10 @@ sub init_win_params {
|
||||
|
||||
sub print_win_params {
|
||||
if ($_DEBUG) {
|
||||
$p_win = shift;
|
||||
addstr(25, 0,
|
||||
"$$p_win{startx} $$p_win{starty} $$p_win{width} $$p_win{height}");
|
||||
refresh();
|
||||
$p_win = shift;
|
||||
addstr(25, 0,
|
||||
"$$p_win{startx} $$p_win{starty} $$p_win{width} $$p_win{height}");
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,21 +91,21 @@ sub create_box {
|
||||
$h = $$p_win{'height'};
|
||||
|
||||
if ($bool) {
|
||||
addch($y, $x, $$p_win{'tl'});
|
||||
addch($y, $x + $w, $$p_win{'tr'});
|
||||
addch($y + $h, $x, $$p_win{'bl'});
|
||||
addch($y + $h, $x + $w, $$p_win{'br'});
|
||||
hline($y, $x + 1, $$p_win{'ts'}, $w - 1);
|
||||
hline($y + $h, $x + 1, $$p_win{'bs'}, $w - 1);
|
||||
vline($y + 1, $x, $$p_win{'ls'}, $h - 1);
|
||||
vline($y + 1, $x + $w, $$p_win{'rs'}, $h - 1);
|
||||
addch($y, $x, $$p_win{'tl'});
|
||||
addch($y, $x + $w, $$p_win{'tr'});
|
||||
addch($y + $h, $x, $$p_win{'bl'});
|
||||
addch($y + $h, $x + $w, $$p_win{'br'});
|
||||
hline($y, $x + 1, $$p_win{'ts'}, $w - 1);
|
||||
hline($y + $h, $x + 1, $$p_win{'bs'}, $w - 1);
|
||||
vline($y + 1, $x, $$p_win{'ls'}, $h - 1);
|
||||
vline($y + 1, $x + $w, $$p_win{'rs'}, $h - 1);
|
||||
}
|
||||
else {
|
||||
for ($j = $y; $j <= $y + $h; $j++) {
|
||||
for ($i = $x; $i <= $x + $w; $i++) {
|
||||
addch($j, $i, ' ');
|
||||
}
|
||||
}
|
||||
for ($j = $y; $j <= $y + $h; $j++) {
|
||||
for ($i = $x; $i <= $x + $w; $i++) {
|
||||
addch($j, $i, ' ');
|
||||
}
|
||||
}
|
||||
}
|
||||
refresh();
|
||||
}
|
||||
|
@@ -34,7 +34,7 @@ sub print_in_middle {
|
||||
$win = stdscr unless ($win);
|
||||
|
||||
getyx($win, $y, $x);
|
||||
|
||||
|
||||
$x = $startx if ($startx);
|
||||
$y = $starty if ($starty);
|
||||
$width = $COLS unless ($width);
|
||||
|
48
perl/10.pl
48
perl/10.pl
@@ -44,27 +44,27 @@ print_menu($menu_win, $highlight);
|
||||
while (1) {
|
||||
$c = getch($menu_win);
|
||||
if ($c == KEY_UP) {
|
||||
if ($highlight == 1) {
|
||||
$highlight = $n_choices;
|
||||
}
|
||||
else {
|
||||
$highlight--;
|
||||
}
|
||||
if ($highlight == 1) {
|
||||
$highlight = $n_choices;
|
||||
}
|
||||
else {
|
||||
$highlight--;
|
||||
}
|
||||
}
|
||||
elsif ($c == KEY_DOWN) {
|
||||
if ($highlight == $n_choices) {
|
||||
$highlight = 1;
|
||||
}
|
||||
else {
|
||||
$highlight++;
|
||||
}
|
||||
if ($highlight == $n_choices) {
|
||||
$highlight = 1;
|
||||
}
|
||||
else {
|
||||
$highlight++;
|
||||
}
|
||||
}
|
||||
elsif ($c == '\n') {
|
||||
$choice = $highlight;
|
||||
$choice = $highlight;
|
||||
}
|
||||
else {
|
||||
addstr($LINES - 2, 0, "Character pressed is $c");
|
||||
refresh();
|
||||
addstr($LINES - 2, 0, "Character pressed is $c");
|
||||
refresh();
|
||||
}
|
||||
print_menu($menu_win, $highlight);
|
||||
last if ($choice);
|
||||
@@ -83,15 +83,15 @@ sub print_menu {
|
||||
$y = 2;
|
||||
box($menu_win, 0, 0);
|
||||
for ($i = 0; $i < $n_choices; $i++) {
|
||||
if ($highlight == $i + 1) {
|
||||
attron($menu_win, A_REVERSE);
|
||||
addstr($menu_win, $y, $x, $choices[$i]);
|
||||
attroff($menu_win, A_REVERSE);
|
||||
}
|
||||
else {
|
||||
addstr($menu_win, $y, $x, $choices[$i]);
|
||||
}
|
||||
$y++;
|
||||
if ($highlight == $i + 1) {
|
||||
attron($menu_win, A_REVERSE);
|
||||
addstr($menu_win, $y, $x, $choices[$i]);
|
||||
attroff($menu_win, A_REVERSE);
|
||||
}
|
||||
else {
|
||||
addstr($menu_win, $y, $x, $choices[$i]);
|
||||
}
|
||||
$y++;
|
||||
}
|
||||
refresh($menu_win);
|
||||
}
|
||||
|
Reference in New Issue
Block a user