Skip to content

Commit 370ac2b

Browse files
committed
Avoid joining lines for shared transcript (#1166)
1 parent 7041f41 commit 370ac2b

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

app/src/main/java/com/termux/app/TermuxActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,7 @@ public boolean onContextItemSelected(MenuItem item) {
722722
if (session != null) {
723723
Intent intent = new Intent(Intent.ACTION_SEND);
724724
intent.setType("text/plain");
725-
String transcriptText = session.getEmulator().getScreen().getTranscriptText().trim();
725+
String transcriptText = session.getEmulator().getScreen().getTranscriptTextWithoutJoinedLines().trim();
726726
// See https://github.com/termux/termux-app/issues/1166.
727727
final int MAX_LENGTH = 100_000;
728728
if (transcriptText.length() > MAX_LENGTH) {

terminal-emulator/src/main/java/com/termux/terminal/TerminalBuffer.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,15 @@ public String getTranscriptText() {
4141
return getSelectedText(0, -getActiveTranscriptRows(), mColumns, mScreenRows).trim();
4242
}
4343

44+
public String getTranscriptTextWithoutJoinedLines() {
45+
return getSelectedText(0, -getActiveTranscriptRows(), mColumns, mScreenRows, false).trim();
46+
}
47+
4448
public String getSelectedText(int selX1, int selY1, int selX2, int selY2) {
49+
return getSelectedText(selX1, selY1, selX2, selY2, true);
50+
}
51+
52+
public String getSelectedText(int selX1, int selY1, int selX2, int selY2, boolean joinBackLines) {
4553
final StringBuilder builder = new StringBuilder();
4654
final int columns = mColumns;
4755

@@ -79,7 +87,8 @@ public String getSelectedText(int selX1, int selY1, int selX2, int selY2) {
7987
}
8088
if (lastPrintingCharIndex != -1)
8189
builder.append(line, x1Index, lastPrintingCharIndex - x1Index + 1);
82-
if (!rowLineWrap && row < selY2 && row < mScreenRows - 1) builder.append('\n');
90+
if ((!joinBackLines || !rowLineWrap)
91+
&& row < selY2 && row < mScreenRows - 1) builder.append('\n');
8392
}
8493
return builder.toString();
8594
}

0 commit comments

Comments
 (0)