182 if not c and not curses.tigetstr(pycompat.sysstr(e)): |
182 if not c and not curses.tigetstr(pycompat.sysstr(e)): |
183 # Most terminals don't support dim, invis, etc, so don't be |
183 # Most terminals don't support dim, invis, etc, so don't be |
184 # noisy and use ui.debug(). |
184 # noisy and use ui.debug(). |
185 ui.debug(b"no terminfo entry for %s\n" % e) |
185 ui.debug(b"no terminfo entry for %s\n" % e) |
186 del ui._terminfoparams[key] |
186 del ui._terminfoparams[key] |
187 if not curses.tigetstr(r'setaf') or not curses.tigetstr(r'setab'): |
187 if not curses.tigetstr('setaf') or not curses.tigetstr('setab'): |
188 # Only warn about missing terminfo entries if we explicitly asked for |
188 # Only warn about missing terminfo entries if we explicitly asked for |
189 # terminfo mode and we're in a formatted terminal. |
189 # terminfo mode and we're in a formatted terminal. |
190 if mode == b"terminfo" and formatted: |
190 if mode == b"terminfo" and formatted: |
191 ui.warn( |
191 ui.warn( |
192 _( |
192 _( |
351 if termcode: |
351 if termcode: |
352 return termcode |
352 return termcode |
353 else: |
353 else: |
354 return curses.tigetstr(pycompat.sysstr(val)) |
354 return curses.tigetstr(pycompat.sysstr(val)) |
355 elif bg: |
355 elif bg: |
356 return curses.tparm(curses.tigetstr(r'setab'), val) |
356 return curses.tparm(curses.tigetstr('setab'), val) |
357 else: |
357 else: |
358 return curses.tparm(curses.tigetstr(r'setaf'), val) |
358 return curses.tparm(curses.tigetstr('setaf'), val) |
359 |
359 |
360 |
360 |
361 def _mergeeffects(text, start, stop): |
361 def _mergeeffects(text, start, stop): |
362 """Insert start sequence at every occurrence of stop sequence |
362 """Insert start sequence at every occurrence of stop sequence |
363 |
363 |
440 _WORD = ctypes.c_ushort |
440 _WORD = ctypes.c_ushort |
441 |
441 |
442 _INVALID_HANDLE_VALUE = -1 |
442 _INVALID_HANDLE_VALUE = -1 |
443 |
443 |
444 class _COORD(ctypes.Structure): |
444 class _COORD(ctypes.Structure): |
445 _fields_ = [(r'X', ctypes.c_short), (r'Y', ctypes.c_short)] |
445 _fields_ = [('X', ctypes.c_short), ('Y', ctypes.c_short)] |
446 |
446 |
447 class _SMALL_RECT(ctypes.Structure): |
447 class _SMALL_RECT(ctypes.Structure): |
448 _fields_ = [ |
448 _fields_ = [ |
449 (r'Left', ctypes.c_short), |
449 ('Left', ctypes.c_short), |
450 (r'Top', ctypes.c_short), |
450 ('Top', ctypes.c_short), |
451 (r'Right', ctypes.c_short), |
451 ('Right', ctypes.c_short), |
452 (r'Bottom', ctypes.c_short), |
452 ('Bottom', ctypes.c_short), |
453 ] |
453 ] |
454 |
454 |
455 class _CONSOLE_SCREEN_BUFFER_INFO(ctypes.Structure): |
455 class _CONSOLE_SCREEN_BUFFER_INFO(ctypes.Structure): |
456 _fields_ = [ |
456 _fields_ = [ |
457 (r'dwSize', _COORD), |
457 ('dwSize', _COORD), |
458 (r'dwCursorPosition', _COORD), |
458 ('dwCursorPosition', _COORD), |
459 (r'wAttributes', _WORD), |
459 ('wAttributes', _WORD), |
460 (r'srWindow', _SMALL_RECT), |
460 ('srWindow', _SMALL_RECT), |
461 (r'dwMaximumWindowSize', _COORD), |
461 ('dwMaximumWindowSize', _COORD), |
462 ] |
462 ] |
463 |
463 |
464 _STD_OUTPUT_HANDLE = 0xFFFFFFF5 # (DWORD)-11 |
464 _STD_OUTPUT_HANDLE = 0xFFFFFFF5 # (DWORD)-11 |
465 _STD_ERROR_HANDLE = 0xFFFFFFF4 # (DWORD)-12 |
465 _STD_ERROR_HANDLE = 0xFFFFFFF4 # (DWORD)-12 |
466 |
466 |
527 ansire = re.compile( |
527 ansire = re.compile( |
528 br'\033\[([^m]*)m([^\033]*)(.*)', re.MULTILINE | re.DOTALL |
528 br'\033\[([^m]*)m([^\033]*)(.*)', re.MULTILINE | re.DOTALL |
529 ) |
529 ) |
530 |
530 |
531 def win32print(ui, writefunc, text, **opts): |
531 def win32print(ui, writefunc, text, **opts): |
532 label = opts.get(r'label', b'') |
532 label = opts.get('label', b'') |
533 attr = origattr |
533 attr = origattr |
534 |
534 |
535 def mapcolor(val, attr): |
535 def mapcolor(val, attr): |
536 if val == -1: |
536 if val == -1: |
537 return origattr |
537 return origattr |