Allow compatbility with classic sam. - sam - An updated version of the sam text editor.
 (HTM) git clone git://vernunftzentrum.de/sam.git
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) LICENSE
       ---
 (DIR) commit c65a7e677c730a320d34b7c7b630e975d141fad9
 (DIR) parent 8cfd5730916941d0a11e24a3152898fc0e9b1091
 (HTM) Author: Rob King <jking@deadpixi.com>
       Date:   Thu,  1 Sep 2016 22:31:32 -0500
       
       Allow compatbility with classic sam.
       
       Diffstat:
         README.rst                          |       3 ++-
         config.h.def                        |       6 ++++++
         sam/mesg.c                          |      14 ++++++++++++--
         sam/mesg.h                          |       6 ++++++
         sam/moveto.c                        |       5 ++++-
         samterm/main.c                      |      35 +++++++++++++++++++++++++------
         samterm/mesg.c                      |       8 ++++++--
       
       7 files changed, 65 insertions(+), 12 deletions(-)
       ---
 (DIR) diff --git a/README.rst b/README.rst
       @@ -105,7 +105,8 @@ Multicolor Support
        
        Simplified and Dynamic Configuration
            The graphical elements (colors and fonts) of this version of sam are controlled via environment variables, not X Resources.
       -    The table of composable characters is now dynamically configurable (via the `~/.keyboard` file), where it was once hard-coded.
       +    The table of composable characters is now dynamically configurable (via the `~/.keyboard` file),
       +    where it was once hard-coded.
        
        Far Better Keyboard Support
            The selection ("cursor") can be moved using keyboard commands.
 (DIR) diff --git a/config.h.def b/config.h.def
       @@ -4,6 +4,12 @@
        /* Where to put temporary files. */
        #define TMPDIR "/tmp"
        
       +/* Define this if you need compatibility with the binary protocol
       + * used by classic sam (e.g. if you are going to be running a classic
       + * sam binary and a Deadpixi samterm, or vice-versa.
       +#define CLASSIC_SAM_COMPATIBILITY
       + */
       +
        /* Is the target 64-bits?
         * 0 - build for 32-bit systems
         * 1 - build for 64-bit little-endian systems
 (DIR) diff --git a/sam/mesg.c b/sam/mesg.c
       @@ -1,5 +1,6 @@
        /* Copyright (c) 1998 Lucent Technologies - All rights reserved. */
        #include "sam.h"
       +#include "../config.h"
        
        Header        h;
        uchar        indata[DATASIZE];
       @@ -19,6 +20,13 @@ long        invlong(void);
        int        inshort(void);
        int        inmesg(Tmesg);
        void        setgenstr(File*, Posn, Posn);
       +
       +#ifdef CLASSIC_SAM_COMPATIBILITY
       +int oldcompat = 1;
       +#else
       +int oldcompat = 0;
       +#endif
       +
        #ifdef DEBUG
        char *hname[] = {
                [Hversion]        "Hversion",
       @@ -251,9 +259,11 @@ inmesg(Tmesg type)
                        s = inshort(); /* tag */
                        l = inlong(); /* position */
                        l1 = inlong(); /* lines to seek past position */
       -        l2 = inlong(); /* cookie to return (identifies layer) */
                        journaln(0, l1);
       -                journaln(0, l2);
       +        if (!oldcompat){
       +            l2 = inlong(); /* cookie to return (identifies layer) */
       +                    journaln(0, l2);
       +        }
                        lookorigin(whichfile(s), l, l1, l2);
                        break;
        
 (DIR) diff --git a/sam/mesg.h b/sam/mesg.h
       @@ -1,5 +1,11 @@
        /* Copyright (c) 1998 Lucent Technologies - All rights reserved. */
       +#ifdef CLASSIC_SAM_COMPATIBILITY
       +#define VERSION 0
       +#else
        #define        VERSION        16091
       +#endif
       +
       +extern int oldcompat;
        
        #define        TBLOCKSIZE 512                  /* largest piece of text sent to terminal */
        #define        DATASIZE  (UTFmax*TBLOCKSIZE+30) /* ... including protocol header stuff */
 (DIR) diff --git a/sam/moveto.c b/sam/moveto.c
       @@ -58,7 +58,10 @@ lookorigin(File *f, Posn p0, Posn ls, long rl)
                                p0 = 0;
                }else
                        p0 = oldp0;
       -        outTsll(Horigin, f->tag, p0, rl);
       +    if (oldcompat)
       +            outTsl(Horigin, f->tag, p0);
       +    else
       +            outTsll(Horigin, f->tag, p0, rl);
        }
        
        int
 (DIR) diff --git a/samterm/main.c b/samterm/main.c
       @@ -8,6 +8,8 @@
        #include "samterm.h"
        #include <commands.h>
        
       +#include "../config.h"
       +
        extern unsigned long _bgpixel;
        extern void hmoveto(int, long, Flayer *);
        
       @@ -31,6 +33,12 @@ int expandtabs = 0;
        char *machine = "localhost";
        int nofifo = 0;
        
       +#ifdef CLASSIC_SAM_COMPATIBILITY
       +int oldcompat = 1;
       +#else
       +int oldcompat = 0;
       +#endif
       +
        void
        main(int argc, char *argv[])
        {
       @@ -317,10 +325,16 @@ scrorigin(Flayer *l, int but, long p0)
        
                switch(but){
                case 1:
       -                outTslll(Torigin, t->tag, l->origin, p0, t->front);
       +        if (oldcompat)
       +                    outTsll(Torigin, t->tag, l->origin, p0);
       +        else
       +                    outTslll(Torigin, t->tag, l->origin, p0, getlayer(l, t));
                        break;
                case 2:
       -                outTslll(Torigin, t->tag, p0, 1L, t->front);
       +        if (oldcompat)
       +                    outTsll(Torigin, t->tag, p0, 1L);
       +        else
       +                    outTslll(Torigin, t->tag, p0, 1L, getlayer(l, t));
                        break;
                case 3:
                        horigin(t->tag, p0, NULL);
       @@ -386,7 +400,10 @@ center(Flayer *l, long a)
        
            if (!t->lock && (a < l->origin || l->origin + l->f.nchars < a)){
                a = (a > t->rasp.nrunes) ? t->rasp.nrunes : a;
       -        outTslll(Torigin, t->tag, a, 2L, getlayer(l, t));
       +        if (oldcompat)
       +            outTsll(Torigin, t->tag, a, 2L);
       +        else
       +            outTslll(Torigin, t->tag, a, 2L, getlayer(l, t));
                return 1;
            }
        
       @@ -408,7 +425,10 @@ onethird(Flayer *l, long a)
                        lines = ((s.max.y-s.min.y)/l->f.fheight+1)/3;
                        if (lines < 2)
                                lines = 2;
       -                outTslll(Torigin, t->tag, a, lines, t->front);
       +        if (oldcompat)
       +                    outTsll(Torigin, t->tag, a, lines);
       +        else
       +                    outTslll(Torigin, t->tag, a, lines, getlayer(l, t));
                        return 1;
                }
                return 0;
       @@ -459,7 +479,10 @@ static long
        cmdscrollup(Flayer *l, long a, Text *t)
        {
            flushtyping(0);
       -    outTslll(Torigin, t->tag, l->origin, l->f.maxlines + 1, getlayer(l, t));
       +    if (oldcompat)
       +        outTsll(Torigin, t->tag, l->origin, l->f.maxlines + 1);
       +    else
       +        outTslll(Torigin, t->tag, l->origin, l->f.maxlines + 1, getlayer(l, t));
            return a;
        }
        
       @@ -866,7 +889,7 @@ type(Flayer *l, int res)        /* what a bloody mess this is -- but it's getting bette
        
                CommandEntry *e = &commands[k.c];
                if (!e->unlocked || !lock){
       -            if (k.t == Tcurrent)
       +            if (k.t == Tcurrent || oldcompat)
                        a = e->f(l, a, t);
                    else{
                        Flayer *lt = flwhich(k.p);
 (DIR) diff --git a/samterm/mesg.c b/samterm/mesg.c
       @@ -590,8 +590,12 @@ hmoveto(int m, long p0, Flayer *l)
            Text *t = whichtext(m);
            l = l ? l : &t->l[t->front];
        
       -    if (p0 < l->origin || p0 - l->origin > l->f.nchars * 9/10)
       -        outTslll(Torigin, m, p0, 2L, getlayer(l, t));
       +    if (p0 < l->origin || p0 - l->origin > l->f.nchars * 9/10){
       +        if (oldcompat)
       +            outTsll(Torigin, m, p0, 2L);
       +        else
       +            outTslll(Torigin, m, p0, 2L, getlayer(l, t));
       +    }
        }
        
        void