Skip to content

Commit

Permalink
Move width/height into sys.go
Browse files Browse the repository at this point in the history
So that the command can access the dimensions of user console
  • Loading branch information
victpork committed Jan 17, 2018
1 parent f934f39 commit 19ec43d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
8 changes: 4 additions & 4 deletions os/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ type Shell struct {
iostream io.ReadWriter
log *log.Entry
sessionLog *termlogger.Logger
width int
height int
termSignal chan<- int
terminal *terminal.Terminal
sys *System
Expand All @@ -35,11 +33,11 @@ func NewShell(iostream io.ReadWriter, fsys *virtualfs.VirtualFS, width, height i
FSys: fsys,
cwd: "/home/" + user,
envVars: map[string]string{},
Width: width,
Height: height,
}
return &Shell{
iostream: iostream,
width: width,
height: height,
log: log,
termSignal: termSignal,
sys: sys,
Expand Down Expand Up @@ -104,6 +102,8 @@ func (sh *Shell) Exec(path string, args []string) (int, error) {
}

func (sh *Shell) SetSize(width, height int) error {
sh.sys.Width = width
sh.sys.Height = height
return sh.terminal.SetSize(width, height)
}

Expand Down
9 changes: 5 additions & 4 deletions os/sys.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ type Command interface {

// System emulates what most of os/sys does in the honeyport
type System struct {
cwd string
FSys *virtualfs.VirtualFS
io io.ReadWriter
envVars map[string]string
cwd string
FSys *virtualfs.VirtualFS
io io.ReadWriter
envVars map[string]string
Width, Height int
}

type stdoutWrapper struct {
Expand Down

0 comments on commit 19ec43d

Please sign in to comment.