zsh-users
 help / color / mirror / code / Atom feed
From: Nikolai Weibull <mailing-lists.zsh-users@rawuncut.elitemail.org>
To: Zsh Users <zsh-users@sunsite.dk>
Subject: [ANN] zap-0.1.0
Date: Mon, 5 Sep 2005 14:20:49 +0200	[thread overview]
Message-ID: <20050905122049.GC8837@puritan.pnetwork> (raw)

[-- Attachment #1: Type: text/plain, Size: 948 bytes --]

As a sort of semi-response to DervishD's refactoring thread, I'm proud
to announce my initial release of the Zsh Application Protocol (ZAP).
There's not really a lot of code in this package yet, but it provides a
comfortable framework for writing quick hacks that nevertheless act like
real applications, with nicely formatted --help output and easy-to-use
options specification.

I've also attached a sample application, which is nothing but a rewrite
of the Workspace manager for the Ratpoison window manager.  Beyond that
the documentation is non-existant, but I'll write something up if anyone
seems to care about it.

Anyway, I hope that this may be useful and if it is I'll put some more
work into it for a 0.2 release,
        nikolai

-- 
Nikolai Weibull: now available free of charge at http://bitwi.se/!
Born in Chicago, IL USA; currently residing in Gothenburg, Sweden.
main(){printf(&linux["\021%six\012\0"],(linux)["have"]+"fun"-97);}

[-- Attachment #2: zap-0.1.0.tar.gz --]
[-- Type: application/x-tar-gz, Size: 2713 bytes --]

[-- Attachment #3: rpws --]
[-- Type: text/plain, Size: 2800 bytes --]

#! /bin/zsh
# contents: Workspace script for ratpoison(1) window manager.
# arch-tag: 18711864-f9c7-4a47-99f6-63d2673c26fd 
#
# Copyright (C) 2003 Shawn Betts
# Copyright (C) 2004 Nikolai Weibull <source@pcppopper.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA



setopt extendedglob

autoload -U zap-init
zap-init $0:t "1.0.0" 

SELF=$0
RATPOISON=ratpoison
FRAMES=(
  "(frame :number 0 :x 242 :y 3 :width 796 :height 1018)"
)
local -a optdesc
optdesc=(
  ''  ''        ' [WORKSPACE]'                                      ''  0 0 -1
  ''  ''        "Workspace support script for the ratpoison \
X11 window manager."                                                ''  0 0 -1
  -b  --bindings  'set up keyboard bindings for workspace switching' '' 0 0 0
  -i  --initialize 'initialize workspace support'                   ''  0 0 0
  ''  'WORKSPACE' 'workspace to switch to'                          ''  0 0 0
)



rp-call () {
  $RATPOISON -c "$*"
}


select-workspace () {
  rp-call gselect ${${1/#/ws}:/ws1/default}
  rp-call frestore $(rp-call getenv fs$1)
  rp-call setenv ws $1
}


save () {
  rp-call setenv fs$(rp-call getenv ws) $(rp-call fdump)
}


restore () {
  save $1
  rp-call echo Workspace $1
  select-workspace $1
}


initialize-workspace () {
  (( $1 != 1 )) && rp-call gnew ws$1

  rp-call setenv fs$1 ${FRAMES[$1]:-$(rp-call fdump)}
}


initialize () {
  rp-call select -
  rp-call only

  for i in {1..6}; do
    initialize-workspace $i
  done

  select-workspace 1
}


bindings () {
  rp-call bind M-1 exec $SELF 1
  rp-call bind M-2 exec $SELF 2
  rp-call bind M-3 exec $SELF 3
  rp-call bind M-4 exec $SELF 4
  rp-call bind M-5 exec $SELF 5
  rp-call bind M-6 exec $SELF 6
}


zap-parse-options optdesc "$@"
(( $ZAP_OPTIONS[(I)--bindings] || $ZAP_OPTIONS[(I)-b] )) && bindings
(( $ZAP_OPTIONS[(I)--initialize] || $ZAP_OPTIONS[(I)-i] )) && initialize
if (( $#ZAP_ARGUMENTS > 0)); then
  for workspace in "$ZAP_ARGUMENTS[@]"; do
    if [[ $workspace == <1-6> ]]; then
      restore $workspace
    else
      zap-error 1 "unrecognized workspace:" "    workspace: $workspace"
    fi
  done
fi



# vim: set sts=2 sw=2:

             reply	other threads:[~2005-09-05 12:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-05 12:20 Nikolai Weibull [this message]
2005-09-05 14:07 ` DervishD

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050905122049.GC8837@puritan.pnetwork \
    --to=mailing-lists.zsh-users@rawuncut.elitemail.org \
    --cc=zsh-users@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).