def PositionCursor(pos, x, y, term): global width curr_pos = 0 while curr_pos < pos: max_width = width[term] - 1 - x if pos - curr_pos >= max_width: partial_count = max_width x = 0 y = y + 1 else: partial_count = pos - curr_pos x = x + partial_count curr_pos = curr_pos + partial_count bits.goto_xy(x, y, term) return(x, y)
def PositionCursor(pos, x, y, term): global width curr_pos = 0 while curr_pos < pos: max_width = width[term] - 1 - x if pos - curr_pos >= max_width: partial_count = max_width x = 0 y = y + 1 else: partial_count = pos - curr_pos x = x + partial_count curr_pos = curr_pos + partial_count bits.goto_xy(x, y, term) return (x, y)
def print_buffer(line_buffer, x, y, term): global width, height, line_y curr_pos = 0 while curr_pos < len(line_buffer): bits.goto_xy(x, y, term) max_width = width[term] - 1 - x newline = False if len(line_buffer) - curr_pos >= max_width: partial_count = max_width x = 0 y = y + 1 newline = True else: partial_count = len(line_buffer) - curr_pos x = x + partial_count bits.puts(line_buffer[curr_pos:curr_pos + partial_count], term) if newline: bits.puts('\n', term) # check for scroll here and adjust start position if y == height[term]: y = y - 1 line_y[term] = line_y[term] - 1 curr_pos = curr_pos + partial_count