import curses

from .character import Character
from .console import Console
from .line import Line
from .attribute import RenditionAttribute, ColorAttribute
from .misc import ESCAPE_CHARS, DELETE_CHARS, BACKSPACE_CHARS, \
                  is_printable_char, char_with_control_key



__console = None


def turn_on_console(asciize=False, spaces_per_tab=4):
  Line.ASCIIZE = asciize
  Line.SPACES_PER_TAB = spaces_per_tab

  window = curses.initscr()
  curses.noecho()
  curses.cbreak()

  curses.start_color()
  curses.use_default_colors()
  ColorAttribute.initialize()

  global __console
  __console = Console(window)

  return __console


def turn_off_console():
  curses.nocbreak()
  curses.echo()
  curses.endwin()


import curses

from .character import Character
from .console import Console
from .line import Line
from .attribute import RenditionAttribute, ColorAttribute
from .misc import ESCAPE_CHARS, DELETE_CHARS, BACKSPACE_CHARS, \
                  is_printable_char, char_with_control_key



def turn_on_console(asciize=False, spaces_per_tab=4):
  Line.ASCIIZE = asciize
  Line.SPACES_PER_TAB = spaces_per_tab

  window = curses.initscr()
  curses.noecho()
  curses.cbreak()

  curses.start_color()
  curses.use_default_colors()
  ColorAttribute.initialize()

  return Console(window)


def turn_off_console():
  curses.nocbreak()
  curses.echo()
  curses.endwin()


Remove an extra global variable in xorcise package
Remove an extra global variable in xorcise package

  import curses
  
  from .character import Character
  from .console import Console
  from .line import Line
  from .attribute import RenditionAttribute, ColorAttribute
  from .misc import ESCAPE_CHARS, DELETE_CHARS, BACKSPACE_CHARS, \
                    is_printable_char, char_with_control_key
  
- 
- 
- __console = None
  
  
  def turn_on_console(asciize=False, spaces_per_tab=4):
    Line.ASCIIZE = asciize
    Line.SPACES_PER_TAB = spaces_per_tab
  
    window = curses.initscr()
    curses.noecho()
    curses.cbreak()
  
    curses.start_color()
    curses.use_default_colors()
    ColorAttribute.initialize()
  
+   return Console(window)
-   global __console
-   __console = Console(window)
- 
-   return __console
  
  
  def turn_off_console():
    curses.nocbreak()
    curses.echo()
    curses.endwin()
  
  
Remove an extra global variable in xorcise package
## Code Before:
import curses

from .character import Character
from .console import Console
from .line import Line
from .attribute import RenditionAttribute, ColorAttribute
from .misc import ESCAPE_CHARS, DELETE_CHARS, BACKSPACE_CHARS, \
                  is_printable_char, char_with_control_key



__console = None


def turn_on_console(asciize=False, spaces_per_tab=4):
  Line.ASCIIZE = asciize
  Line.SPACES_PER_TAB = spaces_per_tab

  window = curses.initscr()
  curses.noecho()
  curses.cbreak()

  curses.start_color()
  curses.use_default_colors()
  ColorAttribute.initialize()

  global __console
  __console = Console(window)

  return __console


def turn_off_console():
  curses.nocbreak()
  curses.echo()
  curses.endwin()


## Instruction:
Remove an extra global variable in xorcise package
## Code After:
import curses

from .character import Character
from .console import Console
from .line import Line
from .attribute import RenditionAttribute, ColorAttribute
from .misc import ESCAPE_CHARS, DELETE_CHARS, BACKSPACE_CHARS, \
                  is_printable_char, char_with_control_key



def turn_on_console(asciize=False, spaces_per_tab=4):
  Line.ASCIIZE = asciize
  Line.SPACES_PER_TAB = spaces_per_tab

  window = curses.initscr()
  curses.noecho()
  curses.cbreak()

  curses.start_color()
  curses.use_default_colors()
  ColorAttribute.initialize()

  return Console(window)


def turn_off_console():
  curses.nocbreak()
  curses.echo()
  curses.endwin()

