Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
1061d22
Windows repl support
DinoV May 17, 2024
fa0f538
Arrow key support
DinoV May 18, 2024
6f35100
Make backspace clear char
DinoV May 18, 2024
7772787
Fix missing newline after input
DinoV May 18, 2024
aced5ae
Make insert work
DinoV May 18, 2024
fa3815f
Fix delete in middle
DinoV May 18, 2024
b30b105
Fix crash on invalid command key
DinoV May 18, 2024
df262c4
More fixes
DinoV May 20, 2024
6e57316
Colorize
DinoV May 20, 2024
18ecc2e
Use constants
DinoV May 20, 2024
60525eb
Use UnicodeChar
DinoV May 21, 2024
af79a17
Simplify
DinoV May 21, 2024
5f99256
Fix scrolling on input which is longer than screen/scrollback
DinoV May 21, 2024
bdff535
fix pager typo and refactor some unused branches (#41)
tonybaloney May 20, 2024
88d64f5
Implement screen clear for Windows (#42)
tonybaloney May 20, 2024
8a74306
Fix word wrap not being enabled in Windows Terminal
DinoV May 21, 2024
38e9c58
Fix culmitive errors in wrapping as lines proceed
DinoV May 21, 2024
9cddace
Fix issues with inputs longer than a single line
DinoV May 22, 2024
fc4efee
Resize WIP
DinoV May 23, 2024
564e6e1
set compat based on Windows build version
tonybaloney May 24, 2024
3ae4316
use escape sequence for clearing screen and setting cursor position
tonybaloney May 24, 2024
5bb02a2
Remove unused imports
tonybaloney May 24, 2024
500761e
Windows repl support
DinoV May 17, 2024
98f16b9
Arrow key support
DinoV May 18, 2024
911a76a
Make backspace clear char
DinoV May 18, 2024
77f1c42
Fix missing newline after input
DinoV May 18, 2024
243817d
Make insert work
DinoV May 18, 2024
25f51b4
Fix delete in middle
DinoV May 18, 2024
5242239
Fix crash on invalid command key
DinoV May 18, 2024
febe424
More fixes
DinoV May 20, 2024
756ac47
Colorize
DinoV May 20, 2024
50fd4c9
Use constants
DinoV May 20, 2024
ff46d66
Use UnicodeChar
DinoV May 21, 2024
fbb9f84
Simplify
DinoV May 21, 2024
683f5f6
Fix scrolling on input which is longer than screen/scrollback
DinoV May 21, 2024
2c524b8
fix pager typo and refactor some unused branches (#41)
tonybaloney May 20, 2024
44ce57b
Implement screen clear for Windows (#42)
tonybaloney May 20, 2024
5ecc8cd
Fix word wrap not being enabled in Windows Terminal
DinoV May 21, 2024
5bb90c7
Fix issues with inputs longer than a single line
DinoV May 22, 2024
35557dd
Resize WIP
DinoV May 23, 2024
e04699f
Use vt100 scrolling to avoid race conditions on resize
DinoV May 24, 2024
6230400
More win api cleanup
DinoV May 24, 2024
70a9a31
Code cleanup
DinoV May 24, 2024
4adfe77
Reformat
DinoV May 24, 2024
9c00bd1
Annotations
DinoV May 24, 2024
dc7ec86
Update news
DinoV May 24, 2024
79a3fb9
Update history
DinoV May 24, 2024
3e4fe55
Initial test cases
DinoV May 25, 2024
38800e7
📜🤖 Added by blurb_it.
blurb-it[bot] May 25, 2024
b3f7092
Fix mypy and formatting issues
DinoV May 25, 2024
a589321
More mypy fixes
DinoV May 25, 2024
9a34d8a
More MyPy
DinoV May 25, 2024
f8a9176
More MyPy fixes
DinoV May 25, 2024
ce77202
More mypy fixes, name changes in WindowsConsole
DinoV May 26, 2024
6d8e7f5
Fix up ignores
DinoV May 26, 2024
bbbb296
Avoid kernel32 on non-Windows platforms
DinoV May 26, 2024
d064124
Formatting
DinoV May 26, 2024
f244a0e
Merge remote-tracking branch 'dinov/winrepl' into winrepl_control
tonybaloney May 26, 2024
3d526ba
roll back other merge
tonybaloney May 26, 2024
b1f5688
Merge pull request #1 from tonybaloney/winrepl_control
DinoV May 29, 2024
1146dbb
Catch more specific comment, avoid typing, fix comment
DinoV May 29, 2024
972e7ec
Ignore type error on return of Any
DinoV May 29, 2024
1d300e4
Merge branch 'main' of https://github.com/python/cpython into winrepl
DinoV May 29, 2024
d783dae
Don't import traceback on exception
DinoV May 29, 2024
d1289af
Remove one more TYPE_CHECKING
DinoV May 29, 2024
db191a2
Update Lib/test/test_pyrepl/test_windows_console.py
ambv May 30, 2024
fba84aa
Use _WindowsConsoleIO for output
DinoV May 31, 2024
42e3e8e
Merge branch 'winrepl' of github.com:DinoV/cpython into winrepl
DinoV May 31, 2024
63d854e
Remove get_abs_positon
DinoV May 31, 2024
513a148
Fix tests on windows
DinoV May 31, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Make insert work
  • Loading branch information
DinoV committed May 18, 2024
commit aced5ae12a14a5e3f7b13ef2032c51e6cf884a6f
37 changes: 32 additions & 5 deletions Lib/_pyrepl/windows_console.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ class CONSOLE_CURSOR_INFO(Structure):
('bVisible', BOOL),
]

class CHAR_INFO(Structure):
_fields_ = [
('UnicodeChar', WCHAR),
('Attributes', WORD),
]

STD_INPUT_HANDLE = -10
STD_OUTPUT_HANDLE = -11
GetStdHandle = windll.kernel32.GetStdHandle
Expand Down Expand Up @@ -73,9 +79,15 @@ class CONSOLE_CURSOR_INFO(Structure):
SetConsoleCursorPosition.use_last_error = True

FillConsoleOutputCharacter = windll.kernel32.FillConsoleOutputCharacterW
FillConsoleOutputCharacter.use_last_error = True
FillConsoleOutputCharacter.argtypes = [HANDLE, CHAR, DWORD, _COORD, POINTER(DWORD)]
FillConsoleOutputCharacter.restype = BOOL

ScrollConsoleScreenBuffer = windll.kernel32.ScrollConsoleScreenBufferW
ScrollConsoleScreenBuffer.use_last_error = True
ScrollConsoleScreenBuffer.argtypes = [HANDLE, POINTER(SMALL_RECT), POINTER(SMALL_RECT), _COORD, POINTER(CHAR_INFO)]
ScrollConsoleScreenBuffer.rettype = BOOL

class Char(Union):
_fields_ = [
("UnicodeChar",WCHAR),
Expand Down Expand Up @@ -336,7 +348,7 @@ def __write_changed_line(self, y, oldline, newline, px_coord):
x_pos += 1

# if we need to insert a single character right after the first detected change
if oldline[x_pos:] == newline[x_pos + 1 :]: # and self.ich1:
if oldline[x_pos:] == newline[x_pos + 1 :]:
if (
y == self.__posxy[1]
and x_coord > self.__posxy[0]
Expand All @@ -345,9 +357,20 @@ def __write_changed_line(self, y, oldline, newline, px_coord):
x_pos = px_pos
x_coord = px_coord
character_width = wlen(newline[x_pos])
trace('sinle char', x_coord, y, px_coord)

ins_x, ins_y = self.get_abs_position(x_coord + 1, y)
ins_x -= 1
scroll_rect = SMALL_RECT()
scroll_rect.Top = scroll_rect.Bottom = ins_y
scroll_rect.Left = ins_x
scroll_rect.Right = self.getheightwidth()[1] - 1
destination_origin = _COORD(X = scroll_rect.Left + 1, Y = scroll_rect.Top)
fill_info = CHAR_INFO()
fill_info.UnicodeChar = ' '

if not ScrollConsoleScreenBuffer(OutHandle, scroll_rect, None, destination_origin, fill_info):
raise ctypes.WinError(ctypes.GetLastError())
self.__move(x_coord, y)
# self.__write_code(self.ich1)
self.__write(newline[x_pos])
self.__posxy = x_coord + character_width, y

Expand Down Expand Up @@ -418,13 +441,17 @@ def restore(self) -> None: ...

def __move_relative(self, x, y):
trace('move relative', x, y)
cur_x, cur_y = self.get_abs_position(x, y)
trace('move is', cur_x, cur_y)
self.__move_absolute(cur_x, cur_y)

def get_abs_position(self, x: int, y: int) -> tuple[int, int]:
cur_x, cur_y = self.screen_xy
dx = x - self.__posxy[0]
dy = y - self.__posxy[1]
cur_x += dx
cur_y += dy
trace('move is', cur_x, cur_y)
self.__move_absolute(cur_x, cur_y)
return cur_x, cur_y

def __move_absolute(self, x, y):
assert 0 <= y - self.__offset < self.height, y - self.__offset
Expand Down