mirror of
https://github.com/0intro/wmii
synced 2024-11-25 15:20:15 +03:00
Better rc.wmii menus. Some pseudo-BNF comments for message.c.
This commit is contained in:
parent
e820f41949
commit
19603410f8
@ -55,6 +55,16 @@ fn wi_9menu {
|
||||
-^(sf sb br)^$wmiifocuscol $*
|
||||
}
|
||||
|
||||
fn wi_fnmenu {
|
||||
group=$1^Menu-$2 last=$group^_last fns=`{wi_getfuns $group} {
|
||||
shift 2
|
||||
if(! ~ $#fns 0) {
|
||||
res = `{wi_9menu -initial $"($last) $fns} \
|
||||
if(! ~ $res '') {
|
||||
($last) = $res
|
||||
$group-$res $*}}}
|
||||
}
|
||||
|
||||
fn wi_fn-p {
|
||||
rc -c 'whatis '$1 >[2]/dev/null | grep -s '^fn '
|
||||
}
|
||||
@ -127,6 +137,10 @@ fn wi_tags {
|
||||
wmiir ls /tag | sed 's,/,,; /^sel$/d'
|
||||
}
|
||||
|
||||
fn wi_seltag {
|
||||
wmiir read /tag/sel/ctl | sed 1q
|
||||
}
|
||||
|
||||
fn wi_eventloop {
|
||||
wi_initkeys
|
||||
|
||||
|
@ -194,7 +194,6 @@ client_manage(Client *c) {
|
||||
|| group_leader(c->group) && !client_viewframe(group_leader(c->group), c->sel->view);
|
||||
|
||||
f = c->sel;
|
||||
if(f->view == screen->sel)
|
||||
if(!(c->w.ewmh.type & TypeSplash))
|
||||
if(newgroup) {
|
||||
if(f->area != f->view->sel)
|
||||
@ -903,7 +902,7 @@ client_setviews(Client *c, char **tags) {
|
||||
}
|
||||
|
||||
f = *fp;
|
||||
area_detach(f);
|
||||
view_detach(f);
|
||||
*fp = f->cnext;
|
||||
if(c->sel == f)
|
||||
c->sel = *fp;
|
||||
|
@ -164,8 +164,8 @@ MapEnt* map_get(Map*, ulong, int create);
|
||||
void* map_rm(Map*, ulong);
|
||||
|
||||
/* message.c */
|
||||
int getlong(const char*, long*);
|
||||
int getulong(const char*, ulong*);
|
||||
bool getlong(const char*, long*);
|
||||
bool getulong(const char*, ulong*);
|
||||
char* message_client(Client*, IxpMsg*);
|
||||
char* message_root(void*, IxpMsg*);
|
||||
char* message_view(View*, IxpMsg*);
|
||||
@ -203,6 +203,7 @@ void view_arrange(View*);
|
||||
void view_attach(View*, Frame*);
|
||||
View* view_create(const char*);
|
||||
void view_destroy(View*);
|
||||
void view_detach(Frame*);
|
||||
Area* view_findarea(View*, int, bool);
|
||||
void view_focus(WMScreen*, View*);
|
||||
bool view_fullscreen_p(View*);
|
||||
|
@ -483,7 +483,10 @@ main(int argc, char *argv[]) {
|
||||
|
||||
if(exitsignal)
|
||||
raise(exitsignal);
|
||||
if(execstr)
|
||||
if(execstr) {
|
||||
quotefmtinstall();
|
||||
print("/bin/sh -c %q\n", execstr);
|
||||
execl("/bin/sh", "sh", "-c", execstr, nil);
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
@ -124,12 +124,9 @@ getdebug(char *s) {
|
||||
static int
|
||||
gettoggle(IxpMsg *m) {
|
||||
switch(getsym(msg_getword(m))) {
|
||||
case LON:
|
||||
return On;
|
||||
case LOFF:
|
||||
return Off;
|
||||
case LTOGGLE:
|
||||
return Toggle;
|
||||
case LON: return On;
|
||||
case LOFF: return Off;
|
||||
case LTOGGLE: return Toggle;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
@ -179,52 +176,68 @@ msg_getword(IxpMsg *m) {
|
||||
|
||||
#define strbcmp(str, const) (strncmp((str), (const), sizeof(const)-1))
|
||||
static int
|
||||
getbase(const char **s) {
|
||||
getbase(const char **s, long *sign) {
|
||||
const char *p;
|
||||
int ret;
|
||||
|
||||
ret = 10;
|
||||
*sign = 1;
|
||||
if(**s == '-') {
|
||||
*sign = -1;
|
||||
*s += 1;
|
||||
}else if(**s == '+')
|
||||
*s += 1;
|
||||
|
||||
p = *s;
|
||||
if(!strbcmp(p, "0x")) {
|
||||
*s += 2;
|
||||
return 16;
|
||||
ret = 16;
|
||||
}
|
||||
if(isdigit(p[0])) {
|
||||
else if(isdigit(p[0])) {
|
||||
if(p[1] == 'r') {
|
||||
*s += 2;
|
||||
return p[0] - '0';
|
||||
ret = p[0] - '0';
|
||||
}
|
||||
if(isdigit(p[1]) && p[2] == 'r') {
|
||||
else if(isdigit(p[1]) && p[2] == 'r') {
|
||||
*s += 3;
|
||||
return 10*(p[0]-'0') + (p[1]-'0');
|
||||
ret = 10*(p[0]-'0') + (p[1]-'0');
|
||||
}
|
||||
}
|
||||
if(p[0] == '0') {
|
||||
*s += 1;
|
||||
return 8;
|
||||
else if(p[0] == '0') {
|
||||
ret = 8;
|
||||
}
|
||||
return 10;
|
||||
if(ret != 10 && (**s == '-' || **s == '+'))
|
||||
*sign = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
bool
|
||||
getlong(const char *s, long *ret) {
|
||||
const char *end;
|
||||
char *rend;
|
||||
int base;
|
||||
long sign;
|
||||
|
||||
end = s+strlen(s);
|
||||
base = getbase(&s);
|
||||
base = getbase(&s, &sign);
|
||||
if(sign == 0)
|
||||
return false;
|
||||
|
||||
*ret = strtol(s, &rend, base);
|
||||
*ret = sign * strtol(s, &rend, base);
|
||||
return (end == rend);
|
||||
}
|
||||
|
||||
int
|
||||
bool
|
||||
getulong(const char *s, ulong *ret) {
|
||||
const char *end;
|
||||
char *rend;
|
||||
int base;
|
||||
long sign;
|
||||
|
||||
end = s+strlen(s);
|
||||
base = getbase(&s);
|
||||
base = getbase(&s, &sign);
|
||||
if(sign < 1)
|
||||
return false;
|
||||
|
||||
*ret = strtoul(s, &rend, base);
|
||||
return (end == rend);
|
||||
@ -234,6 +247,11 @@ static Client*
|
||||
strclient(View *v, char *s) {
|
||||
ulong id;
|
||||
|
||||
/*
|
||||
* sel
|
||||
* 0x<window xid>
|
||||
*/
|
||||
|
||||
if(!strcmp(s, "sel"))
|
||||
return view_selclient(v);
|
||||
if(getulong(s, &id))
|
||||
@ -247,6 +265,12 @@ strarea(View *v, const char *s) {
|
||||
Area *a;
|
||||
long i;
|
||||
|
||||
/*
|
||||
* sel
|
||||
* ~
|
||||
* <column number>
|
||||
*/
|
||||
|
||||
if(!strcmp(s, "sel"))
|
||||
return v->sel;
|
||||
if(!strcmp(s, "~"))
|
||||
@ -276,6 +300,16 @@ message_client(Client *c, IxpMsg *m) {
|
||||
|
||||
s = msg_getword(m);
|
||||
|
||||
/*
|
||||
* Toggle ::= on
|
||||
* | off
|
||||
* | toggle
|
||||
* Fullscreen <toggle>
|
||||
* Urgent <toggle>
|
||||
* kill
|
||||
* slay
|
||||
*/
|
||||
|
||||
switch(getsym(s)) {
|
||||
case LFULLSCREEN:
|
||||
i = gettoggle(m);
|
||||
@ -380,6 +414,41 @@ message_view(View *v, IxpMsg *m) {
|
||||
if(s == nil)
|
||||
return nil;
|
||||
|
||||
/*
|
||||
* area ::= ~
|
||||
* | <column number>
|
||||
* | sel
|
||||
* # This *should* be identical to <frame>
|
||||
* place ::= <column number>
|
||||
* #| ~ # This should be, but isn't.
|
||||
* | left
|
||||
* | right
|
||||
* | up
|
||||
* | down
|
||||
* | toggle
|
||||
* colmode ::= default
|
||||
* | stack
|
||||
* | normal
|
||||
* column ::= sel
|
||||
* | <column number>
|
||||
* frame ::= up
|
||||
* | down
|
||||
* | left
|
||||
* | right
|
||||
* | toggle
|
||||
* | client <window xid>
|
||||
* | sel
|
||||
* | ~
|
||||
* | <column> <frame number>
|
||||
* | <column>
|
||||
*
|
||||
* colmode <area> <colmode>
|
||||
* select <area>
|
||||
* send <frame> <place>
|
||||
* swap <frame> <place>
|
||||
* select <ordframe>
|
||||
*/
|
||||
|
||||
switch(getsym(s)) {
|
||||
case LCOLMODE:
|
||||
s = msg_getword(m);
|
||||
@ -620,7 +689,6 @@ msg_sendclient(View *v, IxpMsg *m, bool swap) {
|
||||
case LLEFT:
|
||||
if(a->floating)
|
||||
return Ebadvalue;
|
||||
|
||||
if(a->prev != v->area)
|
||||
to = a->prev;
|
||||
a = v->area;
|
||||
@ -628,7 +696,6 @@ msg_sendclient(View *v, IxpMsg *m, bool swap) {
|
||||
case LRIGHT:
|
||||
if(a->floating)
|
||||
return Ebadvalue;
|
||||
|
||||
to = a->next;
|
||||
break;
|
||||
case LTOGGLE:
|
||||
@ -642,9 +709,7 @@ msg_sendclient(View *v, IxpMsg *m, bool swap) {
|
||||
default:
|
||||
if(!getulong(s, &i) || i == 0)
|
||||
return Ebadvalue;
|
||||
|
||||
for(to=v->area; to; to=to->next)
|
||||
if(!i--) break;
|
||||
to = view_findarea(v, i, true);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ search(Pair *lst, int key, char *(*def)(int)) {
|
||||
}
|
||||
|
||||
static char*
|
||||
unmask(Pair * list, uint val)
|
||||
unmask(Pair *list, uint val)
|
||||
{
|
||||
Pair *p;
|
||||
char *s, *end;
|
||||
|
@ -299,6 +299,16 @@ view_attach(View *v, Frame *f) {
|
||||
c->sel = f;
|
||||
}
|
||||
|
||||
void
|
||||
view_detach(Frame *f) {
|
||||
View *v;
|
||||
|
||||
v = f->view;
|
||||
area_detach(f);
|
||||
if(v != screen->sel && empty_p(v))
|
||||
view_destroy(v);
|
||||
}
|
||||
|
||||
char**
|
||||
view_names(void) {
|
||||
Vector_ptr vec;
|
||||
|
@ -96,19 +96,30 @@ fn Event-Notice {
|
||||
|
||||
fn Event-LeftBar^(Click DND) {
|
||||
shift; wmiir xwrite /ctl view $*}
|
||||
|
||||
fn ClientMenu-3-Delete {
|
||||
wmiir xwrite /client/$1/ctl kill}
|
||||
fn ClientMenu-3-Fullscreen {
|
||||
wmiir xwrite /client/$1/ctl Fullscreen on}
|
||||
fn Event-ClientMouseDown {
|
||||
client = $1; button = $2
|
||||
if(~ $button 3) {
|
||||
do=`{wi_9menu -initial $menulast Nop Delete Fullscreen}
|
||||
switch($do) {
|
||||
case Delete
|
||||
wmiir xwrite /client/$client/ctl kill
|
||||
case Fullscreen
|
||||
wmiir xwrite /client/$client/ctl Fullscreen on
|
||||
}
|
||||
if(! ~ $do '')
|
||||
menulast = $do;}}
|
||||
menulast = Nop
|
||||
wi_fnmenu Client $2 $1 &}
|
||||
|
||||
fn LBarMenu-3-Delete {
|
||||
tag=$1; clients=`{wmiir read /tag/$tag/index | awk '/[^#]/{print $2}'}
|
||||
for(c in $clients) {
|
||||
if(~ $tag `{wmiir read /client/$c/tags})
|
||||
wmiir xwrite /client/$c/ctl kill
|
||||
if not
|
||||
wmiir xwrite /client/$c/tags -$tag}
|
||||
if(~ $tag `{wi_seltag}) {
|
||||
newtag = `{wi_tags | awk -v't='$tag '
|
||||
$1 == t { if(!l) getline l
|
||||
print l
|
||||
exit }
|
||||
{ l = $0 }'}
|
||||
wmiir xwrite /ctl view $newtag}}
|
||||
fn Event-LeftBarMouseDown {
|
||||
wi_fnmenu LBar $* &}
|
||||
|
||||
# Actions
|
||||
fn Action-rehash {
|
||||
@ -229,10 +240,11 @@ Action rehash
|
||||
|
||||
# Tag Bar Setup
|
||||
ifs=$wi_nl{
|
||||
oldbars=`{comm -23 <{wmiir ls /lbar} <{wi_tags}}
|
||||
oldbars=`{comm -23 <{wmiir ls /lbar} \
|
||||
<{wi_tags}}
|
||||
if(! ~ $oldbars '')
|
||||
wmiir rm /lbar/^$oldbars
|
||||
seltag=`{wmiir read /tag/sel/ctl | sed 1q}
|
||||
seltag=`{wi_seltag}
|
||||
for(tag in `{wi_tags}) {
|
||||
if(~ $tag $seltag)
|
||||
echo $wmiifocuscol $tag | wmiir create /lbar/$tag
|
||||
|
Loading…
Reference in New Issue
Block a user