add yank functionality in imperative shell

This commit is contained in:
2024-11-11 05:27:20 +00:00
parent ae68627a8f
commit 54090ccf64
5 changed files with 14 additions and 0 deletions

View File

@@ -41,3 +41,8 @@ void swapBuffers(GLFWwindow *window) {
glfwSwapBuffers(window); glfwSwapBuffers(window);
} }
void setClipboardString (GLFWwindow *window, const char *copyString) {
glfwSetClipboardString(window, copyString);
printf("ddone yanking");
}

View File

@@ -22,4 +22,5 @@ struct
val windowShouldClose = _import "windowShouldClose" public : window -> bool; val windowShouldClose = _import "windowShouldClose" public : window -> bool;
val waitEvents = _import "waitEvents" public reentrant : unit -> unit; val waitEvents = _import "waitEvents" public reentrant : unit -> unit;
val swapBuffers = _import "swapBuffers" public : window -> unit; val swapBuffers = _import "swapBuffers" public : window -> unit;
val setClipboardString = _import "setClipboardString" public : window * string -> unit;
end end

View File

@@ -3,6 +3,7 @@ sig
datatype t = datatype t =
REDRAW_TEXT of Real32.real vector REDRAW_TEXT of Real32.real vector
| REDRAW_CURSOR of Real32.real vector | REDRAW_CURSOR of Real32.real vector
| YANK of string
end end
structure DrawMsg :> DRAW_MSG = structure DrawMsg :> DRAW_MSG =
@@ -10,4 +11,5 @@ struct
datatype t = datatype t =
REDRAW_TEXT of Real32.real vector REDRAW_TEXT of Real32.real vector
| REDRAW_CURSOR of Real32.real vector | REDRAW_CURSOR of Real32.real vector
| YANK of string
end end

View File

@@ -164,6 +164,11 @@ struct
() ()
end end
fun yank (shellState: t, str) =
( Glfw.setClipboardString (#window shellState, str);
shellState
)
fun consumeDrawEvent (shellState, msg) = fun consumeDrawEvent (shellState, msg) =
let let
val val
@@ -178,6 +183,7 @@ struct
case msg of case msg of
REDRAW_TEXT textVec => uploadText (shellState, textVec) REDRAW_TEXT textVec => uploadText (shellState, textVec)
| REDRAW_CURSOR cursorVec => uploadCursor (shellState, cursorVec) | REDRAW_CURSOR cursorVec => uploadCursor (shellState, cursorVec)
| YANK str => yank (shellState, str)
end end
fun consumeDrawEvents (shellState as {drawMailbox, ...}: t) = fun consumeDrawEvents (shellState as {drawMailbox, ...}: t) =

BIN
shf

Binary file not shown.