zsh-users
 help / color / mirror / code / Atom feed
* [ANN] zap-0.1.0
@ 2005-09-05 12:20 Nikolai Weibull
  2005-09-05 14:07 ` DervishD
  0 siblings, 1 reply; 2+ messages in thread
From: Nikolai Weibull @ 2005-09-05 12:20 UTC (permalink / raw)
  To: Zsh Users

[-- 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:

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [ANN] zap-0.1.0
  2005-09-05 12:20 [ANN] zap-0.1.0 Nikolai Weibull
@ 2005-09-05 14:07 ` DervishD
  0 siblings, 0 replies; 2+ messages in thread
From: DervishD @ 2005-09-05 14:07 UTC (permalink / raw)
  To: Zsh Users

    Hi Nikolai :)

 * Nikolai Weibull <mailing-lists.zsh-users@rawuncut.elitemail.org> dixit:
> 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).

    Not exactly what I need, but I've took a look and your option
parsing routine is quite good, I'm going to stea^H^H^H^Hborrow it ;)

    Raúl Núñez de Arenas Coronado

-- 
Linux Registered User 88736 | http://www.dervishd.net
http://www.pleyades.net & http://www.gotesdelluna.net
It's my PC and I'll cry if I want to...


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-09-05 14:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-09-05 12:20 [ANN] zap-0.1.0 Nikolai Weibull
2005-09-05 14:07 ` DervishD

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).