From e4632f01c2b4b1853ec4b7e31b388f7d356fbb4b Mon Sep 17 00:00:00 2001 From: Anton Sivakov Date: Mon, 20 Jan 2020 23:13:00 +0200 Subject: [PATCH] Updated allow paste text from buffer to input with ctrl + v --- src/Components/InputModel.re | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Components/InputModel.re b/src/Components/InputModel.re index 19a0bf3ba3..787cc6d4e1 100644 --- a/src/Components/InputModel.re +++ b/src/Components/InputModel.re @@ -27,6 +27,12 @@ let add = (~at as index, insert, text) => ( index + String.length(insert), ); +let getClipboardText = () => + switch (Sdl2.Clipboard.getText()) { + | Some(value) => value + | None => "" + }; + let handleInput = (~text, ~cursorPosition) => fun | "" => (text, max(0, cursorPosition - 1)) @@ -35,5 +41,6 @@ let handleInput = (~text, ~cursorPosition) => | "" => removeAfter(cursorPosition, text) | "" => (text, 0) | "" => (text, String.length(text)) + | "" => (text ++ getClipboardText(), String.length(text)) | key when String.length(key) == 1 => add(~at=cursorPosition, key, text) | _ => (text, cursorPosition);