@@ -220,9 +220,11 @@ def smarter_request_refresh(when='now'):
220220 self .get_term_hw = get_term_hw
221221 self .get_cursor_vertical_diff = get_cursor_vertical_diff
222222
223- self .status_bar = StatusBar (banner if config .curtsies_fill_terminal else '' , _ (
224- " <%s> Rewind <%s> Save <%s> Pastebin <%s> Editor"
225- ) % (config .undo_key , config .save_key , config .pastebin_key , config .external_editor_key ),
223+ self .status_bar = StatusBar (
224+ banner if config .curtsies_fill_terminal else '' ,
225+ (_ (" <%s> Rewind <%s> Save <%s> Pastebin <%s> Editor" )
226+ % (config .undo_key , config .save_key , config .pastebin_key , config .external_editor_key )
227+ if config .curtsies_fill_terminal else '' ),
226228 refresh_request = self .request_refresh
227229 )
228230 self .rl_char_sequences = get_updated_char_sequences (key_dispatch , config )
@@ -262,6 +264,7 @@ def smarter_request_refresh(when='now'):
262264 self .paste_mode = False
263265 self .current_match = None
264266 self .list_win_visible = False
267+ self .watching_files = False
265268
266269 self .original_modules = sys .modules .keys ()
267270
@@ -361,13 +364,25 @@ def process_event(self, e):
361364 self .update_completion ()
362365 return
363366
364- elif isinstance (e , events .ReloadEvent ) or e in key_dispatch [ self . config . reimport_key ] :
365- self .clear_modules_and_reevaluate ()
366- self .update_completion ()
367- if isinstance ( e , events . ReloadEvent ):
367+ elif isinstance (e , events .ReloadEvent ):
368+ if self .watching_files :
369+ self .clear_modules_and_reevaluate ()
370+ self . update_completion ()
368371 self .status_bar .message ('Reloaded at ' + time .strftime ('%H:%M:%S' ) + ' because ' + ' & ' .join (e .files_modified ) + ' modified' )
372+
373+ elif e in key_dispatch [self .config .toggle_file_watch_key ]:
374+ msg = "Auto-reloading active, watching for file changes..."
375+ if self .watching_files :
376+ self .watching_files = False
377+ self .status_bar .pop_permanent_message (msg )
369378 else :
370- self .status_bar .message ('Reloaded at ' + time .strftime ('%H:%M:%S' ) + ' by user' )
379+ self .watching_files = True
380+ self .status_bar .push_permanent_message (msg )
381+
382+ elif e in key_dispatch [self .config .reimport_key ]:
383+ self .clear_modules_and_reevaluate ()
384+ self .update_completion ()
385+ self .status_bar .message ('Reloaded at ' + time .strftime ('%H:%M:%S' ) + ' by user' )
371386
372387 elif (e in ("<RIGHT>" , '<Ctrl-f>' ) and self .config .curtsies_right_arrow_completion
373388 and self .cursor_offset == len (self .current_line )):
0 commit comments