From 2aa98de7aa9635a3deed1a64abe5d3ad421f50ff Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Sun, 13 Nov 2022 16:45:57 +0100 Subject: Add editing keys: copy, paste, cut, select all --- srcs/juloo.keyboard2/KeyValue.java | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'srcs/juloo.keyboard2/KeyValue.java') diff --git a/srcs/juloo.keyboard2/KeyValue.java b/srcs/juloo.keyboard2/KeyValue.java index df0d290..7215736 100644 --- a/srcs/juloo.keyboard2/KeyValue.java +++ b/srcs/juloo.keyboard2/KeyValue.java @@ -52,9 +52,17 @@ final class KeyValue FN, // Must be placed last to be applied first } + public static enum Editing + { + COPY, + PASTE, + CUT, + SELECT_ALL, + } + public static enum Kind { - Char, String, Keyevent, Event, Modifier + Char, String, Keyevent, Event, Modifier, Editing } // Behavior flags. @@ -132,6 +140,12 @@ final class KeyValue return Modifier.values()[(_code & VALUE_BITS)]; } + /** Defined only when [getKind() == Kind.Editing]. */ + public Editing getEditing() + { + return Editing.values()[(_code & VALUE_BITS)]; + } + /* Update the char and the symbol. */ public KeyValue withChar(char c) { @@ -247,6 +261,12 @@ final class KeyValue addKeyeventKey(name, String.valueOf((char)symbol), code, flags | FLAG_KEY_FONT); } + private static void addEditingKey(String name, String symbol, Editing action) + { + addKey(name, symbol, Kind.Editing, action.ordinal(), + FLAG_SPECIAL | FLAG_SECONDARY | FLAG_SMALLER_FONT); + } + // Within VALUE_BITS private static int placeholder_unique_id = 0; @@ -332,6 +352,11 @@ final class KeyValue addPlaceholderKey("removed"); addPlaceholderKey("f11_placeholder"); addPlaceholderKey("f12_placeholder"); + + addEditingKey("copy", "copy", Editing.COPY); + addEditingKey("paste", "paste", Editing.PASTE); + addEditingKey("cut", "cut", Editing.CUT); + addEditingKey("select_all", "s. all", Editing.SELECT_ALL); } static final HashMap keys_descr = new HashMap(); -- cgit v1.2.3