screen-devel
[Top][All Lists]
Advanced

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

[screen-devel] alias support for GNU Screen


From: Steve Kemp
Subject: [screen-devel] alias support for GNU Screen
Date: Sat, 18 Oct 2008 22:23:43 +0100
User-agent: Mutt/1.5.17+20080114 (2008-01-14)

  I've recently put together a few new features and updates
 for GNU Screen, in a (transient?) fork called tscreen[0].  This
 is primarily because I've always had the belief that GNU Screen
 was not being actively developed - but also because there are
 things that I personally would like to see added, changed, or
 dropped.

  One of the most interesting new features is the ability to
 define aliases.  In my current implementation there are two
 kinds of aliases:

    1.  Mere synonyms.
    2.  Constant calls to other functions with a list of arguments.

  As an example the following makes "shout" an alias for "echo":

  alias shout echo

  A more interesting alias is one with some actual activity behind
 it.  This is a typical example in four parts:

#
#  1. Caption toggle
#
alias caption_off  eval "caption splitonly"
alias caption_on   eval "caption always"

#
#  2. Statusbar toggle
#
alias status_off   eval "hardstatus ignore"
alias status_on    eval "hardstatus alwayslastline"


#
#  3. Disable both caption and status, and show a message.
#
alias fullscreen   eval "status_off" "caption_off" "echo 'fullscreen - \"Ctrl-a 
F\" to return'"
alias captioned    eval "status_on"  "caption_on"  "echo 'fullscreen - \"Ctrl-a 
f\" for fullscreen'"


#
#  4. Bind the keys
#
bind f eval fullscreen
bind F eval captioned


  In terms of implementation the code is pretty straightforward, and
 some of the actual details show through.  We maintain a global linked
 list of aliases.

  The structure is :

/*
 * Command aliases.
 */
struct alias {
  /* next in our linked list */
  struct alias *next;
  char *alias_name;
  char *alias_value;
  int  alias_arg_count;
  char **alias_args;
};

  For the simple case we have an entry of the form:
    
    alias{
    alias_name => "shout",
    alias_value => "echo",
    }

  For a more complex case we'd have this:

    alias{
    alias_name => "fullscreen"
    alias_value => "eval",
    alias_args => [ "status_off", "caption_off", "echo 'blah'" ],
    alias_args_count => 3
  }

  As you can see this alias is in two parts:

    1.  It defines "fullscreen" as actually invoking "eval".
    2.  When fullscreen is called it will invoke eval with the
       list of three arguments we've been passed at create time.

  Anyway, Juergen Weigert, suggested I drop the list a mail with
 a couple of comments.  I hope this serves as a suitable introduction,
 and the patch is attached - against the current git tree.

Steve
-- 
Managed Anti-Spam Service
http://mail-scanning.com/


 0 - http://www.steve.org.uk/Software/tscreen/


Attachment: alias.diff
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]