[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#772521: apt: Use more typical escape sequences for save/restore cursor



Package: apt
Version: 1.1~exp8
Severity: wishlist
Tags: patch

Apt's progress reporting uses escape sequences from DOS' ANSI.SYS to
save/restore the cursor position.  I know of at least one terminal that
doesn't recognize those.

The attached patch switches to the DECSC/DECRC[0] escape sequences,
which, from a brief canvas of terminfo,  are the dominant sequences
used.

      5  sc=^],
     19  sc=\036F}10,
      1  sc=^B,
      1  sc=~^E,
    446  sc=\E7,
      8  sc=\Ej,
     18  sc=\E[s,
      3  sc=\E[%y,

      5  rc=^\,
     19  rc=\036F}11,
      1  rc=^C,
      1  rc=\E7,
    556  rc=\E8,
      8  rc=\Ek,
      4  rc=\E[r,
     18  rc=\E[u,
      6  rc=\E[%z,

[0]: http://invisible-island.net/xterm/ctlseqs/ctlseqs.html

-- Package-specific info:

-- (no /etc/apt/preferences present) --


-- (/etc/apt/sources.list present, but not submitted) --


-- System Information:
Debian Release: 8.0
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 3.16.0-4-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages apt depends on:
ii  adduser                 3.113+nmu3
ii  debian-archive-keyring  2014.3
ii  gnupg                   1.4.18-6
ii  gnupg2                  2.0.26-3
ii  libapt-pkg4.15          1.1~exp8
ii  libc6                   2.19-13
ii  libgcc1                 1:4.9.2-5
ii  libstdc++6              4.9.2-5

apt recommends no packages.

Versions of packages apt suggests:
pn  apt-doc     <none>
ii  aptitude    0.6.11-1+b1
ii  dpkg-dev    1.17.22
ii  python-apt  0.9.3.11

-- no debconf information
>From 0aedede7fc2f5739891e7ba68b6f9ab8f03c4635 Mon Sep 17 00:00:00 2001
From: James McCoy <jamessan@debian.org>
Date: Sun, 7 Dec 2014 22:15:36 -0500
Subject: [PATCH] Use terminfo's typical save_cursor/restore_cursor sequences

Not all terminals understand DOS' escape sequences for save/restore
cursor, so use the more typical sequences from terminfo.

Signed-off-by: James McCoy <jamessan@debian.org>
---
 apt-pkg/install-progress.cc | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/apt-pkg/install-progress.cc b/apt-pkg/install-progress.cc
index 5ea8bf4..736b9e2 100644
--- a/apt-pkg/install-progress.cc
+++ b/apt-pkg/install-progress.cc
@@ -285,13 +285,13 @@ void PackageManagerFancy::SetupTerminalScrollArea(int nr_rows)
      std::cout << "\n";
          
      // save cursor
-     std::cout << "\033[s";
+     std::cout << "\0337";
          
      // set scroll region (this will place the cursor in the top left)
      std::cout << "\033[0;" << nr_rows - 1 << "r";
             
      // restore cursor but ensure its inside the scrolling area
-     std::cout << "\033[u";
+     std::cout << "\0338";
      static const char *move_cursor_up = "\033[1A";
      std::cout << move_cursor_up;
 
@@ -373,8 +373,8 @@ bool PackageManagerFancy::DrawStatusLine()
    if (unlikely(size.rows < 1 || size.columns < 1))
       return false;
 
-   static std::string save_cursor = "\033[s";
-   static std::string restore_cursor = "\033[u";
+   static std::string save_cursor = "\0337";
+   static std::string restore_cursor = "\0338";
 
    // green
    static std::string set_bg_color = DeQuoteString(
-- 
2.1.3


Reply to: