~helmut/tcvt.git
23 months agoimplement "el" family properly master
Helmut Grohne [Fri, 3 Nov 2017 21:23:59 +0000 (22:23 +0100)]
implement "el" family properly

el0 simply is el.

el1 was implemented improperly and missed clearing the character under
the cursor.

el2 clears the whole line.

2 years agoimplement cursor position reporting (u7)
Helmut Grohne [Tue, 10 Jan 2017 11:37:07 +0000 (12:37 +0100)]
implement cursor position reporting (u7)

This is used by a number of programs (including vim) to determine utf8
terminal capabilities.

The feed functions now return none or a bytes object. If a bytes object
is returned, it is sent back to the requesting program.

2 years agoimprove corner cases related to resizing and mode switching
Helmut Grohne [Thu, 5 Jan 2017 19:26:13 +0000 (20:26 +0100)]
improve corner cases related to resizing and mode switching

A few operations would previously fail unexpectedly:
 * Running tcvt with many columns and a small terminal width would crash
   instead of falling back to a simple screen.
 * After switching the mode, column ordering would be lost.
 * Switching the mode from simple to columns after resizing could result
   in a crash.

Instead of collecting the screen options and passing them down
individually, the Terminal class now asks for a preconfigured screen
factory. This should eliminate future potential for similar mistakes.

2 years agofix broken color handling
Helmut Grohne [Mon, 19 Dec 2016 19:13:21 +0000 (20:13 +0100)]
fix broken color handling

When printing "\e[32mx\e[33mx\e[32mx\e[0m", the expected outcome is that
the first and third x share the same color. Prior to clearing A_COLOR,
the colors would be ORed yielding three different colors. This breaks
e.g. usage with mutt.

2 years agoremove unused inch method
Helmut Grohne [Thu, 15 Dec 2016 09:21:42 +0000 (10:21 +0100)]
remove unused inch method

The last user got removed with 458ccd1cdc60 ("fix rendering of alternate
font for ncmpc").

2 years agofix SIGWINCH race condition during startup
Helmut Grohne [Wed, 14 Dec 2016 09:08:44 +0000 (10:08 +0100)]
fix SIGWINCH race condition during startup

Some programs (e.g. ncmpc) do not like receiving a terminal of unknown
size. Before we issue the resizepty method that would be the case. Since
there was no synchronisation between resizepty and execvp, a program
that starts quickly could run into this situation. Now we ensure that
resizepty is called before execvp using an extra pipe.

2 years agonote known breakage with FreeBSD's curses
Helmut Grohne [Mon, 12 Dec 2016 19:33:48 +0000 (20:33 +0100)]
note known breakage with FreeBSD's curses

On FreeBSD, curses.tigetstr('acsc') will return None unless Python is
built against ncurses.

Reported-By: Klaus Aehlig <aehlig@linta.de>
2 years agoMake tcvt aware of the OSC sequences
Klaus Aehlig [Tue, 28 Jun 2016 08:39:56 +0000 (10:39 +0200)]
Make tcvt aware of the OSC sequences

Ansi is vague about the meaning of the OSC sequences (i.e.,
the control sequences starting with <esc> ]): the interpretation is
up to the operating system. Nevertheless, some programs send these
sequences, most prominently the one to set the terminal title (OSC 0;).
So make tcvt aware of those sequences and pass them through.

Signed-off-by: Helmut Grohne <helmut@subdivi.de>
2 years agoconvert more branches into table lookups
Helmut Grohne [Sat, 10 Dec 2016 06:26:38 +0000 (07:26 +0100)]
convert more branches into table lookups

2 years agoprecompute lookup tables
Helmut Grohne [Sat, 10 Dec 2016 05:48:38 +0000 (06:48 +0100)]
precompute lookup tables

This improves performance of output-heavy workloads (e.g. the time it
takes to run find on a large tree) by 10% on CPython 2.7.

2 years agofix adding characters at the end of the window
Helmut Grohne [Fri, 9 Dec 2016 20:14:16 +0000 (21:14 +0100)]
fix adding characters at the end of the window

When the number of columns wasn't exactly 2 (the default), adding a
character at the end of the window could fail at scrolling thus yielding
corrupted output.

2 years agopush the refresh logic into the Terminal class
Helmut Grohne [Fri, 9 Dec 2016 10:54:25 +0000 (11:54 +0100)]
push the refresh logic into the Terminal class

One advantage of doing so is that the main function becomes simpler.
Another advantage is that the Terminal class has better knowledge of
when refreshes are actually needed. It also means that one more refresh
call can be coalesced into the logic. The major downside is that it
requires annotating all screen operations.

