Skip to content
Closed
Changes from all commits
Commits
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
28 changes: 26 additions & 2 deletions addon/globalPlugins/virtualRevision.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,30 @@
except:
SCRCAT_TEXTREVIEW = None

def _isDecorativeTerminalLine(line):
# True for lines whose only non-whitespace characters are in the Unicode Box Drawing
# block (U+2500-U+257F): the borders, separators, and corners that TUI apps paint.
# Content lines that happen to contain a "│" border still survive because the
# letters/digits inside fall outside the range.
stripped = line.strip()
if not stripped:
return True
return all("─" <= ch <= "╿" for ch in stripped)

def _cleanTerminalText(text):
# Terminal cells are space-padded to the column width, and TUI apps reserve fixed
# rows/columns for borders, status bars, input, etc. Captured as a UNIT_STORY this
# turns into long runs of blank padding and box-border-only lines that bury the actual
# content when the review window is navigated line by line. Strip per-line trailing
# whitespace and drop lines that carry no real content.
lines = []
for line in text.split("\n"):
stripped = line.rstrip()
if _isDecorativeTerminalLine(stripped):
continue
lines.append(stripped)
return "\n".join(lines)

def obtainUWPWindowText():
foreground = api.getForegroundObject()
desktop = api.getDesktopObject()
Expand All @@ -28,7 +52,7 @@ def obtainUWPWindowText():
if hasattr(curObject, "UIAElement") and curObject.UIAElement and curObject.UIAElement.currentClassName == "TermControl":
info = curObject.makeTextInfo(textInfos.POSITION_FIRST)
info.expand(textInfos.UNIT_STORY)
text = info.clipboardText.rstrip()
text = _cleanTerminalText(info.clipboardText)
uwpTextList.append(text)
if curObject.simpleFirstChild:
curObject=curObject.simpleFirstChild
Expand All @@ -52,7 +76,7 @@ def obtainUWPWindowText():
if hasattr(foreground, "UIAElement") and foreground.UIAElement and foreground.UIAElement.currentClassName == "TermControl":
info = foreground.makeTextInfo(textInfos.POSITION_FIRST)
info.expand(textInfos.UNIT_STORY)
text = info.clipboardText.rstrip()
text = _cleanTerminalText(info.clipboardText)
uwpTextList.append(text)
return uwpTextList

Expand Down