diff options
-rw-r--r-- | doc/manual.tex | 4 | ||||
-rw-r--r-- | lib/js/urweb.js | 9 | ||||
-rw-r--r-- | lib/ur/basis.urs | 3 | ||||
-rw-r--r-- | src/monoize.sml | 23 | ||||
-rw-r--r-- | tests/ctextarea.ur | 8 | ||||
-rw-r--r-- | tests/ctextarea.urp | 3 | ||||
-rw-r--r-- | tests/ctextarea.urs | 1 |
7 files changed, 49 insertions, 2 deletions
diff --git a/doc/manual.tex b/doc/manual.tex index 3b7ce214..07f96398 100644 --- a/doc/manual.tex +++ b/doc/manual.tex @@ -140,7 +140,7 @@ Here is the complete list of directive forms. ``FFI'' stands for ``foreign func \item \texttt{effectful Module.ident} registers an FFI function or transaction as having side effects. The optimizer avoids removing, moving, or duplicating calls to such functions. Every effectful FFI function must be registered, or the optimizer may make invalid transformations. \item \texttt{exe FILENAME} sets the filename to which to write the output executable. The default for file \texttt{P.urp} is \texttt{P.exe}. \item \texttt{ffi FILENAME} reads the file \texttt{FILENAME.urs} to determine the interface to a new FFI module. The name of the module is calculated from \texttt{FILENAME} in the same way as for normal source files. See the files \texttt{include/urweb.h} and \texttt{src/c/urweb.c} for examples of C headers and implementations for FFI modules. In general, every type or value \texttt{Module.ident} becomes \texttt{uw\_Module\_ident} in C. -\item \texttt{header FILENAME} adds \texttt{FILENAME} to the list of files to be \texttt{\#include}d in C sources. This is most useful for interfacing with new FFI modules. +\item \texttt{include FILENAME} adds \texttt{FILENAME} to the list of files to be \texttt{\#include}d in C sources. This is most useful for interfacing with new FFI modules. \item \texttt{jsFunc Module.ident=name} gives the JavaScript name of an FFI value. \item \texttt{library FILENAME} parses \texttt{FILENAME.urp} and merges its contents with the rest of the current file's contents. If \texttt{FILENAME.urp} doesn't exist, the compiler also tries \texttt{FILENAME/lib.urp}. \item \texttt{link FILENAME} adds \texttt{FILENAME} to the list of files to be passed to the GCC linker at the end of compilation. This is most useful for importing extra libraries needed by new FFI modules. @@ -1992,7 +1992,7 @@ It is most convenient to encapsulate an FFI binding with a new \texttt{.urp} fil \item \texttt{clientToServer Module.ident} declares a type as OK to marshal between clients and servers. By default, abstract FFI types are not allowed to be marshalled, since your library might be maintaining invariants that the simple serialization code doesn't check. \item \texttt{effectful Module.ident} registers a function that can have side effects. It is important to remember to use this directive for each such function, or else the optimizer might change program semantics. \item \texttt{ffi FILE.urs} names the file giving your library's signature. You can include multiple such files in a single \texttt{.urp} file, and each file \texttt{mod.urp} defines an FFI module \texttt{Mod}. -\item \texttt{header FILE} requests inclusion of a C header file. +\item \texttt{include FILE} requests inclusion of a C header file. \item \texttt{jsFunc Module.ident=name} gives a mapping from an Ur name for a value to a JavaScript name. \item \texttt{link FILE} requests that \texttt{FILE} be linked into applications. It should be a C object or library archive file, and you are responsible for generating it with your own build process. \item \texttt{script URL} requests inclusion of a JavaScript source file within application HTML. diff --git a/lib/js/urweb.js b/lib/js/urweb.js index 474bdaf6..3a0e7f9f 100644 --- a/lib/js/urweb.js +++ b/lib/js/urweb.js @@ -501,6 +501,15 @@ function chk(s) { return x; } +function tbx(s) { + var x = input(document.createElement("textarea"), s, + function(x) { return function(v) { if (x.innerHTML != v) x.innerHTML = v; }; }); + x.innerHTML = s.data; + x.onkeyup = function() { sv(s, x.value) }; + + return x; +} + function addOnChange(x, f) { var old = x.onchange; x.onchange = function() { old(); f (); }; diff --git a/lib/ur/basis.urs b/lib/ur/basis.urs index 02ac0126..ffce96c0 100644 --- a/lib/ur/basis.urs +++ b/lib/ur/basis.urs @@ -734,6 +734,9 @@ con cselect = [Cselect] val cselect : cformTag ([Source = source string, Onchange = transaction unit] ++ boxAttrs) cselect val coption : unit -> tag [Value = string, Selected = bool] cselect [] [] [] +val ctextarea : cformTag ([Value = string, Rows = int, Cols = int, Source = source string, Onchange = transaction unit, + Ontext = transaction unit] ++ boxAttrs) [] + (*** Tables *) val tabl : other ::: {Unit} -> [other ~ [Body, Table]] => unit diff --git a/src/monoize.sml b/src/monoize.sml index e9d90ecc..0f03111c 100644 --- a/src/monoize.sml +++ b/src/monoize.sml @@ -2985,6 +2985,29 @@ fun monoExp (env, st, fm) (all as (e, loc)) = | "coption" => normal ("option", NONE, NONE) + | "ctextarea" => + (case List.find (fn ("Source", _, _) => true | _ => false) attrs of + NONE => + let + val (ts, fm) = tagStart "textarea" + in + ((L'.EStrcat (ts, + (L'.EPrim (Prim.String " />"), loc)), + loc), fm) + end + | SOME (_, src, _) => + let + val sc = strcat [str "tbx(exec(", + (L'.EJavaScript (L'.Script, src), loc), + str "))"] + val sc = setAttrs sc + in + (strcat [str "<script type=\"text/javascript\">", + sc, + str "</script>"], + fm) + end) + | "tabl" => normal ("table", NONE, NONE) | _ => normal (tag, NONE, NONE)) end diff --git a/tests/ctextarea.ur b/tests/ctextarea.ur new file mode 100644 index 00000000..86a8c739 --- /dev/null +++ b/tests/ctextarea.ur @@ -0,0 +1,8 @@ +fun main () = + s <- source "DEFAULT"; + return <xml><body> + <ctextarea rows={2} source={s}/><br/> + <br/> + + <dyn signal={s <- signal s; return (cdata s)}/> + </body></xml> diff --git a/tests/ctextarea.urp b/tests/ctextarea.urp new file mode 100644 index 00000000..2ed9b69f --- /dev/null +++ b/tests/ctextarea.urp @@ -0,0 +1,3 @@ +debug + +ctextarea diff --git a/tests/ctextarea.urs b/tests/ctextarea.urs new file mode 100644 index 00000000..6ac44e0b --- /dev/null +++ b/tests/ctextarea.urs @@ -0,0 +1 @@ +val main : unit -> transaction page |