diff --git a/li/cil/oc/Settings.scala b/li/cil/oc/Settings.scala index 1433aa70a..9b54b2478 100644 --- a/li/cil/oc/Settings.scala +++ b/li/cil/oc/Settings.scala @@ -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. // ----------------------------------------------------------------------- // diff --git a/li/cil/oc/client/gui/Buffer.scala b/li/cil/oc/client/gui/Buffer.scala index a100f2274..f751d6c14 100644 --- a/li/cil/oc/client/gui/Buffer.scala +++ b/li/cil/oc/client/gui/Buffer.scala @@ -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) + } } diff --git a/reference.conf b/reference.conf index 0c728e226..a3ec2c7da 100644 --- a/reference.conf +++ b/reference.conf @@ -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.