ARB Patcher: make status line respect terminal width
This commit is contained in:
@@ -98,7 +98,7 @@ def patch_shader(fname, f_lines, game_settings_module=None, enable_print_warning
|
|||||||
return f_full
|
return f_full
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
from os import listdir, makedirs
|
from os import listdir, makedirs, get_terminal_size
|
||||||
from os.path import join as joinpath, splitext, isfile, exists, dirname
|
from os.path import join as joinpath, splitext, isfile, exists, dirname
|
||||||
from re import compile as recompile
|
from re import compile as recompile
|
||||||
import sys
|
import sys
|
||||||
@@ -207,6 +207,14 @@ if __name__ == '__main__':
|
|||||||
status_str += ' {:.2%}'.format(progress_val)
|
status_str += ' {:.2%}'.format(progress_val)
|
||||||
status_str += ' ' + fname
|
status_str += ' ' + fname
|
||||||
|
|
||||||
|
try:
|
||||||
|
terminal_width = get_terminal_size()[0]
|
||||||
|
except:
|
||||||
|
terminal_width = 120
|
||||||
|
|
||||||
|
if len(status_str) > terminal_width:
|
||||||
|
status_str = status_str[:terminal_width-3] + '...'
|
||||||
|
|
||||||
# fix characters left on screen from a previous longer line
|
# fix characters left on screen from a previous longer line
|
||||||
# (without cursor staying off to the side)
|
# (without cursor staying off to the side)
|
||||||
this_status_len = len(status_str)
|
this_status_len = len(status_str)
|
||||||
|
|||||||
Reference in New Issue
Block a user