mirror of
https://github.com/db9979/sshtermy.git
synced 2026-12-06 04:34:08 +01:00
- internal/importer: ~/.ssh/config (Include, Host-Muster, ProxyJump, IdentityFile), PuTTY (Registry unter Windows, .reg-Export überall), MobaXterm (ini/.mxtsessions, Ordner, SSH-Gateway). Vorhandene Ziele werden erkannt, Jump-Hosts verknüpft. - Manager: i importieren, a Aussehen wechseln, b Tastenkürzel anpassen; auch in der Palette. - Themes Dunkel, Hell, Hochkontrast inkl. passender Eingabefelder und Terminal-Vordergrund. - Tastenkürzel pro Aktion belegbar (Settings.Keys, mit Sync), Konflikte werden markiert, Hilfe und Fußzeilen zeigen die eigene Belegung. - Alt+Enter nicht mehr belegt (Windows Terminal Vollbild); neue Zeile: Shift+Enter / Strg+J. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018i4GUk49WhmNoB29BT6Hiq
86 lines
2.6 KiB
Go
86 lines
2.6 KiB
Go
package ui
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"charm.land/bubbles/v2/key"
|
|
"charm.land/bubbles/v2/textarea"
|
|
tea "charm.land/bubbletea/v2"
|
|
"charm.land/lipgloss/v2"
|
|
)
|
|
|
|
// aiInputMaxRows: so hoch wächst ein KI-Eingabefeld höchstens, danach
|
|
// scrollt es innerhalb des Felds.
|
|
const aiInputMaxRows = 8
|
|
|
|
// aiInput ist das Eingabefeld für Ziele, Fragen und die Palette: Der Text
|
|
// bricht automatisch um und das Feld wächst mit, statt horizontal zu
|
|
// scrollen. ⏎ wertet der Aufrufer aus (senden), Shift+⏎ / Strg+J (frei belegbar)
|
|
// fügt eine neue Zeile ein.
|
|
type aiInput struct {
|
|
textarea.Model
|
|
singleLine bool // z. B. Befehl bearbeiten: umbrechen ja, Zeilenumbruch nein
|
|
}
|
|
|
|
func newAIInput(placeholder string) aiInput {
|
|
ta := textarea.New()
|
|
ta.Prompt = ""
|
|
ta.ShowLineNumbers = false
|
|
ta.Placeholder = placeholder
|
|
ta.CharLimit = 8000
|
|
ta.DynamicHeight = true
|
|
ta.MinHeight = 1
|
|
ta.MaxHeight = aiInputMaxRows
|
|
ta.MaxContentHeight = 400
|
|
ta.EndOfBufferCharacter = ' '
|
|
// Kein Alt+⏎: das schaltet Windows Terminal auf Vollbild.
|
|
ta.KeyMap.InsertNewline = key.NewBinding(key.WithKeys(activeKeys.keys[actNewline]...))
|
|
|
|
t := activeTheme
|
|
sty := textarea.DefaultStyles(t.Dark)
|
|
sty.Focused.Text = lipgloss.NewStyle().Foreground(t.Text)
|
|
sty.Blurred.Text = lipgloss.NewStyle().Foreground(t.Muted)
|
|
sty.Focused.Placeholder = lipgloss.NewStyle().Foreground(t.Muted)
|
|
sty.Blurred.Placeholder = sty.Focused.Placeholder
|
|
sty.Cursor.Color = t.Accent
|
|
plain := lipgloss.NewStyle()
|
|
sty.Focused.CursorLine = plain
|
|
sty.Focused.EndOfBuffer = plain
|
|
sty.Blurred.CursorLine = plain
|
|
sty.Blurred.EndOfBuffer = plain
|
|
ta.SetStyles(sty)
|
|
ta.SetWidth(40)
|
|
return aiInput{Model: ta}
|
|
}
|
|
|
|
// newCommandInput: bricht um, erlaubt aber keine Zeilenumbrüche (ein Befehl).
|
|
func newCommandInput() aiInput {
|
|
in := newAIInput("")
|
|
in.singleLine = true
|
|
in.KeyMap.InsertNewline.SetEnabled(false)
|
|
return in
|
|
}
|
|
|
|
func (in aiInput) Update(msg tea.Msg) (aiInput, tea.Cmd) {
|
|
var cmd tea.Cmd
|
|
in.Model, cmd = in.Model.Update(msg)
|
|
if in.singleLine {
|
|
if v := in.Model.Value(); strings.ContainsAny(v, "\r\n") {
|
|
in.Model.SetValue(strings.Join(strings.Fields(v), " "))
|
|
}
|
|
}
|
|
return in, cmd
|
|
}
|
|
|
|
// CursorEnd setzt den Cursor ans Ende des gesamten Texts (wie bei textinput).
|
|
func (in *aiInput) CursorEnd() { in.Model.MoveToEnd() }
|
|
|
|
// promptBlock setzt ein Präfix wie „› “ vor ein (evtl. mehrzeiliges) Feld,
|
|
// sodass Folgezeilen bündig eingerückt bleiben.
|
|
func promptBlock(prefix, view string) string {
|
|
return lipgloss.JoinHorizontal(lipgloss.Top, prefix, view)
|
|
}
|
|
|
|
// oneLine fasst mehrzeiligen Text für Listen-Beschriftungen zusammen.
|
|
func oneLine(s string) string { return strings.Join(strings.Fields(s), " ") }
|