Files
kte/TerminalFrontend.h
Kyle Isom 12cc04d7e0 Improve input handling and scrolling behavior for high-resolution trackpads.
- Added precise fractional mouse wheel delta handling with per-step command emission.
- Introduced scroll accumulators (`wheel_accum_y_`, `wheel_accum_x_`) for high-resolution trackpad input.
- Replaced hardcoded ESC delay with configurable `kEscDelayMs` constant in `TerminalFrontend`.
- Enabled mouse position reporting and reduced CPU usage during idle with optimized `timeout()` setting.
2025-12-05 20:53:04 -08:00

41 lines
1.0 KiB
C++

/*
* TerminalFrontend - couples TerminalInputHandler + TerminalRenderer and owns ncurses lifecycle
*/
#pragma once
#include <termios.h>
#include <signal.h>
#include "Frontend.h"
#include "TerminalInputHandler.h"
#include "TerminalRenderer.h"
class TerminalFrontend final : public Frontend {
public:
TerminalFrontend() = default;
~TerminalFrontend() override = default;
// Configurable ESC key delay (ms) for ncurses' set_escdelay().
// Controls how long ncurses waits to distinguish ESC vs. meta sequences.
// Adjust if your terminal needs a different threshold.
static constexpr int kEscDelayMs = 50;
bool Init(Editor &ed) override;
void Step(Editor &ed, bool &running) override;
void Shutdown() override;
private:
TerminalInputHandler input_{};
TerminalRenderer renderer_{};
int prev_r_ = 0;
int prev_c_ = 0;
// Saved terminal attributes to restore on shutdown
bool have_orig_tio_ = false;
struct termios orig_tio_{};
// Saved SIGINT handler to restore on shutdown
bool have_old_sigint_ = false;
struct sigaction old_sigint_{};
};