2 years agoimprove sub process handling: return child exit code
Helmut Grohne [Fri, 9 Dec 2016 09:29:55 +0000 (10:29 +0100)]
improve sub process handling: return child exit code

Wrap the management of the sub process in a new class ForkPty. This
reduces the length and number of variables in the main function. Turn it
into a context manager to allow closing the masterfd and actually
waiting for the forked child (rather than reparenting it to init on
exit). This also allows propagating the exit code. Document the new exit
semantics.

2 years agosimplify Terminal start and stop using a context manager
Helmut Grohne [Fri, 9 Dec 2016 08:15:14 +0000 (09:15 +0100)]
simplify Terminal start and stop using a context manager

4 years agofix manual page syntax
Helmut Grohne [Thu, 7 May 2015 14:24:36 +0000 (16:24 +0200)]
fix manual page syntax

Reported-By: Alfredo Canziani <alfredo.canziani@gmail.com>
4 years agoAdd an option to reverse the column order
Klaus Aehlig [Tue, 5 May 2015 21:58:37 +0000 (23:58 +0200)]
Add an option to reverse the column order

In this way, for long dialoges (e.g., shell, ed) the focus
is in the lower left corner of the screen---the same as for
one-column terminals. Therefore, users used to that focus
can use this option to avoid changing reading habits.

4 years ago"\b" is also known as cub1
Helmut Grohne [Mon, 9 Feb 2015 22:06:31 +0000 (23:06 +0100)]
"\b" is also known as cub1

6 years agoname two more terminal functions hpa and vpa
Helmut Grohne [Sat, 22 Jun 2013 10:26:31 +0000 (12:26 +0200)]
name two more terminal functions hpa and vpa

6 years agosupport attributes blink and invis
Helmut Grohne [Sat, 22 Jun 2013 09:53:53 +0000 (11:53 +0200)]
support attributes blink and invis

6 years agoconfused terminfo "ind" and "ht"
Helmut Grohne [Thu, 20 Jun 2013 20:06:11 +0000 (22:06 +0200)]
confused terminfo "ind" and "ht"

6 years agouse terminfo capability names
Helmut Grohne [Thu, 20 Jun 2013 18:29:10 +0000 (20:29 +0200)]
use terminfo capability names

Implement terminfo capabilities as do_CAP on the Terminal class. This is
a bit more generic and might allow to pull the parsing from terminfo at
some point.

6 years agouse bytearrays
Helmut Grohne [Thu, 20 Jun 2013 11:47:46 +0000 (13:47 +0200)]
use bytearrays

With bytearrays there is no need for hacks specific to the Python
version such as byte_sequence.

6 years agoadd mappings for Fn keys
Helmut Grohne [Mon, 3 Jun 2013 06:43:08 +0000 (08:43 +0200)]
add mappings for Fn keys

We don't gain anything here, because the emulated terminal does not
support these keys. Should we switch the emulated terminal, this
immediately helps.

6 years agoclear screen on WINCH
Helmut Grohne [Mon, 3 Jun 2013 06:20:57 +0000 (08:20 +0200)]
clear screen on WINCH

Most applications do a full redraw on WINCH anyway. A shell doesn't and
looks ugly.

6 years agofix WINCH handling
Helmut Grohne [Sun, 2 Jun 2013 13:36:11 +0000 (15:36 +0200)]
fix WINCH handling

 * The switch to single column on WINCH was a bad idea.
 * The new window would get old dimensions, because we would
   reinitialize windows before curses noticed the new dimensions.

6 years agoallow specifying the number of columns
Helmut Grohne [Sun, 2 Jun 2013 12:03:09 +0000 (14:03 +0200)]
allow specifying the number of columns

6 years agomanpage: explain TCVT_DEVEL variable
Helmut Grohne [Sun, 2 Jun 2013 11:26:07 +0000 (13:26 +0200)]
manpage: explain TCVT_DEVEL variable

6 years agosupport python3.3
Helmut Grohne [Sun, 2 Jun 2013 11:19:30 +0000 (13:19 +0200)]
support python3.3

6 years agosupport not crashing on unsupported sequences
Helmut Grohne [Sun, 2 Jun 2013 10:44:27 +0000 (12:44 +0200)]
support not crashing on unsupported sequences

6 years agoimplement full alternate character set
Helmut Grohne [Sun, 2 Jun 2013 08:52:32 +0000 (10:52 +0200)]
implement full alternate character set

We now get the characters from terminfo "acsc".

6 years agoadd new input mode feed_graphics
Helmut Grohne [Sun, 2 Jun 2013 08:03:59 +0000 (10:03 +0200)]
add new input mode feed_graphics

