Merge pull request #55 from liamg/ctrl-codes

add more control codes
This commit is contained in:
Liam Galvin 2018-11-04 20:59:34 +00:00 committed by GitHub
commit 1d82f48f8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 64 additions and 6 deletions

View File

@ -79,6 +79,10 @@ func (buffer *Buffer) GetURLAtPosition(col uint16, row uint16) string {
candidate = fmt.Sprintf("%s%c", candidate, cell.Rune()) candidate = fmt.Sprintf("%s%c", candidate, cell.Rune())
} }
if candidate == "" || candidate[0] == '/' {
return ""
}
// check if url // check if url
_, err := url.ParseRequestURI(candidate) _, err := url.ParseRequestURI(candidate)
if err != nil { if err != nil {

View File

@ -69,30 +69,84 @@ func (gui *GUI) key(w *glfw.Window, key glfw.Key, scancode int, action glfw.Acti
case modsPressed(mods, glfw.ModControl): case modsPressed(mods, glfw.ModControl):
modStr = "5" modStr = "5"
switch key { switch key {
case glfw.KeyA:
gui.terminal.Write([]byte{0x1})
return
case glfw.KeyB:
gui.terminal.Write([]byte{0x2})
return
case glfw.KeyC: // ctrl^c case glfw.KeyC: // ctrl^c
gui.logger.Debugf("Sending CTRL^C")
gui.terminal.Write([]byte{0x3}) // send EOT gui.terminal.Write([]byte{0x3}) // send EOT
return return
case glfw.KeyD: case glfw.KeyD:
gui.logger.Debugf("Sending CTRL^D")
gui.terminal.Write([]byte{0x4}) // send EOT gui.terminal.Write([]byte{0x4}) // send EOT
return return
case glfw.KeyE:
gui.terminal.Write([]byte{0x5})
return
case glfw.KeyF:
gui.terminal.Write([]byte{0x6})
return
case glfw.KeyG:
gui.terminal.Write([]byte{0x7})
return
case glfw.KeyH: case glfw.KeyH:
gui.logger.Debugf("Sending CTRL^H")
gui.terminal.Write([]byte{0x08}) gui.terminal.Write([]byte{0x08})
return return
case glfw.KeyI:
gui.terminal.Write([]byte{0x9})
return
case glfw.KeyJ: case glfw.KeyJ:
gui.logger.Debugf("Sending CTRL^J")
gui.terminal.Write([]byte{0x0a}) gui.terminal.Write([]byte{0x0a})
return return
case glfw.KeyK:
gui.terminal.Write([]byte{0x0b})
return
case glfw.KeyL:
gui.terminal.Write([]byte{0x0c})
return
case glfw.KeyM: case glfw.KeyM:
gui.logger.Debugf("Sending CTRL^M")
gui.terminal.Write([]byte{0x0d}) gui.terminal.Write([]byte{0x0d})
return return
case glfw.KeyN:
gui.terminal.Write([]byte{0x0e})
return
case glfw.KeyO:
gui.terminal.Write([]byte{0x0f})
return
case glfw.KeyP:
gui.terminal.Write([]byte{0x10})
return
case glfw.KeyQ:
gui.terminal.Write([]byte{0x11})
return
case glfw.KeyR:
gui.terminal.Write([]byte{0x12})
return
case glfw.KeyS:
gui.terminal.Write([]byte{0x13})
return
case glfw.KeyT:
gui.terminal.Write([]byte{0x14})
return
case glfw.KeyU:
gui.terminal.Write([]byte{0x15})
return
case glfw.KeyV:
gui.terminal.Write([]byte{0x16})
return
case glfw.KeyW:
gui.terminal.Write([]byte{0x17})
return
case glfw.KeyX: case glfw.KeyX:
gui.logger.Debugf("Sending CTRL^X")
gui.terminal.Write([]byte{0x18}) gui.terminal.Write([]byte{0x18})
return return
case glfw.KeyY:
gui.terminal.Write([]byte{0x19})
return
case glfw.KeyZ:
gui.terminal.Write([]byte{0x1a})
return
} }
case modsPressed(mods, glfw.ModAlt, glfw.ModShift): case modsPressed(mods, glfw.ModAlt, glfw.ModShift):
modStr = "4" modStr = "4"