Skip to content

Commit

Permalink
Fix issue where cursor blinker wouldn't automatically start after ter…
Browse files Browse the repository at this point in the history
…minal reset if it was disabled before reset
  • Loading branch information
agnostic-apollo committed Jun 28, 2021
1 parent d3c34ad commit 00f805f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
7 changes: 5 additions & 2 deletions app/src/main/java/com/termux/app/TermuxActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ public boolean onContextItemSelected(MenuItem item) {
requestAutoFill();
return true;
case CONTEXT_MENU_RESET_TERMINAL_ID:
resetSession(session);
onResetTerminalSession(session);
return true;
case CONTEXT_MENU_KILL_PROCESS_ID:
showKillSessionDialog(session);
Expand Down Expand Up @@ -650,10 +650,13 @@ private void showKillSessionDialog(TerminalSession session) {
b.show();
}

private void resetSession(TerminalSession session) {
private void onResetTerminalSession(TerminalSession session) {
if (session != null) {
session.reset();
showToast(getResources().getString(R.string.msg_terminal_reset), true);

if (mTermuxTerminalSessionClient != null)
mTermuxTerminalSessionClient.onResetTerminalSession();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,15 @@ public void onTerminalCursorStateChange(boolean enabled) {
mActivity.getTerminalView().setTerminalCursorBlinkerState(enabled, false);
}

/**
* Should be called when mActivity.onResetTerminalSession() is called
*/
public void onResetTerminalSession() {
// Ensure blinker starts again after reset if cursor blinking was disabled before reset like
// with "tput civis" which would have called onTerminalCursorStateChange()
mActivity.getTerminalView().setTerminalCursorBlinkerState(true, true);
}



@Override
Expand Down
4 changes: 4 additions & 0 deletions terminal-view/src/main/java/com/termux/view/TerminalView.java
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,10 @@ public synchronized boolean setTerminalCursorBlinkerRate(int blinkRate) {
* to be shown. It should also be checked if activity is visible if blinker is to be started
* before calling this.
*
* It should also be called after terminal is reset with {@link TerminalSession#reset()} in case
* cursor blinker was disabled before reset due to call to
* {@link com.termux.terminal.TerminalSessionClient#onTerminalCursorStateChange(boolean)}.
*
* How cursor blinker starting works is by registering a {@link Runnable} with the looper of
* the main thread of the app which when run, toggles the cursor blinking state and re-registers
* itself to be called with the delay set by {@link #mTerminalCursorBlinkerRate}. When cursor
Expand Down

0 comments on commit 00f805f

Please sign in to comment.