@@ -5,29 +5,43 @@ if exists('g:autoloaded_dispatch_screen')
5
5
endif
6
6
let g: autoloaded_dispatch_screen = 1
7
7
8
+ let s: waiting = {}
9
+
8
10
function ! dispatch#screen#handle (request) abort
9
11
if empty ($STY ) || ! executable (' screen' )
10
12
return 0
11
13
endif
14
+ let aftercmd = ' screen -X only; screen -X at $WINDOW kill'
12
15
if a: request .action == # ' make'
13
- if ! get (a: request , ' background' , 0 ) && empty (v: servername )
16
+ if ! get (a: request , ' background' , 0 ) && empty (v: servername ) && ! empty ( s: waiting )
14
17
return 0
15
18
endif
16
- return dispatch#screen#spawn (dispatch#prepare_make (a: request ), a: request )
19
+ let cmd = dispatch#prepare_make (a: request , aftercmd)
20
+ return dispatch#screen#spawn (cmd, a: request )
17
21
elseif a: request .action == # ' start'
18
- return dispatch#screen#spawn (dispatch#prepare_start (a: request ), a: request )
22
+ let cmd = dispatch#prepare_start (a: request , aftercmd)
23
+ return dispatch#screen#spawn (cmd, a: request )
19
24
endif
20
25
endfunction
21
26
22
27
function ! dispatch#screen#spawn (command , request) abort
23
- let command = ' screen -ln -fn -t ' .dispatch#shellescape (a: request .title )
28
+ let command = ' '
29
+ if ! get (a: request , ' background' , 0 )
30
+ silent execute " !screen -X eval 'split' 'focus down' 'resize 10'"
31
+ endif
32
+ let command .= ' screen -ln -fn -t ' .dispatch#shellescape (a: request .title )
24
33
\ . ' ' . &shell . ' ' . &shellcmdflag . ' '
25
34
\ . shellescape (' exec ' . dispatch#isolate ([' STY' , ' WINDOW' ],
26
35
\ dispatch#set_title (a: request ), a: command ))
27
36
silent execute ' !' . escape (command , ' !#%' )
37
+
28
38
if a: request .background
29
39
silent ! screen - X other
40
+ else
41
+ silent ! screen - X focus up
30
42
endif
43
+
44
+ let s: waiting = a: request
31
45
return 1
32
46
endfunction
33
47
@@ -42,3 +56,19 @@ function! dispatch#screen#activate(pid) abort
42
56
return ! v: shell_error
43
57
endif
44
58
endfunction
59
+
60
+ function ! dispatch#screen#poll () abort
61
+ if empty (s: waiting )
62
+ return
63
+ endif
64
+ let request = s: waiting
65
+ if ! dispatch#pid (request)
66
+ let s: waiting = {}
67
+ call dispatch#complete (request)
68
+ endif
69
+ endfunction
70
+
71
+ augroup dispatch_screen
72
+ autocmd !
73
+ autocmd VimResized * if ! has (' gui_running' ) | call dispatch#screen#poll () | endif
74
+ augroup END
0 commit comments