Skip to content

Commit 00f805f

Browse files
Fix issue where cursor blinker wouldn't automatically start after terminal reset if it was disabled before reset
1 parent d3c34ad commit 00f805f

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ public boolean onContextItemSelected(MenuItem item) {
611611
requestAutoFill();
612612
return true;
613613
case CONTEXT_MENU_RESET_TERMINAL_ID:
614-
resetSession(session);
614+
onResetTerminalSession(session);
615615
return true;
616616
case CONTEXT_MENU_KILL_PROCESS_ID:
617617
showKillSessionDialog(session);
@@ -650,10 +650,13 @@ private void showKillSessionDialog(TerminalSession session) {
650650
b.show();
651651
}
652652

653-
private void resetSession(TerminalSession session) {
653+
private void onResetTerminalSession(TerminalSession session) {
654654
if (session != null) {
655655
session.reset();
656656
showToast(getResources().getString(R.string.msg_terminal_reset), true);
657+
658+
if (mTermuxTerminalSessionClient != null)
659+
mTermuxTerminalSessionClient.onResetTerminalSession();
657660
}
658661
}
659662

app/src/main/java/com/termux/app/terminal/TermuxTerminalSessionClient.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,15 @@ public void onTerminalCursorStateChange(boolean enabled) {
205205
mActivity.getTerminalView().setTerminalCursorBlinkerState(enabled, false);
206206
}
207207

208+
/**
209+
* Should be called when mActivity.onResetTerminalSession() is called
210+
*/
211+
public void onResetTerminalSession() {
212+
// Ensure blinker starts again after reset if cursor blinking was disabled before reset like
213+
// with "tput civis" which would have called onTerminalCursorStateChange()
214+
mActivity.getTerminalView().setTerminalCursorBlinkerState(true, true);
215+
}
216+
208217

209218

210219
@Override

terminal-view/src/main/java/com/termux/view/TerminalView.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -905,6 +905,10 @@ public synchronized boolean setTerminalCursorBlinkerRate(int blinkRate) {
905905
* to be shown. It should also be checked if activity is visible if blinker is to be started
906906
* before calling this.
907907
*
908+
* It should also be called after terminal is reset with {@link TerminalSession#reset()} in case
909+
* cursor blinker was disabled before reset due to call to
910+
* {@link com.termux.terminal.TerminalSessionClient#onTerminalCursorStateChange(boolean)}.
911+
*
908912
* How cursor blinker starting works is by registering a {@link Runnable} with the looper of
909913
* the main thread of the app which when run, toggles the cursor blinking state and re-registers
910914
* itself to be called with the delay set by {@link #mTerminalCursorBlinkerRate}. When cursor

0 commit comments

Comments
 (0)