Skip to content

Instantly share code, notes, and snippets.

@uplus
Created May 9, 2016 15:06
Show Gist options
  • Save uplus/988627464269b99f34adbb2b09b1eb78 to your computer and use it in GitHub Desktop.
Save uplus/988627464269b99f34adbb2b09b1eb78 to your computer and use it in GitHub Desktop.
function! s:bufdo(bufname, cmd) abort
let wn = bufwinnr(a:bufname)
if wn == -1
return 0
endif
exe wn 'wincmd w'
exe a:cmd
wincmd p
endfunction
function! s:append_buf(bufname, str) abort
let wn = bufwinnr(a:bufname)
if wn == -1
return 0
endif
exe wn 'wincmd w'
put =a:str
wincmd p
endfunction
function! Callback(handle, msg)
let wn = bufwinnr("gdb-buf")
if wn == -1
return 0
endif
exe wn 'wincmd w'
put =a:msg
" wincmd p
redraw
endfunction
command! -nargs=* Send call ch_sendraw(handle_send, <q-args> . "\n")
if bufwinnr("gdb-buf") == -1
20new gdb-buf
setlocal buftype=nofile bufhidden=hide noswapfile
setf gdb
wincmd p
endif
let handle = ch_open("127.0.0.1:3000", {'mode': 'raw', 'callback': 'Callback'})
let handle_send = ch_open("127.0.0.1:4000", {'mode': 'raw'})
" $ nc -l 4000 | nc -l 3000
" $ nc -l 4000 | gdb |& nc -l 3000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment