@@ -241,6 +241,7 @@ def update_subchannel_msgs(debug=False):
241
241
vim .command (" syn match Green /^In \[ [0-9]*\]\: /" )
242
242
vim .command (" syn match Red /^Out\[ [0-9]*\]\: /" )
243
243
b = vim .current.buffer
244
+ update_occured = False
244
245
for m in msgs:
245
246
#db.append (str (m ).splitlines ())
246
247
s = ' '
@@ -281,12 +282,14 @@ def update_subchannel_msgs(debug=False):
281
282
b .append (s .splitlines ())
282
283
except:
283
284
b .append ([l .encode (vim_encoding) for l in s .splitlines ()])
285
+ update_occured = True
284
286
# make a newline so we can just start typing there
285
287
if b [-1 ] != ' ' :
286
288
b .append ([' ' ])
287
289
vim .command (' normal G' ) # go to the end of the file
288
290
if not startedin_vimipython:
289
291
vim .command (' normal p' ) # go back to where you were
292
+ return update_occured
290
293
291
294
def get_child_msg (msg_id):
292
295
# XXX : message handling should be split into its own process in the future
@@ -421,6 +424,35 @@ fun! <SID>toggle_send_on_save()
421
424
endif
422
425
endfun
423
426
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
+
424
456
" Allow custom mappings
425
457
if ! exists (' g:ipy_perform_mappings' )
426
458
let g: ipy_perform_mappings = 1
0 commit comments