0

Every bit of documentation I've found suggests that this should work, but the cursor position doesn't return to 0,0.

colorama.init()

def move (y, x):
    print("\033[%d;%dH" % (y, x))

for file in original_file:
        for element in root.iter():
                all_lines = all_lines+1
                if element.text != None:
                    if element.tag in field_list:
                        if len(element.text) > field_list[element.tag]:
                                corrected_lines = corrected_lines+1           
                                move(0, 0)
                                working_message(username, window_width)
                                print("{3}: {0} \n {1} to {2}\n---".format(element.tag, len(element.text), field_list[element.tag], corrected_lines))
                                print(corrected_lines)
                                print(all_lines)

                                element.text = element.text[field_list[element.tag]]

The important bits being that colorama is initialized, then every loop the cursor should be moved to 0,0 using the move(0,0) function (passing as string of "\033[0;0H" to print).

Emil Visti
  • 47
  • 1
  • 6

1 Answers1

1

The top left of the screen is at coordinate 1,1 not 0,0. So your call should be

move(1,1)

And your print() call should look like this:

print("\033[%d;%dH" % (y, x), end="")

Without that, move(1,1) will call print() which will issue the escape code to send the cursor to the desired coordinate and then immediately issue a carriage return/line feed. That will turn your move(1,1) effectively into move(1,2).

BoarGules
  • 13,647
  • 2
  • 23
  • 38