diff --git a/IPython/platutils.py b/IPython/platutils.py index 7f84769..6d1d94c 100644 --- a/IPython/platutils.py +++ b/IPython/platutils.py @@ -12,10 +12,6 @@ for your operation system, from platutils_PLATFORMNAME module. # the file COPYING, distributed as part of this software. #***************************************************************************** -from IPython import Release -__author__ = '%s <%s>' % Release.authors['Ville'] -__license__ = Release.license - import os import sys @@ -35,8 +31,26 @@ else: # Functionality that's logically common to all platforms goes here, each # platform-specific module only provides the bits that are OS-dependent. -def freeze_term_title(): - _platutils.ignore_termtitle = True +# XXX - I'm still not happy with a module global for this, but at least now +# there is a public, cross-platform way of toggling the term title control on +# and off. We should make this a stateful object later on so that each user +# can have its own instance if needed. +def toggle_set_term_title(val): + """Control whether set_term_title is active or not. + + set_term_title() allows writing to the console titlebar. In embedded + widgets this can cause problems, so this call can be used to toggle it on + or off as needed. + + The default state of the module is for the function to be disabled. + + Parameters + ---------- + val : bool + If True, set_term_title() actually writes to the terminal (using the + appropriate platform-specific module). If False, it is a no-op. + """ + _platutils.ignore_termtitle = not(val) def set_term_title(title): @@ -45,3 +59,12 @@ def set_term_title(title): if _platutils.ignore_termtitle: return _platutils.set_term_title(title) + + +#----------------------------------------------------------------------------- +# Deprecated functions +#----------------------------------------------------------------------------- +def freeze_term_title(): + warnings.warn("This function is deprecated, use toggle_set_term_title()") + _platutils.ignore_termtitle = True + diff --git a/IPython/platutils_posix.py b/IPython/platutils_posix.py index d0dbc0a..e4d162b 100644 --- a/IPython/platutils_posix.py +++ b/IPython/platutils_posix.py @@ -12,14 +12,10 @@ to use these functions in platform agnostic fashion. # the file COPYING, distributed as part of this software. #***************************************************************************** -from IPython import Release -__author__ = '%s <%s>' % Release.authors['Ville'] -__license__ = Release.license - import sys import os -ignore_termtitle = False +ignore_termtitle = True def _dummy_op(*a, **b): """ A no-op function """ @@ -27,7 +23,7 @@ def _dummy_op(*a, **b): def _set_term_title_xterm(title): """ Change virtual terminal title in xterm-workalikes """ - sys.stdout.write('\033]%d;%s\007' % (0,title)) + sys.stdout.write('\033]0;%s\007' % title) if os.environ.get('TERM','') == 'xterm': diff --git a/IPython/platutils_win32.py b/IPython/platutils_win32.py index 630a9ca..e732fb9 100644 --- a/IPython/platutils_win32.py +++ b/IPython/platutils_win32.py @@ -12,13 +12,10 @@ to use these functions in platform agnostic fashion. # the file COPYING, distributed as part of this software. #***************************************************************************** -from IPython import Release -__author__ = '%s <%s>' % Release.authors['Ville'] -__license__ = Release.license import os -ignore_termtitle = False +ignore_termtitle = True try: import ctypes