Fixes for cross compiling under modern Linux
Repair GTK timer handling

The bug eventually makes PuTTY take 100% of a CPU.

1) This patch stops run_timers returning with a next timer interval
of zero ms.

2) The code called from run_timers is likely to create a new timer
when it runs before timer_trigger adds the next timer that run_timers
returns. This would mean that two timers get scheduled with gtk.

3) Alter terminal.c to turn off the text blink timer when we don't
have focus and turn it on, synched with the cursor when we get it back.

NB: Windows calls 'term_set_focus' a lot .. Yes you still have focus
Pango font performance update

This change improves the speed of the best case pango font
processing.  It removes multiple calls to pango_layout_set_text and
pango_layout_get_pixel_extents that were used to check that every prefix
string of a given draw_text is actually the correct size.

Instead the function now checks just once before painting the text
that the size of the whole region is correct. If it's not correct it
falls back to painting one character at a time immediatly rather than
optimistically trying lots of substrings; this normally improves the
draw time of complex screens and proportional fonts too.

If there are compensating layout issues within the string they won't
cause problems because terminal.c already has code to redraw any row
of text that was drawn as one operation if it's split.
Windows font drawing performance upgrade.

Two issues here.

Firstly. Windows is getting slower at drawing characters to the screen,
so much so that sometimes it overruns the time limits and eats into
the time that we should be using to process characters received from
the host. So add a change to make do_paint not accept a redraw request
until there has been 'enough' time since the last one.

In addition the WM_PAINT message has been being used to directly draw
characters to the screen. Because of issues with some machines this can
cause screen corruption (white lines).

Note: not all the corruption is cured by this patch as it stands; white
marks can still occur in the border area and the scroll bar.

With Windows 7 this has become mostly irrelevent as, usually, windows
will now 'save-unders' for the transparency.

Tested on W95 OSR2, W2k SP4, WXP SP3, WXP64 SP2, Win7 SP1.
Timer starving fix

If the remote (or pty for pterm) is giving us data very quickly it can
stop the timers being called. This makes sure we check the timers even
if we're very busy with characters from the host.
Minimise, maximise, etc are as annoying as other terminal resize operations.

Note they ARE resize operations so treat them as such and disable them
if requested.
Add XTerm extensions for DECCOLM and reverse BS

Codes to enable and disable the DECCOLM 132/80 column switching DEC
control and XTerm's reverse BS code.

This allows a vttest pass and prevents the xterm 'init' sequence
from terminfo clearing the screen.

Most applications realise that terminal resizes are requests and that
you likely won't get what you ask for.  Programs (like vttest) that use
the sequence DECCOLM aren't so smart so the change is immediatly enacted.
Adjust DEC-MCS character set.

U+2426 "␦" is defined as the substitution character in DEC-MCS

Note: dec_mcs is a 94 character set so 0xA0 and 0xFF are not defined in
a different way when it's mapped into GR.
Optimisation to delete windows code on unix

Changed is_dbcs_leadbyte to a macro on unix so the compiler knows
it's always zero.
This is a fix for the direct to font DBCS cursor.

If we're sitting on a DBCS lead byte it extends the cursor to two
characters rather then just one.
Windows codepages do not have C1 controls
Function x11font_draw_text uses the UCS2 character set
SCO Ansi Keyboard correction
UTF8 Window title on windows.

The used character set will ALWAYS be UTF8
Readme for github

A .gitignore file and a working makefile with proper cleanup
Changes to the internal usage of unicode areas for character set conversion.

The unix port is using the U+D800 range for the same jobs as the windows
port uses the U+F100 range. Set it to use the same range of characters.

Note: unlike windows this is ONLY used if the font doesn't have a
recognised character set so this change doesn't make the DTF range
compatible with the Linux console.

In a similar issue terminal.c is using the CSET_* codes for two different
tasks; the screen map characters and the line characters. Making the
distinction explicit should clarify things.

We now have a 32bit space for the characters so the hack of placing
the CSET_* code overlapping the surrogates is no longer required. We
can instead place them past the end of the valid unicode characters
(ie U+180000). Note I've chosen 0x180000 rather than 0x200000 to preserve
the compression of the scrollback.

Unfortunatly I can't do the same for the DTF range as it wouldn't work
for the UTF-16 platform. I can, however, move it to the "Low Surrogates"
area where it shouldn't interfere with the normal use of surrogates.

