Commit 058cf57f authored by Eric's avatar Eric

stash

parent ec5f6f4b
...@@ -8,8 +8,8 @@ import ( ...@@ -8,8 +8,8 @@ import (
) )
type commandInput struct { type commandInput struct {
readFromUserInput bytes.Buffer readFromUserInput *bytes.Buffer
readFromServerInput bytes.Buffer readFromServerInput *bytes.Buffer
isUserSideValid bool isUserSideValid bool
isServerSideValid bool isServerSideValid bool
...@@ -24,16 +24,18 @@ func (c *commandInput) readFromServer(p []byte) { ...@@ -24,16 +24,18 @@ func (c *commandInput) readFromServer(p []byte) {
} }
func (c *commandInput) Parse() string { func (c *commandInput) Parse() string {
lines, ok := utils.ParseTerminalData(c.readFromUserInput.Bytes()) lines, ok := utils.ParseTerminalData([]byte(c.readFromUserInput.String()))
if ok { if ok {
fmt.Println("readFromUserInput lines: ", lines) fmt.Println("readFromUserInput lines: ", lines)
c.readFromUserInput.Reset() c.readFromUserInput.Reset()
c.readFromServerInput.Reset() c.readFromServerInput.Reset()
return strings.Join(lines, "\r\n") result := strings.Join(lines, "\r\n")
fmt.Println("readFromUserInput result: ", result, len(result))
return result
} }
lines, _ = utils.ParseTerminalData(c.readFromServerInput.Bytes()) lines, _ = utils.ParseTerminalData([]byte(c.readFromServerInput.String()))
fmt.Println("readFromServerInput lines: ", lines) fmt.Println("readFromServerInput lines: ", lines)
c.readFromUserInput.Reset() c.readFromUserInput.Reset()
c.readFromServerInput.Reset() c.readFromServerInput.Reset()
...@@ -41,9 +43,7 @@ func (c *commandInput) Parse() string { ...@@ -41,9 +43,7 @@ func (c *commandInput) Parse() string {
} }
type commandOut struct { type commandOut struct {
readFromServerOut bytes.Buffer readFromServerOut *bytes.Buffer
isUserSideValid bool
isServerSideValid bool
} }
func (c *commandOut) readFromServer(p []byte) { func (c *commandOut) readFromServer(p []byte) {
...@@ -51,8 +51,11 @@ func (c *commandOut) readFromServer(p []byte) { ...@@ -51,8 +51,11 @@ func (c *commandOut) readFromServer(p []byte) {
} }
func (c *commandOut) Parse() string { func (c *commandOut) Parse() string {
lines, _ := utils.ParseTerminalData(c.readFromServerOut.Bytes()) lines, _ := utils.ParseTerminalData([]byte(c.readFromServerOut.String()))
c.readFromServerOut.Reset() c.readFromServerOut.Reset()
fmt.Println("commandOut: ", lines) result := strings.Join(lines, "\r\n")
return strings.Join(lines, "\r\n") fmt.Println("commandOut: ", result)
return result
} }
...@@ -71,15 +71,13 @@ func (p *Parser) initial() { ...@@ -71,15 +71,13 @@ func (p *Parser) initial() {
//p.cmdInputParser = NewCmdParser(p.id, CommandInputParserName) //p.cmdInputParser = NewCmdParser(p.id, CommandInputParserName)
//p.cmdOutputParser = NewCmdParser(p.id, CommandOutputParserName) //p.cmdOutputParser = NewCmdParser(p.id, CommandOutputParserName)
p.cmdInputParser = &commandInput{ p.cmdInputParser = &commandInput{
readFromUserInput: bytes.Buffer{}, readFromUserInput: &bytes.Buffer{},
readFromServerInput: bytes.Buffer{}, readFromServerInput: &bytes.Buffer{},
isUserSideValid: false, isUserSideValid: false,
isServerSideValid: false, isServerSideValid: false,
} }
p.cmdOutputParser = &commandOut{ p.cmdOutputParser = &commandOut{
readFromServerOut: bytes.Buffer{}, readFromServerOut: &bytes.Buffer{},
isUserSideValid: false,
isServerSideValid: false,
} }
p.closed = make(chan struct{}) p.closed = make(chan struct{})
p.cmdRecordChan = make(chan [2]string, 1024) p.cmdRecordChan = make(chan [2]string, 1024)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment