configurable paste shortcut, very rudimentary but better than nothing. closes #54

This commit is contained in:
Florian Nücke 2014-01-04 01:12:49 +01:00
parent 27316ff8c2
commit b5154843a9
3 changed files with 20 additions and 6 deletions

View File

@ -22,6 +22,7 @@ class Settings(config: Config) {
val maxScreenTextRenderDistance = config.getDouble("client.maxScreenTextRenderDistance")
val textLinearFiltering = config.getBoolean("client.textLinearFiltering")
val textAntiAlias = config.getBoolean("client.textAntiAlias")
val pasteShortcut = config.getStringList("client.pasteShortcut").toSet
val rTreeDebugRenderer = false // *Not* to be configurable via config file.
// ----------------------------------------------------------------------- //

View File

@ -1,5 +1,6 @@
package li.cil.oc.client.gui
import li.cil.oc.Settings
import li.cil.oc.client.PacketSender
import li.cil.oc.client.renderer.MonospaceFontRenderer
import li.cil.oc.client.renderer.gui.BufferRenderer
@ -70,12 +71,8 @@ trait Buffer extends GuiScreen {
if (NEI.isInputFocused) return
val code = Keyboard.getEventKey
if (code != Keyboard.KEY_ESCAPE && code != Keyboard.KEY_F11)
if (code == Keyboard.KEY_INSERT && GuiScreen.isShiftKeyDown) {
if (Keyboard.getEventKeyState)
PacketSender.sendClipboard(buffer.owner, GuiScreen.getClipboardString)
}
else if (Keyboard.getEventKeyState) {
if (code != Keyboard.KEY_ESCAPE && code != Keyboard.KEY_F11) {
if (Keyboard.getEventKeyState) {
val char = Keyboard.getEventCharacter
if (!pressedKeys.contains(code) || !ignoreRepeat(char, code)) {
PacketSender.sendKeyDown(buffer.owner, char, code)
@ -86,6 +83,11 @@ trait Buffer extends GuiScreen {
case Some(char) => PacketSender.sendKeyUp(buffer.owner, char, code)
case _ => // Wasn't pressed while viewing the screen.
}
if (isPasteShortcutPressed && Keyboard.getEventKeyState) {
PacketSender.sendClipboard(buffer.owner, GuiScreen.getClipboardString)
}
}
}
override protected def mouseClicked(x: Int, y: Int, button: Int) {
@ -107,4 +109,9 @@ trait Buffer extends GuiScreen {
code == Keyboard.KEY_LMETA ||
code == Keyboard.KEY_RMETA
}
private def isPasteShortcutPressed = {
val want = Settings.get.pasteShortcut.map(name => Keyboard.getKeyIndex(name.toUpperCase)).filter(_ != Keyboard.KEY_NONE)
pressedKeys.keySet.equals(want)
}
}

View File

@ -47,6 +47,12 @@ opencomputers {
# If you prefer the text on the screens to be aliased (you know, *not*
# anti-aliased / smoothed) turn this option off.
textAntiAlias: true
# The keyboard shortcut that is used to send the current text in the
# clipboard to the currently opened screen (if said screen has a keyboard
# attached to it). For valid key names, please see the following list:
# https://github.com/LWJGL/lwjgl/blob/master/src/java/org/lwjgl/input/Keyboard.java#L73
pasteShortcut: [LSHIFT, INSERT]
}
# Computer related settings, concerns server performance and security.