Added Linux DTF range (U+F000 -> CP437) explicitly into the emulation
because we no longer have the "happy coincidence" of the OEMCP being
mapped to U+F000. This means it could now be disabled for pure utf8 mode.
UTF8 Update
This patch adds ANSI.SYS, SCO Xenix 2.3.2 and a general ANSI emulation.

The SCO Xenix is a well defined but rather old style emulation similar
in many respects to the ANSI.SYS emulation but a bit nicer. The later
SCO Unix variants are far more uncertain as they cover may versions of
SCO Unix where the emulation was changed to maintain or provide minimal
compatibility with other systems.

In the SCO Xenix emulation I have assumed the mapchan(1) facility has
been used to set the default character set to the putty line codepage. So
if your application assumes the mapchan process hasn't been run you will
need to set the line charset to CP437. The ANSI.SYS emulation forces CP437.

echo -e '\e[4040"p'   # Set normal PuTTY (xterm) mode.
echo -e '\e[4041"p'   # Set modern Ansi mode, all available non VT sequences.
echo -e '\e[4042"p'   # Set ANSI.SYS emulation
echo -e '\e[4043"p'   # Set SCO Xenix

echo -e '\e[4030"p'   # Set pure VT52 mode
echo -e '\e[4031"p'   # Set pure VT220+ mode

These and all the compatibility stuff can be turned off using the compile
option DISABLE_COMPAT. Note, CSI 4030"p turns off _nearly_ all the CSI
sequences, the exception being ones that begin "ESC [ 404".
The SCO emulation overrides the configured function key definitions.

The SCO Xenix emulation does not have the reverse or graphic attribute
variables. However, I do have full details if these are needed.

Attributes DIM and CONCEAL have been added. Concealed text is shown by
highlighting it with the mouse.

Altered CSI 21m to be dup of CSI 22m; I didn't know about this convention
when I chose to use single underline as a near enough equlivent to
double underline.

The SCO ACS character set on unix has been fixed; added the OEM glyphs
for characters 1..31.
The default SCO mapping for the number pad '5' key has been fixed.
The ECMA-48 'REP' code, repeat character has been added.
I've added SCO's new CSI 13m mode and the CSI=g code.
Removed the supposedly SCO CSI 6m.
Linux CSI 8 ] for default colours. CSI 8 ; 1 ] to reset.
Added CSI 8 ; 2 ] to reconfigure the default colours and the BLINK
attribute to blink any other attribute.

In ANSI.SYS mode CSI-J homes cursor.

Added XTerm's vttest modes; CSI ?40 l/h & CSI ?45 l/h
    This means DECCOLM is disabled by default and stops xterm's "tput init"
    clearing the screen.

Default blink now to DIM not blank, set with:
   echo -e '\e[0;2m\e[8;2]\e[m'
Set back to PC Style with:
   echo -e '\e[0;8m\e[8;2]\e[m'

I haven't added GUI configs for any of this; don't know which you'd prefer.
    Possibilities:
	Terminal Type: xterm/ansi/ansisys/scoansi/vt220/vt52
	Blink attribute: Dim/Conceal/Reverse ...

I've had to move the literal character display into it's own function
so I can call it from multiple places.

Readded Linux DTF range (U+F000 -> CP437) explicitly into the emulation.
This means I no longer need the "happy coincidence" of the OEMCP being
mapped to U+F000.

Cleaned out "vt52_bold" variable; it does nothing.

Some small updates to the emulation.

Added a config and setting to control the text blinking style then removed
the CSI sequence.

Some cleanups to the emulation switching.

UTF8 as a line codepage is supported better now.
UTF8 locking is gone completely; use the no_remote_charset_switching
Follow the locale in a slightly different way

The config dialog works on windows, but it's too big.
Adding better support for some Chinese character sets

Adding better support for some 国家标准 character sets. (ie Chinese standard
character sets)

This does NOT need a specific font as long as the unicode system can find the
requsite characters.

Note the change in the defaults; it is now reccomended to explicitly
specify the line character set for DBCS systems.

Also added a few Windows charsets and moved UTF-8 right to the top of
the list.
Reconfigure PuTTY colour scheme from Unix host.

This is possibly related to: /wishlist/colour-scheme.html

These colour schemes are not stored in the PuTTY session file and so
have to be dynamically configured from the host.

The script can read the colour scheme from a Windows PuTTY registry
dump or a Unix session file.