1+ # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
2+ # vim: ft=zsh sw=2 ts=2 et
3+ #
4+ # ZUI demo: configure/make
5+ #
16# Started from Zle or from command line
27
38-zui_std_cleanup deserialize:" zui-demo-configure"
49-zui_std_init app:" zui-demo-configure" app_name:" ZUI Configure/Make wrapper"
5- emulate -LR zsh -o extended_glob -o typeset_silent -o warn_create_global
10+
11+ builtin emulate -LR zsh
12+ builtin setopt extended_glob typeset_silent warn_create_global
13+
614-zui_std_init2 # after emulate -LR
715
816-zui_std_store_default_app_config s:timeout 300
@@ -12,45 +20,45 @@ local -a coproc_output
1220local cstarted=0 mstarted=0 # denote if configure/make is running
1321
1422demo_generator_A () {
15- local mod=" $1 " ice=" $2 "
23+ local mod=" $1 " ice=" $2 "
1624
17- reply=()
18- -zui_std_rc_button " button1" " ${ZUI[MAGENTA]} Run configure${ZUI[FMT_END]} " ' internal=1; coproc 2>&1 ./configure; cstarted=1'
19- -zui_std_rc_button " button2" " ${ZUI[MAGENTA]} Get CFLAGS${ZUI[FMT_END]} " ' internal=1; get_cflags'
20- -zui_std_rc_button " button3" " ${ZUI[MAGENTA]} Run make${ZUI[FMT_END]} " ' internal=1; coproc 2>&1 make; mstarted=1'
25+ reply=()
26+ -zui_std_rc_button " button1" " ${ZUI[MAGENTA]} Run configure${ZUI[FMT_END]} " ' internal=1; coproc 2>&1 ./configure; cstarted=1'
27+ -zui_std_rc_button " button2" " ${ZUI[MAGENTA]} Get CFLAGS${ZUI[FMT_END]} " ' internal=1; get_cflags'
28+ -zui_std_rc_button " button3" " ${ZUI[MAGENTA]} Run make${ZUI[FMT_END]} " ' internal=1; coproc 2>&1 make; mstarted=1'
2129
22- # Content
23- reply=( " ${reply[1]} ${reply[2]} ${reply[3]} " )
30+ # Content
31+ reply=( " ${reply[1]} ${reply[2]} ${reply[3]} " )
2432
25- # Non-selectable lines Hops to jump with [ and ] Local anchors
26- reply2=( ) reply3=( 1 ) reply4=( )
33+ # Non-selectable lines Hops to jump with [ and ] Local anchors
34+ reply2=( ) reply3=( 1 ) reply4=( )
2735}
2836
2937demo_generator_B () {
30- reply=()
31- -zui_std_special_text " Configure/Make output"
32- -zui_std_button " button4" " ${ZUI[MAGENTA]} (clear)${ZUI[FMT_END]} " ' internal=1; coproc_output=( ); -zui_std_fly_mod_regen 2 1'
33- reply=( " ${ZUI[YELLOW]}${reply[1]}${ZUI[FMT_END]} ${reply[2]} " " ${coproc_output[@]} " ) reply2=( ) reply3=( 1 ) reply4=( )
38+ reply=()
39+ -zui_std_special_text " Configure/Make output"
40+ -zui_std_button " button4" " ${ZUI[MAGENTA]} (clear)${ZUI[FMT_END]} " ' internal=1; coproc_output=( ); -zui_std_fly_mod_regen 2 1'
41+ reply=( " ${ZUI[YELLOW]}${reply[1]}${ZUI[FMT_END]} ${reply[2]} " " ${coproc_output[@]} " ) reply2=( ) reply3=( 1 ) reply4=( )
3442}
3543
3644# Read & publish configure/make output
3745-zui-standard-timeout-callback () {
38- (( mstarted + cstarted == 0 )) && return
46+ (( mstarted + cstarted == 0 )) && return
3947
40- local line had_read=0
41- repeat 20; do
42- read -r -p -t 0 line 2> /dev/null && { had_read=1; coproc_output+=( " $line " ); } || break
43- done
48+ local line had_read=0
49+ repeat 20; do
50+ read -r -p -t 0 line 2> /dev/null && { had_read=1; coproc_output+=( " $line " ); } || break
51+ done
4452
45- (( had_read )) && -zui_std_fly_mod_regen 2 1
46- (( mstarted != 0 && had_read == 0 )) && [[ " ${jobtexts[*]} " != * make* ]] && { ZUI[redraw]=1; mstarted=0; -zui_std_stalog " Message: " " make ended" ; }
47- (( cstarted != 0 && had_read == 0 )) && [[ " ${jobtexts[*]} " != * configure* ]] && { ZUI[redraw]=1; cstarted=0; -zui_std_stalog " Message: " " configure ended" ; }
53+ (( had_read )) && -zui_std_fly_mod_regen 2 1
54+ (( mstarted != 0 && had_read == 0 )) && [[ " ${jobtexts[*]} " != * make* ]] && { ZUI[redraw]=1; mstarted=0; -zui_std_stalog " Message: " " make ended" ; }
55+ (( cstarted != 0 && had_read == 0 )) && [[ " ${jobtexts[*]} " != * configure* ]] && { ZUI[redraw]=1; cstarted=0; -zui_std_stalog " Message: " " configure ended" ; }
4856}
4957
5058get_cflags () {
51- local CFLAGS=` grep ' ^CFLAGS[[:space:]]*=' Makefile`
52- -zui_std_stalog " Obtained: " " CFLAGS = ${CFLAGS#* =[[:space:]]## } "
53- return 1
59+ local CFLAGS=` grep ' ^CFLAGS[[:space:]]*=' Makefile`
60+ -zui_std_stalog " Obtained: " " CFLAGS = ${CFLAGS#* =[[:space:]]## } "
61+ return 1
5462}
5563
5664# # Start application ##
@@ -59,5 +67,3 @@ zui-event-loop 1:demo_generator_A 1:demo_generator_B
5967-zui_std_cleanup serialize
6068
6169return 0
62-
63- # vim:ft=zsh
0 commit comments