| 1 |
#!/usr/bin/env python3 |
| 2 |
# -*- coding: utf-8 -*- |
| 3 |
|
| 4 |
# Fenrir TTY screen reader |
| 5 |
# By Chrys, Storm Dragon, and contributors. |
| 6 |
|
| 7 |
from fenrirscreenreader.core import debug |
| 8 |
|
| 9 |
|
| 10 |
def get_prev_line(curr_x, curr_y, curr_text): |
| 11 |
end_of_screen = False |
| 12 |
if curr_text == "": |
| 13 |
return -1, -1, "", end_of_screen |
| 14 |
wrapped_lines = curr_text.split("\n") |
| 15 |
x = curr_x |
| 16 |
y = curr_y |
| 17 |
if y - 1 >= 0: |
| 18 |
y -= 1 |
| 19 |
else: |
| 20 |
end_of_screen = True |
| 21 |
x = curr_x |
| 22 |
curr_line = "" |
| 23 |
if not end_of_screen: |
| 24 |
curr_line = wrapped_lines[y] |
| 25 |
return x, y, curr_line, end_of_screen |
| 26 |
|
| 27 |
|
| 28 |
def get_current_line(curr_x, curr_y, curr_text): |
| 29 |
if curr_text == "": |
| 30 |
return -1, -1, "" |
| 31 |
wrapped_lines = curr_text.split("\n") |
| 32 |
x = curr_x |
| 33 |
y = curr_y |
| 34 |
x = 0 |
| 35 |
curr_line = wrapped_lines[y] |
| 36 |
return x, y, curr_line |
| 37 |
|
| 38 |
|
| 39 |
def get_next_line(curr_x, curr_y, curr_text): |
| 40 |
end_of_screen = False |
| 41 |
if curr_text == "": |
| 42 |
return -1, -1, "", end_of_screen |
| 43 |
wrapped_lines = curr_text.split("\n") |
| 44 |
x = curr_x |
| 45 |
y = curr_y |
| 46 |
if y + 1 < len(wrapped_lines): |
| 47 |
y += 1 |
| 48 |
else: |
| 49 |
end_of_screen = True |
| 50 |
x = curr_x |
| 51 |
curr_line = "" |
| 52 |
if not end_of_screen: |
| 53 |
curr_line = wrapped_lines[y] |
| 54 |
return x, y, curr_line, end_of_screen |