示例#1
0
def putwc_at(pagenum, row, col, c, d, for_keys=False):
    """ Put a double-byte character at a given position. """
    global last_pos
    sys.stdout.write(ansi.esc_move_cursor % (row, col))
    try:
        sys.stdout.write(unicodepage.UTF8Converter().to_utf8(c + d))
    except KeyError:
        sys.stdout.write('  ')
    sys.stdout.write(unicodepage.UTF8Converter().to_utf8(c))
    sys.stdout.write(ansi.esc_move_cursor % (cursor_row, cursor_col))
    last_pos = (cursor_row, cursor_col)
    sys.stdout.flush()
示例#2
0
def putc_at(pagenum, row, col, c, for_keys=False):
    """ Put a single-byte character at a given position. """
    global last_pos
    sys.stdout.write(ansi.esc_move_cursor % (row, col))
    sys.stdout.write(unicodepage.UTF8Converter().to_utf8(c))
    sys.stdout.write(ansi.esc_move_cursor % (cursor_row, cursor_col))
    last_pos = (cursor_row, cursor_col)
    sys.stdout.flush()
示例#3
0
def putc_at(pagenum, row, col, c, for_keys=False):
    """ Put a single-byte character at a given position. """
    if c == '\0':
        c = ' '
    try:
        window.addstr(row - 1, col - 1,
                      unicodepage.UTF8Converter().to_utf8(c), colours(attr))
    except curses.error:
        pass
示例#4
0
def putc_at(pagenum, row, col, c, for_keys=False):
    """ Put a single-byte character at a given position. """
    global last_col
    if for_keys:
        return
    update_position(row, col)
    # this doesn't recognise DBCS
    sys.stdout.write(unicodepage.UTF8Converter().to_utf8(c))
    sys.stdout.flush()
    last_col += 1
示例#5
0
文件: printer.py 项目: nony05/pcbasic
 def flush(self):
     """ Flush the printer buffer to a printer. """
     printbuf = self.getvalue()
     if not printbuf:
         return
     self.truncate(0)
     # any naked lead bytes in DBCS will remain just that - avoid in-line flushes.
     utf8buf = unicodepage.UTF8Converter(
         preserve_control=True).to_utf8(printbuf)
     line_print(utf8buf, self.printer_name)
示例#6
0
def putwc_at(pagenum, row, col, c, d, for_keys=False):
    """ Put a double-byte character at a given position. """
    try:
        try:
            window.addstr(row - 1, col - 1,
                          unicodepage.UTF8Converter().to_utf8(c + d),
                          colours(attr))
        except KeyError:
            window.addstr(row - 1, col - 1, '  ', attr)
    except curses.error:
        pass
示例#7
0
def putwc_at(pagenum, row, col, c, d, for_keys=False):
    """ Put a double-byte character at a given position. """
    global last_col
    if for_keys:
        return
    update_position(row, col)
    # this does recognise DBCS
    try:
        sys.stdout.write(unicodepage.UTF8Converter().to_utf8(c + d))
    except KeyError:
        sys.stdout.write('  ')
    sys.stdout.flush()
    last_col += 2
示例#8
0
(c) 2014, 2015 Rob Hagemans
This file is released under the GNU GPL version 3.
"""

import logging
from functools import partial

import config
import unicodepage
import state

# input has closed
input_closed = False

# converter with DBCS lead-byte buffer for utf8 output redirection
utf8conv = unicodepage.UTF8Converter(preserve_control=True)

# redirect i/o to file or printer
output_echos = []


def prepare():
    """ Initialise redirect module. """
    pass


def prepare_redirects():
    """ Initialise i/o redirects. """
    option_input = config.get('input')
    option_output = config.get('output')
    if option_output:
示例#9
0
 def write(self, s):
     """ Write to file in normal or UTF-8 mode. """
     if self.utf8:
         s = unicodepage.UTF8Converter().to_utf8(s)
     devices.CRLFTextFileBase.write(self, s)