mirror of
https://github.com/fankes/termux-app.git
synced 2025-09-06 10:45:23 +08:00
Fix issue where terminal cursor blinking would not automatically start again if termux activity was restarted after exiting it with double back press
This commit is contained in:
@@ -60,6 +60,8 @@ public class TermuxTerminalViewClient extends TermuxTerminalViewClientBase {
|
|||||||
private boolean mShowSoftKeyboardIgnoreOnce;
|
private boolean mShowSoftKeyboardIgnoreOnce;
|
||||||
private boolean mShowSoftKeyboardWithDelayOnce;
|
private boolean mShowSoftKeyboardWithDelayOnce;
|
||||||
|
|
||||||
|
private boolean mTerminalCursorBlinkerStateAlreadySet;
|
||||||
|
|
||||||
private static final String LOG_TAG = "TermuxTerminalViewClient";
|
private static final String LOG_TAG = "TermuxTerminalViewClient";
|
||||||
|
|
||||||
public TermuxTerminalViewClient(TermuxActivity activity, TermuxTerminalSessionClient termuxTerminalSessionClient) {
|
public TermuxTerminalViewClient(TermuxActivity activity, TermuxTerminalSessionClient termuxTerminalSessionClient) {
|
||||||
@@ -95,8 +97,7 @@ public class TermuxTerminalViewClient extends TermuxTerminalViewClientBase {
|
|||||||
// Show the soft keyboard if required
|
// Show the soft keyboard if required
|
||||||
setSoftKeyboardState(true, false);
|
setSoftKeyboardState(true, false);
|
||||||
|
|
||||||
// Start terminal cursor blinking if enabled
|
mTerminalCursorBlinkerStateAlreadySet = false;
|
||||||
setTerminalCursorBlinkerState(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -118,6 +119,23 @@ public class TermuxTerminalViewClient extends TermuxTerminalViewClientBase {
|
|||||||
setTerminalCursorBlinkerState(true);
|
setTerminalCursorBlinkerState(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Should be called when {@link com.termux.view.TerminalView#mEmulator}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void onEmulatorSet() {
|
||||||
|
if (!mTerminalCursorBlinkerStateAlreadySet) {
|
||||||
|
// Start terminal cursor blinking if enabled
|
||||||
|
// We need to wait for the first session to be attached that's set in
|
||||||
|
// TermuxActivity.onServiceConnected() and then the multiple calls to TerminalView.updateSize()
|
||||||
|
// where the final one eventually sets the mEmulator when width/height is not 0. Otherwise
|
||||||
|
// blinker will not start again if TermuxActivity is started again after exiting it with
|
||||||
|
// double back press. Check TerminalView.setTerminalCursorBlinkerState().
|
||||||
|
setTerminalCursorBlinkerState(true);
|
||||||
|
mTerminalCursorBlinkerStateAlreadySet = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -322,6 +322,7 @@ public final class TerminalEmulator {
|
|||||||
public void updateTerminalSessionClient(TerminalSessionClient client) {
|
public void updateTerminalSessionClient(TerminalSessionClient client) {
|
||||||
mClient = client;
|
mClient = client;
|
||||||
setCursorStyle();
|
setCursorStyle();
|
||||||
|
setCursorBlinkState(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TerminalBuffer getScreen() {
|
public TerminalBuffer getScreen() {
|
||||||
|
@@ -755,6 +755,7 @@ public final class TerminalView extends View {
|
|||||||
if (mEmulator == null || (newColumns != mEmulator.mColumns || newRows != mEmulator.mRows)) {
|
if (mEmulator == null || (newColumns != mEmulator.mColumns || newRows != mEmulator.mRows)) {
|
||||||
mTermSession.updateSize(newColumns, newRows);
|
mTermSession.updateSize(newColumns, newRows);
|
||||||
mEmulator = mTermSession.getEmulator();
|
mEmulator = mTermSession.getEmulator();
|
||||||
|
mClient.onEmulatorSet();
|
||||||
|
|
||||||
mTopRow = 0;
|
mTopRow = 0;
|
||||||
scrollTo(0, 0);
|
scrollTo(0, 0);
|
||||||
@@ -880,7 +881,13 @@ public final class TerminalView extends View {
|
|||||||
* {@link #TERMINAL_CURSOR_BLINK_RATE_MIN} and {@link #TERMINAL_CURSOR_BLINK_RATE_MAX}.
|
* {@link #TERMINAL_CURSOR_BLINK_RATE_MIN} and {@link #TERMINAL_CURSOR_BLINK_RATE_MAX}.
|
||||||
*
|
*
|
||||||
* This should be called when the view holding this activity is resumed or stopped so that
|
* This should be called when the view holding this activity is resumed or stopped so that
|
||||||
* cursor blinker does not run when activity is not visible.
|
* cursor blinker does not run when activity is not visible. Ensure that {@link #mEmulator}
|
||||||
|
* is set when you call this to start cursor blinking by waiting for {@link TerminalViewClient#onEmulatorSet()}
|
||||||
|
* event after calling {@link #attachSession(TerminalSession)} for the first session added in the
|
||||||
|
* activity, otherwise blinking will not start. Do not call this directly after
|
||||||
|
* {@link #attachSession(TerminalSession)} since {@link #updateSize()} may return without
|
||||||
|
* setting {@link #mEmulator} since width/height may be 0. Its called again in
|
||||||
|
* {@link #onSizeChanged(int, int, int, int)}.
|
||||||
*
|
*
|
||||||
* It should also be called on the
|
* It should also be called on the
|
||||||
* {@link com.termux.terminal.TerminalSessionClient#onTerminalCursorStateChange(boolean)}
|
* {@link com.termux.terminal.TerminalSessionClient#onTerminalCursorStateChange(boolean)}
|
||||||
|
@@ -56,6 +56,8 @@ public interface TerminalViewClient {
|
|||||||
boolean onCodePoint(int codePoint, boolean ctrlDown, TerminalSession session);
|
boolean onCodePoint(int codePoint, boolean ctrlDown, TerminalSession session);
|
||||||
|
|
||||||
|
|
||||||
|
void onEmulatorSet();
|
||||||
|
|
||||||
|
|
||||||
void logError(String tag, String message);
|
void logError(String tag, String message);
|
||||||
|
|
||||||
|
@@ -67,6 +67,11 @@ public class TermuxTerminalViewClientBase implements TerminalViewClient {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEmulatorSet() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void logError(String tag, String message) {
|
public void logError(String tag, String message) {
|
||||||
Logger.logError(tag, message);
|
Logger.logError(tag, message);
|
||||||
|
Reference in New Issue
Block a user