Add help button

This commit is contained in:
Nikolay Puzanov 2022-12-03 13:32:09 +03:00
parent 185dcb350d
commit 9939a226c8
2 changed files with 47 additions and 11 deletions

View File

@ -94,6 +94,7 @@
<body> <body>
<div id="buttons"> <div id="buttons">
<button onclick="show_help()"><span class="text">?</span></button>
<button onclick="save_code('%SAVECODEURI%')"><span class="text">Save (ctrl-s)</span></button> <button onclick="save_code('%SAVECODEURI%')"><span class="text">Save (ctrl-s)</span></button>
<button onclick="save_code('%SAVEASURI%')"><span class="text">Save as new</span></button> <button onclick="save_code('%SAVEASURI%')"><span class="text">Save as new</span></button>
Sim: Sim:
@ -151,6 +152,10 @@
.then((text) => { window.location.href = text; }); .then((text) => { window.location.href = text; });
}; };
function show_help() {
alert("%HELPSTRING%");
};
document.addEventListener('keydown', (e) => { document.addEventListener('keydown', (e) => {
if (e.key.toLowerCase() === 's' && e.ctrlKey) { if (e.key.toLowerCase() === 's' && e.ctrlKey) {
e.preventDefault(); e.preventDefault();

View File

@ -191,7 +191,7 @@
#:content-type-params content-type-params)) #:content-type-params content-type-params))
;;; ;;;
;;; Execute system command and capture stdout and stderr to string list ;;; Execute system command and capture stdout and stderr to string
;;; ;;;
(define* (system-to-string cmd #:key (pwd #f)) (define* (system-to-string cmd #:key (pwd #f))
(let* ((cmd (string-append cmd " 2>&1")) (let* ((cmd (string-append cmd " 2>&1"))
@ -201,14 +201,14 @@
(values (close-pipe p) out))) (values (close-pipe p) out)))
;;; ;;;
;;; Unused ;;; Execute system command and capture stdout and stderr to string list
;;; ;;;
;; (define* (system-to-string-list cmd #:key (pwd #f)) (define* (system-to-string-list cmd #:key (pwd #f))
;; (let-values (((status out) (let-values (((status out)
;; (system-to-string cmd #:pwd pwd))) (system-to-string cmd #:pwd pwd)))
;; (values (values
;; status status
;; (list-trim (string-split out #\newline) string-null?)))) (list-trim (string-split out #\newline) string-null?))))
;;; ;;;
;;; Make pretty log from executable output ;;; Make pretty log from executable output
@ -328,6 +328,18 @@
(exe-log-pretty cmdline status out))) (exe-log-pretty cmdline status out)))
(values status (string-append compile-log execution-log))))))))))) (values status (string-append compile-log execution-log)))))))))))
;;;
;;; Get iverilog version
;;;
(define (iverilog-version iverilog-exe)
(let-values (((status out)
(system-to-string-list
(format "~a -V" iverilog-exe))))
(if (and (zero? status)
(not (null? out)))
(car out)
"Unknown")))
;;; ;;;
;;; Execute simulation ;;; Execute simulation
;;; ;;;
@ -426,9 +438,28 @@
(iverilog-post-uri (encode-and-join-uri-path iverilog-path)) (iverilog-post-uri (encode-and-join-uri-path iverilog-path))
(savecode-post-uri (encode-and-join-uri-path savecode-path)) (savecode-post-uri (encode-and-join-uri-path savecode-path))
(saveas-post-uri (encode-and-join-uri-path saveas-path)) (saveas-post-uri (encode-and-join-uri-path saveas-path))
(index-html (read-template-text index-file `(("IVERILOGPOSTURI" ,iverilog-post-uri) (index-html
("SAVECODEURI" ,savecode-post-uri) (read-template-text
("SAVEASURI" ,saveas-post-uri))))) index-file
`(("IVERILOGPOSTURI" ,iverilog-post-uri)
("SAVECODEURI" ,savecode-post-uri)
("SAVEASURI" ,saveas-post-uri)
("HELPSTRING",
(string-concatenate
(insert-between
`("Verilog Playground by Punzik (c) 2022"
""
,(format "Icarus: ~a"
(iverilog-version iverilog-exe))
,(format "Verilator: ~a" "TODO")
""
"Rules:"
"0. Don't fool around ;)"
"1. (TODO) The top module must be named 'testbench'."
"2. (TODO) The top module for the Verilator must have an input clock signal."
"3. Code size should not exceed 10000 characters."
"4. Code execution time no longer than 5 seconds.")
"\\n")))))))
(lambda (request request-body) (lambda (request request-body)
(let (;; Requested resource path (let (;; Requested resource path