@@ -246,6 +246,7 @@ func s:InstallCommands()
246246 command - range -nargs =* Evaluate call s: Evaluate (<range> , <q-args> )
247247 command Gdb call win_gotoid (s: gdbwin )
248248 command Program call win_gotoid (s: ptywin )
249+ command Source call s: GotoStartwinOrCreateIt ()
249250 command Winbar call s: InstallWinbar ()
250251
251252 " TODO: can the K mapping be restored?
@@ -269,13 +270,15 @@ let s:winbar_winids = []
269270
270271" Install the window toolbar in the current window.
271272func s: InstallWinbar ()
272- nnoremenu WinBar.Step :Step <CR>
273- nnoremenu WinBar.Next :Over <CR>
274- nnoremenu WinBar.Finish :Finish <CR>
275- nnoremenu WinBar.Cont :Continue <CR>
276- nnoremenu WinBar.Stop :Stop <CR>
277- nnoremenu WinBar.Eval :Evaluate <CR>
278- call add (s: winbar_winids , win_getid (winnr ()))
273+ if has (' menu' ) && &mouse != ' '
274+ nnoremenu WinBar.Step :Step <CR>
275+ nnoremenu WinBar.Next :Over <CR>
276+ nnoremenu WinBar.Finish :Finish <CR>
277+ nnoremenu WinBar.Cont :Continue <CR>
278+ nnoremenu WinBar.Stop :Stop <CR>
279+ nnoremenu WinBar.Eval :Evaluate <CR>
280+ call add (s: winbar_winids , win_getid (winnr ()))
281+ endif
279282endfunc
280283
281284" Delete installed debugger commands in the current window.
@@ -450,6 +453,14 @@ func s:HandleError(msg)
450453 echoerr substitute (a: msg , ' .*msg="\(.*\)"' , ' \1' , ' ' )
451454endfunc
452455
456+ func s: GotoStartwinOrCreateIt ()
457+ if ! win_gotoid (s: startwin )
458+ new
459+ let s: startwin = win_getid (winnr ())
460+ call s: InstallWinbar ()
461+ endif
462+ endfunc
463+
453464" Handle stopping and running message from gdb.
454465" Will update the sign that shows the current position.
455466func s: HandleCursor (msg)
@@ -461,31 +472,32 @@ func s:HandleCursor(msg)
461472 let s: stopped = 0
462473 endif
463474
464- if win_gotoid (s: startwin )
465- let fname = substitute (a: msg , ' .*fullname="\([^"]*\)".*' , ' \1' , ' ' )
466- if a: msg = ~ ' ^\(\*stopped\|=thread-selected\)' && filereadable (fname)
467- let lnum = substitute (a: msg , ' .*line="\([^"]*\)".*' , ' \1' , ' ' )
468- if lnum = ~ ' ^[0-9]*$'
469- if expand (' %:p' ) != fnamemodify (fname, ' :p' )
470- if &modified
471- " TODO: find existing window
472- exe ' split ' . fnameescape (fname)
473- let s: startwin = win_getid (winnr ())
474- else
475- exe ' edit ' . fnameescape (fname)
476- endif
475+ call s: GotoStartwinOrCreateIt ()
476+
477+ let fname = substitute (a: msg , ' .*fullname="\([^"]*\)".*' , ' \1' , ' ' )
478+ if a: msg = ~ ' ^\(\*stopped\|=thread-selected\)' && filereadable (fname)
479+ let lnum = substitute (a: msg , ' .*line="\([^"]*\)".*' , ' \1' , ' ' )
480+ if lnum = ~ ' ^[0-9]*$'
481+ if expand (' %:p' ) != fnamemodify (fname, ' :p' )
482+ if &modified
483+ " TODO: find existing window
484+ exe ' split ' . fnameescape (fname)
485+ let s: startwin = win_getid (winnr ())
486+ call s: InstallWinbar ()
487+ else
488+ exe ' edit ' . fnameescape (fname)
477489 endif
478- exe lnum
479- exe ' sign unplace ' . s: pc_id
480- exe ' sign place ' . s: pc_id . ' line=' . lnum . ' name=debugPC file=' . fname
481- setlocal signcolumn = yes
482490 endif
483- else
491+ exe lnum
484492 exe ' sign unplace ' . s: pc_id
493+ exe ' sign place ' . s: pc_id . ' line=' . lnum . ' name=debugPC file=' . fname
494+ setlocal signcolumn = yes
485495 endif
486-
487- call win_gotoid (wid)
496+ else
497+ exe ' sign unplace ' . s: pc_id
488498 endif
499+
500+ call win_gotoid (wid)
489501endfunc
490502
491503" Handle setting a breakpoint
0 commit comments