Skip to content
Myr

tty_windows.go

This file

Path

tty_windows.go

64 lines · 1.8 KiB · Go

Last changed by

Merge pull request #1118 from charmbracelet/v2-expAyman Bagabasbefore adoptiond1c8c97

History of this file

Take it

The walk stopped after 200 commits: lines older than 3dfbcd9 point at it.

feat(render): skipping lines from previous frameKonstantin Antonovbefore adoption3dfbcd9

lines 1–20why, one step back
1//go:build windows
2// +build windows34package tea56import (7 "fmt"89 "github.com/charmbracelet/x/term"10 "golang.org/x/sys/windows"11)1213func (p *Program) initInput() (err error) {14 // Save stdin state and enable VT input15 // We also need to enable VT16 // input here.17 if f, ok := p.input.(term.File); ok && term.IsTerminal(f.Fd()) {18 p.ttyInput = f19 p.previousTtyInputState, err = term.MakeRaw(p.ttyInput.Fd())20 if err != nil {

Merge pull request #1118 from charmbracelet/v2-expAyman Bagabasbefore adoptiond1c8c97

line 21why, one step back
21 return fmt.Errorf("error making terminal raw: %w", err)

feat(render): skipping lines from previous frameKonstantin Antonovbefore adoption3dfbcd9

lines 22–39why, one step back
22 }
2324 // Enable VT input25 var mode uint3226 if err := windows.GetConsoleMode(windows.Handle(p.ttyInput.Fd()), &mode); err != nil {27 return fmt.Errorf("error getting console mode: %w", err)28 }2930 if err := windows.SetConsoleMode(windows.Handle(p.ttyInput.Fd()), mode|windows.ENABLE_VIRTUAL_TERMINAL_INPUT); err != nil {31 return fmt.Errorf("error setting console mode: %w", err)32 }33 }3435 // Save output screen buffer state and enable VT processing.36 if f, ok := p.output.(term.File); ok && term.IsTerminal(f.Fd()) {37 p.ttyOutput = f38 p.previousOutputState, err = term.GetState(f.Fd())39 if err != nil {

Merge pull request #1118 from charmbracelet/v2-expAyman Bagabasbefore adoptiond1c8c97

line 40why, one step back
40 return fmt.Errorf("error getting terminal state: %w", err)

feat(render): skipping lines from previous frameKonstantin Antonovbefore adoption3dfbcd9

lines 41–47why, one step back
41 }
4243 var mode uint3244 if err := windows.GetConsoleMode(windows.Handle(p.ttyOutput.Fd()), &mode); err != nil {45 return fmt.Errorf("error getting console mode: %w", err)46 }47

Merge pull request #1118 from charmbracelet/v2-expAyman Bagabasbefore adoptiond1c8c97

lines 48–50why, one step back
48 if err := windows.SetConsoleMode(windows.Handle(p.ttyOutput.Fd()),
49 mode|windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING|50 windows.DISABLE_NEWLINE_AUTO_RETURN); err != nil {

feat(render): skipping lines from previous frameKonstantin Antonovbefore adoption3dfbcd9

lines 51–53why, one step back
51 return fmt.Errorf("error setting console mode: %w", err)
52 }53

Merge pull request #1118 from charmbracelet/v2-expAyman Bagabasbefore adoptiond1c8c97

lines 54–56why, one step back
54 //nolint:godox
55 // TODO: check if we can optimize cursor movements on Windows.56 p.checkOptimizedMovements(p.previousOutputState)

feat(render): skipping lines from previous frameKonstantin Antonovbefore adoption3dfbcd9

line 57why, one step back
57 }

Merge pull request #1118 from charmbracelet/v2-expAyman Bagabasbefore adoptiond1c8c97

lines 58–59why, one step back
58
59 return //nolint:nakedret

feat(render): skipping lines from previous frameKonstantin Antonovbefore adoption3dfbcd9

lines 60–64why, one step back
60}
6162const suspendSupported = false6364func suspendProcess() {}