Ran Benita
d8558e87c5
terminalwriter: clean up markup function a bit
2020-04-30 16:44:03 +03:00
Ran Benita
d5584c7207
terminalwriter: compute width_of_current_line lazily
...
Currently this property is computed eagerly, which means
get_line_width() is computed on everything written, but that is a slow
function.
Compute it lazily, so that get_line_width() only runs when needed.
2020-04-30 16:44:03 +03:00
Ran Benita
dd32c72ff0
terminalwriter: remove unused property chars_on_current_line
2020-04-30 16:44:03 +03:00
Ran Benita
1bc4170e63
terminalwriter: don't flush implicitly; add explicit flushes
...
Flushing on every write is somewhat expensive.
Rely on line buffering instead (if line buffering for stdout is
disabled, there must be some reason...), and add explicit flushes when
not outputting lines.
This is how regular `print()` e.g. work so should be familiar.
2020-04-30 16:44:03 +03:00
Ran Benita
d9b43647b7
terminalwriter: inline function _update_chars_on_current_line
2020-04-30 16:44:03 +03:00
Ran Benita
8e04d35a33
terminalwriter: remove unneeded hasattr use
2020-04-30 16:44:03 +03:00
Ran Benita
e8fc5f99fa
terminalwriter: add type annotations
2020-04-30 16:44:03 +03:00
Ran Benita
f6564a548a
terminalwriter: remove win32 specific code in favor of relying on colorama
...
On Windows we already depend on colorama, which takes care of all of
this custom code on its own.
2020-04-30 16:44:03 +03:00
Ran Benita
8d2d1c40f8
terminalwriter: inline function _escaped
...
Doesn't add much.
2020-04-30 16:44:03 +03:00
Ran Benita
66ee755649
terminalwriter: remove TerminalWriter's stringio argument
...
Had a mark indicating it should be removed, and I agree, it's better to
just use the `file` argument.
2020-04-30 16:44:02 +03:00
Ran Benita
94a57d2353
io: combine _io.TerminalWriter and _io.terminalwriter.TerminalWriter
...
Previously it extended an external type but now it come move to the type
itself.
2020-04-30 16:44:02 +03:00
Ran Benita
dac05ccd9a
terminalwriter: remove support for passing callable as file in TerminalWriter
...
Not used.
2020-04-30 16:44:02 +03:00
Ran Benita
0528307ebf
terminalwriter: remove unused function TerminalWriter.reline
2020-04-30 16:44:02 +03:00
Ran Benita
a6819726cd
terminalwriter: remove unused function ansi_print
2020-04-30 16:44:02 +03:00
Ran Benita
b6cc90e0af
terminalwriter: remove support for writing bytes directly
...
It is not used and slows things down.
2020-04-30 16:44:02 +03:00
Ran Benita
9a59970cad
terminalwriter: optimize get_line_width() a bit
...
This function is called a lot when printing a lot of text, and is very
slow -- this speeds it up a bit.
2020-04-30 16:44:02 +03:00
Ran Benita
6c1b6a09b8
terminalwriter: simplify get_terminal_width()
...
The shutil.get_terminal_size() handles everything this did already.
2020-04-30 16:44:02 +03:00
Ran Benita
c749e44efc
terminalwriter: remove custom win32 screen width code
...
Python 3 does this on its own so we can use the shared code:
bcf2b59fb5
2020-04-30 16:44:02 +03:00
Ran Benita
1d596b27a7
terminalwriter: move Win32ConsoleWriter definition under win32 conditional
...
This way non-Windows platforms skip it. It also uses things defined
inside the `if`.
2020-04-30 16:44:02 +03:00
Ran Benita
5e2d820308
terminalwriter: fix lints
2020-04-30 16:44:02 +03:00
Ran Benita
3014d9a3f7
terminalwriter: auto-format
2020-04-30 16:43:55 +03:00
Ran Benita
276405a039
terminalwriter: vendor TerminalWriter from py
...
Straight copy from py 1.8.1. Doesn't pass linting yet.
2020-04-30 16:43:54 +03:00