chore: import official kitty sources from upstream
Bring the kovidgoyal/kitty codebase in as the base of FWS-Kitty, vendored at upstream commit 91fb38a without its git history.
This commit is contained in:
1134 files changed
+433629
No files matched your search
@@ -0,0 +1,50 @@
|
||||
// License: GPLv3 Copyright: 2026, Kovid Goyal, <kovid at kovidgoyal.net>
|
||||
|
||||
package resize_window
|
||||
|
||||
import "github.com/kovidgoyal/kitty/tools/tui/loop"
|
||||
|
||||
// Edge interaction uses these hooks while settings keys and persistence are
|
||||
// shared with Window resizing.
|
||||
type strategy_hooks struct {
|
||||
OnActivate func(*handler) error
|
||||
OnDeactivate func(*handler) error
|
||||
OnSettings func(*handler)
|
||||
OnKey func(*handler, *loop.KeyEvent) error
|
||||
OnText func(*handler, string) error
|
||||
OnResponse func(*handler, rc_response) (bool, error)
|
||||
Draw func(*handler)
|
||||
}
|
||||
|
||||
var edge_strategy *strategy_hooks
|
||||
|
||||
func (h *handler) active_strategy() string {
|
||||
if h.settings.Strategy == "edge" {
|
||||
return "edge"
|
||||
}
|
||||
return "window"
|
||||
}
|
||||
|
||||
func (h *handler) active_hooks() *strategy_hooks {
|
||||
if h.active_strategy() == "edge" {
|
||||
return edge_strategy
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (h *handler) active_preferences() strategy_settings {
|
||||
return h.settings.preferences(h.active_strategy())
|
||||
}
|
||||
|
||||
// Also used by an edge strategy when turning a key into a move request.
|
||||
func (h *handler) resize_step(mods loop.KeyModifiers) (multiplier int, fraction float64) {
|
||||
mods &= ^(loop.CAPS_LOCK | loop.NUM_LOCK)
|
||||
if mods == loop.CTRL {
|
||||
return 2, 0
|
||||
}
|
||||
p := h.active_preferences()
|
||||
if (p.Modifier == "alt" && mods == loop.ALT) || (p.Modifier == "shift" && mods == loop.SHIFT) {
|
||||
return 1, h.fraction
|
||||
}
|
||||
return 1, 0
|
||||
}
|
||||
Reference in new issue
Block a user