Thereby we avoid accidentally treating graphics chars as regular chars,
just because they were not yet implemented.

6 years agoadded more line drawing characters
Helmut Grohne [Sat, 1 Jun 2013 19:36:00 +0000 (21:36 +0200)]
added more line drawing characters

This makes aptitude work.

Reported-By: Axel Beckert
6 years agoadded a README
Helmut Grohne [Sat, 1 Jun 2013 13:52:01 +0000 (15:52 +0200)]
added a README

6 years agoswallow exceptions for unknown keys
Helmut Grohne [Sat, 2 Feb 2013 00:22:42 +0000 (01:22 +0100)]
swallow exceptions for unknown keys

Most often this feature comes at an inconvenient time. If a key turns
out dysfunctional, export TCVT_DEVEL=1 to see the value of the key.

6 years agoif argv is empty, start a $SHELL
Helmut Grohne [Sat, 2 Feb 2013 00:09:08 +0000 (01:09 +0100)]
if argv is empty, start a $SHELL

7 years agosupport more than two columns
Helmut Grohne [Mon, 27 Aug 2012 12:39:24 +0000 (14:39 +0200)]
support more than two columns

The TwoColumn class is renamed to Columns since it now has a
configurable number of columns. Note that this support is not to the
command line yet.

7 years agomanpage: mention homepage
Helmut Grohne [Sun, 15 Apr 2012 12:53:44 +0000 (14:53 +0200)]
manpage: mention homepage

7 years agotcvt: code cleanup using properties
Helmut Grohne [Sun, 15 Apr 2012 12:28:45 +0000 (14:28 +0200)]
tcvt: code cleanup using properties

7 years agoMakefile: don't fail to install twice
Helmut Grohne [Sun, 15 Apr 2012 11:55:41 +0000 (13:55 +0200)]
Makefile: don't fail to install twice

7 years agoprint a reasonable error message when exec fails
Helmut Grohne [Sun, 15 Apr 2012 11:54:30 +0000 (13:54 +0200)]
print a reasonable error message when exec fails

7 years agoadded manual page tcvt.1
Helmut Grohne [Sun, 15 Apr 2012 11:25:21 +0000 (13:25 +0200)]
added manual page tcvt.1

8 years agosupport outputting ACS_VLINE
Helmut Grohne [Tue, 4 Oct 2011 16:46:48 +0000 (18:46 +0200)]
support outputting ACS_VLINE

This enables running tcvt inside tcvt resulting in four non-linearly
ordered columns.

8 years agoreduce screen.refresh()
Helmut Grohne [Fri, 30 Sep 2011 08:22:57 +0000 (10:22 +0200)]
reduce screen.refresh()

Previously it would refresh after at most 1024 bytes of output. With a
slow terminal and much output this can be very annoying. So now we only
refresh when there is no more output or a tenth of a second has passed
since the last output.

8 years agofixed enter key in vim
Helmut Grohne [Wed, 14 Sep 2011 20:47:16 +0000 (22:47 +0200)]
fixed enter key in vim

8 years agopass through \xb4 (some tick) and \xe9 (accent e)
Helmut Grohne [Fri, 22 Jul 2011 16:08:41 +0000 (18:08 +0200)]
pass through \xb4 (some tick) and \xe9 (accent e)

8 years agoimplement \t output
Helmut Grohne [Wed, 8 Jun 2011 08:43:59 +0000 (10:43 +0200)]
implement \t output

8 years agoadded Makefile for easy installation
Helmut Grohne [Sun, 27 Feb 2011 16:16:12 +0000 (17:16 +0100)]
added Makefile for easy installation

8 years agoadded optcvt.sh
Helmut Grohne [Sat, 26 Feb 2011 15:45:20 +0000 (16:45 +0100)]
added optcvt.sh

Executes tcvt iff the resulting width is at least 80 chars.

8 years agofix rendering of alternate font for ncmpc
Helmut Grohne [Sat, 26 Feb 2011 13:54:19 +0000 (14:54 +0100)]
fix rendering of alternate font for ncmpc

8 years agouse tigetstr to resolve ansi key sequences
Helmut Grohne [Sat, 26 Feb 2011 13:11:07 +0000 (14:11 +0100)]
use tigetstr to resolve ansi key sequences

8 years agoproperly process input keys with curses' getch
Helmut Grohne [Sat, 26 Feb 2011 12:57:53 +0000 (13:57 +0100)]
properly process input keys with curses' getch

8 years agoinitial checkin
Helmut Grohne [Sat, 26 Feb 2011 12:35:23 +0000 (13:35 +0100)]
initial checkin