Package: mytop
Version: 1.6
Severity: normal
Tags: patch

see attache

Recently I've begun to use mytop. Everything is very comfortable except
the fact that the terminal flickers when repainting. I've written the
patch removing this effect.

Unfortunately I can't test it on many platforms so I've realised it as
an additional option --vt100.
--- mytop	2008-04-09 12:14:52.000000000 +0400
+++ mytop	2008-04-09 14:10:25.000000000 +0400
@@ -76,6 +76,7 @@
 ## Default Config Values
 
 my %config = (
+    vt100         => 0,
     batchmode     => 0,
     color         => 1,
     db            => 'test',
@@ -107,6 +108,13 @@
 
 my $CLEAR = $WIN ? '': `clear`;
 
+my %vt100_commands=
+(
+  CURSOR_TO_START     => "\x1b[0;0f",
+  CURSOR_SAVE         => "\x1b[s",
+  CURSOR_RESTORE      => "\x1b[u",
+);
+
 ## Term::ReadKey values
 
 my $RM_RESET   = 0;
@@ -143,6 +151,7 @@
 Getopt::Long::Configure('no_ignore_case', 'bundling');
 
 GetOptions(
+    "vt100"               => \$config{vt100},
     "color!"              => \$config{color},
     "user|u=s"            => \$config{user},
     "pass|password|p=s"   => \$config{pass},
@@ -161,6 +170,8 @@
     "sort=s"              => \$config{sort},
 );
 
+-t STDOUT or $config{vt100}=undef;
+
 ## User may have put the port with the host.
 
 if ($config{host} =~ s/:(\d+)$//)
@@ -685,6 +696,13 @@
     }
 }
 
+sub CursorToStartNotClear()
+{
+  $config{vt100} or return Clear;
+  $WIN and return Clear;
+  print $vt100_commands{CURSOR_TO_START};
+}
+
 my $last_time;
 
 sub GetData()
@@ -813,7 +831,7 @@
         my $host_width = 52;
         my $up_width   = $width - $host_width;
 
-        Clear() unless $config{batchmode};
+        CursorToStartNotClear() unless $config{batchmode};
         print RESET();
 
         printf "%-${host_width}s%${up_width}s\n",
@@ -899,7 +917,7 @@
 
     if (not $config{batchmode} and not $config{header})
     {
-        Clear();
+        CursorToStartNotClear();
         print RESET();
     }
 
@@ -1059,6 +1077,13 @@
 
     }
 
+    
+    if ($config{vt100} and not $config{batchmode})
+    {
+      print $vt100_commands{CURSOR_SAVE};
+      print join "\n", (" "x$width)x($lines_left+2);
+      print $vt100_commands{CURSOR_RESTORE};
+    }
 }
 
 ###########################################################################
@@ -1706,6 +1731,11 @@
 Use if you'd like B<mytop> to connect to a specific database by
 default. Default: ``B<test>''.
 
+=item B<--vt100>
+
+For  screen re-drawing use esc-sequence vt100. It is remove terminal 
+twinkling.
+
 =item B<-b> or B<--batch> or B<--batchmode>
 
 In batch mode, mytop runs only once, does not clear the screen, and

Attachment: signature.asc
Description: Digital signature

Reply via email to