package view;

import javafx.event.EventHandler;
import javafx.scene.control.TextField;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyCodeCombination;
import javafx.scene.input.KeyCombination;
import javafx.scene.input.KeyEvent;

import java.util.prefs.Preferences;

import static javafx.scene.input.KeyCode.*;
import static javafx.scene.input.KeyCombination.SHORTCUT_DOWN;

public class ViewUtil {
    final static KeyCombination ctrlZ = new KeyCodeCombination(Z, SHORTCUT_DOWN);
    final static KeyCombination ctrlY = new KeyCodeCombination(Y, SHORTCUT_DOWN);
    static Preferences prefs = Preferences.userRoot().node("General");

    public static void addFocusListener(TextField tf, ProofView pv) {
        tf.focusedProperty().addListener((observable, oldValue, newValue) -> {
            pv.lastFocusedTf = tf;
            pv.caretPosition = tf.getCaretPosition();
        });
    }
    public static void applyStyleIf(TextField expression, boolean bool, String style) {
        if(prefs.getBoolean("verify",true)) {

            expression.getStyleClass().removeIf((s) -> s.equals(style));
            if (bool) {
                expression.getStyleClass().add(style);
            }
        }
    }
    public static String checkShortcut(String newValue) {
        newValue = newValue.replaceAll("!|ne|no", "¬");
        newValue = newValue.replaceAll("&|an", "∧");
        newValue = newValue.replaceAll("->|im", "→");
        newValue = newValue.replaceAll("fa|fo", "∀");
        newValue = newValue.replaceAll("or", "∨");
        newValue = newValue.replaceAll("ex|te|th", "∃");
        newValue = newValue.replaceAll("co|bo", "⊥");
        return newValue;
    }
    public static void consumeKeys(TextField tf) {
        tf.setOnKeyPressed(key -> {
            if (ctrlY.match(key) || ctrlZ.match(key)) {
                key.consume();
            }
        });
    }
}

@@ -1652,24 +1652,524 @@
 %7Cbo%22, %22%E2%8A%A5%22);%0A
+        newValue = newValue.replaceAll(%220%22, %22%E2%82%80%22);%0A        newValue = newValue.replaceAll(%221%22, %22%E2%82%81%22);%0A        newValue = newValue.replaceAll(%222%22, %22%E2%82%82%22);%0A        newValue = newValue.replaceAll(%223%22, %22%E2%82%83%22);%0A        newValue = newValue.replaceAll(%224%22, %22%E2%82%84%22);%0A        newValue = newValue.replaceAll(%225%22, %22%E2%82%85%22);%0A        newValue = newValue.replaceAll(%226%22, %22%E2%82%86%22);%0A        newValue = newValue.replaceAll(%227%22, %22%E2%82%87%22);%0A        newValue = newValue.replaceAll(%228%22, %22%E2%82%88%22);%0A        newValue = newValue.replaceAll(%229%22, %22%E2%82%89%22);%0A
         retu

0123456789 subscript