Skip to content

Commit

Permalink
build escape sequence state machine at startup
Browse files Browse the repository at this point in the history
  • Loading branch information
poderosaproject committed Dec 1, 2024
1 parent ceec928 commit b5a38de
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
15 changes: 11 additions & 4 deletions TerminalEmulator/EscapeSequenceEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1309,6 +1309,17 @@ public EscapeSequenceEngine(
Action<IEscapeSequenceContext> incompleteHandler,
Action<Exception, IEscapeSequenceContext> exceptionHandler
) {
BuildStateMachine();
_currentState = _root;
_completedHandler = completedHandler;
_incompleteHandler = incompleteHandler;
_exceptionHandler = exceptionHandler;
}

/// <summary>
/// Build global instance of the state machine
/// </summary>
public static void BuildStateMachine() {
lock (_initializeSync) {
if (!_initialized) {
#if DEBUG
Expand All @@ -1327,10 +1338,6 @@ Action<Exception, IEscapeSequenceContext> exceptionHandler
#endif
}
}
_currentState = _root;
_completedHandler = completedHandler;
_incompleteHandler = incompleteHandler;
_exceptionHandler = exceptionHandler;
}

/// <summary>
Expand Down
3 changes: 3 additions & 0 deletions TerminalEmulator/TerminalEmulatorPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ public override void InitializePlugin(IPoderosaWorld poderosa) {

// Initialize Unicode table
Poderosa.Document.Unicode.Initialize();

// Prepare EscapeSequenceEngine for XTerm
EscapeSequence.EscapeSequenceEngine<XTerm>.BuildStateMachine();
}

#if UNITTEST
Expand Down

0 comments on commit b5a38de

Please sign in to comment.