This repository was archived by the owner on Aug 30, 2024. It is now read-only.
- Notifications
You must be signed in to change notification settings - Fork18
Adds support for windows#79
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
3 commits Select commitHold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Empty file added.github/workflows/test.yaml
Empty file.
1 change: 1 addition & 0 deletionsci/build.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletionscmd/coder/main.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
82 changes: 36 additions & 46 deletionscmd/coder/shell.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletiongo.mod
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
8 changes: 2 additions & 6 deletionsgo.sum
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletionsinternal/xterminal/doc.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Package xterminal provides functions to change termios or console attributes | ||
// and restore them later on. It supports Unix and Windows. | ||
// | ||
// This does the same thing as x/crypto/ssh/terminal on Linux. On Windows, it | ||
// sets the same console modes as the terminal package but also sets | ||
// `ENABLE_VIRTUAL_TERMINAL_INPUT` and `ENABLE_VIRTUAL_TERMINAL_PROCESSING` to | ||
// allow for VT100 sequences in the console. This is important, otherwise Linux | ||
// apps (with colors or ncurses) that are run through SSH or wsep get | ||
// garbled in a Windows console. | ||
// | ||
// More details can be found out about Windows console modes here: | ||
// https://docs.microsoft.com/en-us/windows/console/setconsolemode | ||
package xterminal |
71 changes: 71 additions & 0 deletionsinternal/xterminal/terminal.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// +build !windows | ||
package xterminal | ||
import ( | ||
"context" | ||
"os" | ||
"os/signal" | ||
"golang.org/x/crypto/ssh/terminal" | ||
"golang.org/x/sys/unix" | ||
) | ||
// State differs per-platform. | ||
type State struct { | ||
s *terminal.State | ||
} | ||
// MakeRaw sets the terminal to raw. | ||
func MakeRaw(fd uintptr) (*State, error) { | ||
s, err := terminal.MakeRaw(int(fd)) | ||
return &State{s}, err | ||
} | ||
// MakeOutputRaw does nothing on non-Windows platforms. | ||
func MakeOutputRaw(fd uintptr) (*State, error) { | ||
return nil, nil | ||
} | ||
// Restore terminal back to original state. | ||
func Restore(fd uintptr, state *State) error { | ||
if state == nil { | ||
return nil | ||
} | ||
return terminal.Restore(int(fd), state.s) | ||
} | ||
// ColorEnabled returns true on Linux if handle is a terminal. | ||
func ColorEnabled(fd uintptr) (bool, error) { | ||
return terminal.IsTerminal(int(fd)), nil | ||
} | ||
type ResizeEvent struct { | ||
Height, Width uint16 | ||
} | ||
// ResizeEvents sends terminal resize events | ||
func ResizeEvents(ctx context.Context, termfd uintptr) chan ResizeEvent { | ||
sigs := make(chan os.Signal, 16) | ||
signal.Notify(sigs, unix.SIGWINCH) | ||
events := make(chan ResizeEvent) | ||
go func() { | ||
for ctx.Err() == nil { | ||
width, height, err := terminal.GetSize(int(termfd)) | ||
if err != nil { | ||
return | ||
} | ||
events <- ResizeEvent{ | ||
Height: uint16(height), | ||
Width: uint16(width), | ||
} | ||
<-sigs | ||
} | ||
}() | ||
return events | ||
} |
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.