@@ -241,6 +241,7 @@ def update_subchannel_msgs(debug=False):
241241 vim .command (" syn match Green /^In \[ [0-9]*\]\: /" )
242242 vim .command (" syn match Red /^Out\[ [0-9]*\]\: /" )
243243 b = vim .current.buffer
244+ update_occured = False
244245 for m in msgs:
245246 #db.append (str (m ).splitlines ())
246247 s = ' '
@@ -281,12 +282,14 @@ def update_subchannel_msgs(debug=False):
281282 b .append (s .splitlines ())
282283 except:
283284 b .append ([l .encode (vim_encoding) for l in s .splitlines ()])
285+ update_occured = True
284286 # make a newline so we can just start typing there
285287 if b [-1 ] != ' ' :
286288 b .append ([' ' ])
287289 vim .command (' normal G' ) # go to the end of the file
288290 if not startedin_vimipython:
289291 vim .command (' normal p' ) # go back to where you were
292+ return update_occured
290293
291294def get_child_msg (msg_id):
292295 # XXX : message handling should be split into its own process in the future
@@ -421,6 +424,35 @@ fun! <SID>toggle_send_on_save()
421424 endif
422425endfun
423426
427+ " Update the vim-ipython shell when the cursor is not moving.
428+ " You can change how quickly this happens after you stop moving the cursor by
429+ " setting 'updatetime' (in milliseconds). For example, to have this event
430+ " trigger after 1 second:
431+ "
432+ " :set updatetime 1000
433+ "
434+ " NOTE: This will only be triggered once, after the first 'updatetime'
435+ " milliseconds, *not* every 'updatetime' milliseconds. see :help CursorHold
436+ " for more info.
437+ "
438+ " TODO: Make this easily configurable on the fly, so that an introspection
439+ " buffer we may have opened up doesn't get closed just because of an idle
440+ " event (i.e. user pressed \d and then left the buffer that popped up, but
441+ " expects it to stay there).
442+ au CursorHold *.*,vim-ipython :python if update_subchannel_msgs (): echo (" vim-ipython shell updated (on idle)" ,' Operator' )
443+
444+ " XXX: broken - cursor hold update for insert mode moves the cursor one
445+ " character to the left of the last character (update_subchannel_msgs must be
446+ " doing this)
447+ " au CursorHoldI *.* :python if update_subchannel_msgs(): echo("vim-ipython shell updated (on idle)",'Operator')
448+
449+ " Same as above, but on regaining window focus (mostly for GUIs)
450+ au FocusGained *.*,vim-ipython :python if update_subchannel_msgs (): echo (" vim-ipython shell updated (on input focus)" ,' Operator' )
451+
452+ " Update vim-ipython buffer when we move the cursor there. A message is only
453+ " displayed if vim-ipython buffer has been updated.
454+ au BufEnter vim-ipython :python if update_subchannel_msgs (): echo (" vim-ipython shell updated (on buffer enter)" ,' Operator' )
455+
424456" Allow custom mappings
425457if ! exists (' g:ipy_perform_mappings' )
426458 let g: ipy_perform_mappings = 1
0 commit comments