example 'cl-repl': add help, screenshot; several revisions

This commit is contained in:
pls.153 2022-04-11 16:47:17 +02:00
parent ad70df7399
commit a131436dde
14 changed files with 86 additions and 73 deletions

View file

@ -72,7 +72,6 @@
(define-symbol-macro :q (quicklisp))) (define-symbol-macro :q (quicklisp)))
(export (export
(list #+ios (list 'start-swank
'start-swank
'stop-swank 'stop-swank
'quicklisp)) 'quicklisp))

View file

@ -5,6 +5,7 @@
#:debug-dialog #:debug-dialog
#:get-file-name #:get-file-name
#:exited #:exited
#:help
#:push-dialog #:push-dialog
#:pop-dialog #:pop-dialog
#:*file-name*)) #:*file-name*))
@ -26,8 +27,7 @@
(disable-clipboard-menu) (disable-clipboard-menu)
(prog1 (prog1
(> (q< |depth| ui:*main*) 1) (> (q< |depth| ui:*main*) 1)
(qjs |popDialog| ui:*main*) (qjs |popDialog| ui:*main*)))
(exited)))
(defun wait-while-transition () (defun wait-while-transition ()
;; needed for evtl. recursive calls ;; needed for evtl. recursive calls
@ -43,7 +43,6 @@
(q! |forceActiveFocus| ui:*query-input*) (q! |forceActiveFocus| ui:*query-input*)
(q! |showKeyboard| ui:*main* t) ; needed on recursive calls (q! |showKeyboard| ui:*main* t) ; needed on recursive calls
(wait-for-closed) (wait-for-closed)
(pop-dialog)
(qlater (lambda () (editor:ensure-focus :show))) (qlater (lambda () (editor:ensure-focus :show)))
(q< |text| ui:*query-input*)) (q< |text| ui:*query-input*))
@ -66,18 +65,20 @@
(q! |forceActiveFocus| ui:*debug-input*) (q! |forceActiveFocus| ui:*debug-input*)
(qsingle-shot 500 (lambda () (q! |positionViewAtEnd| ui:*debug-text*))) (qsingle-shot 500 (lambda () (q! |positionViewAtEnd| ui:*debug-text*)))
(wait-for-closed) (wait-for-closed)
(pop-dialog)
(qlater (lambda () (editor:ensure-focus :show))) (qlater (lambda () (editor:ensure-focus :show)))
(q< |text| ui:*debug-input*)) (q< |text| ui:*debug-input*))
(let ((exited t)) (let (waiting)
(defun wait-for-closed () (defun wait-for-closed ()
(setf exited nil) (setf waiting t)
;; busy waiting is safer than suspending a thread, especially on mobile ;; busy waiting is safer than suspending a thread, especially on mobile
(x:while (not exited) (x:while waiting
(qsleep 0.1))) (qsleep 0.1))
(pop-dialog))
(defun exited () ; called from QML (defun exited () ; called from QML
(setf exited t))) (unless waiting
(pop-dialog))
(setf waiting nil)))
;; file browser ;; file browser
@ -99,8 +100,9 @@
(qsingle-shot 500 (lambda () (q! |forceActiveFocus| ui:*path*)))))) (qsingle-shot 500 (lambda () (q! |forceActiveFocus| ui:*path*))))))
(defun directory-p (path) (defun directory-p (path)
(unless (equal "" path)
(not (or (pathname-name path) (not (or (pathname-name path)
(pathname-type path)))) (pathname-type path)))))
(defun set-file-name (file-name) ; called from QML (defun set-file-name (file-name) ; called from QML
(let ((name (remove-if (lambda (ch) (find ch "*?\\")) file-name))) (let ((name (remove-if (lambda (ch) (find ch "*?\\")) file-name)))
@ -134,3 +136,7 @@
(unless (x:ends-with "/" url) (unless (x:ends-with "/" url)
(setf path* (x:cc url "/"))) (setf path* (x:cc url "/")))
(q> |folder| ui:*folder-model* url))) (q> |folder| ui:*folder-model* url)))
(defun help ()
(push-dialog :help))

View file

@ -658,19 +658,13 @@
(print-eval-output :values "kill: eval thread not running"))) (print-eval-output :values "kill: eval thread not running")))
(t (t
(let ((cmd (cond ((cmd ":h") (let ((cmd (cond ((cmd ":h")
"(qml:help)") "(dialogs:help)")
((cmd ":s") ((cmd ":s")
"(qml:start-swank)") "(qml:start-swank)")
((cmd ":q") ((cmd ":q")
"(qml:quicklisp)") "(qml:quicklisp)")
((cmd ":a")
"(require :asdf)")
((cmd ":f")
"(dialogs:get-file-name)")
((cmd ":c") ((cmd ":c")
"(progn (qml:q! |clear| ui:*output-model*) (values))") "(progn (qml:q! |clear| ui:*output-model*) (values))")
((cmd ":r")
"(editor:reload-qml)")
((cmd "*") ((cmd "*")
(format nil "(progn~% (editor::set-clipboard-text (prin1-to-string *))~% *)")) (format nil "(progn~% (editor::set-clipboard-text (prin1-to-string *))~% *)"))
((x:starts-with ":? " text*) ((x:starts-with ":? " text*)
@ -1133,7 +1127,8 @@
(change-font :smaller 3)) (change-font :smaller 3))
(eval:ini :output 'print-eval-output (eval:ini :output 'print-eval-output
:query-dialog 'dialogs:query-dialog :query-dialog 'dialogs:query-dialog
:debug-dialog 'dialogs:debug-dialog)) :debug-dialog 'dialogs:debug-dialog)
(append-output (format nil "~% :h for help") :bold t))
;;; quit app ;;; quit app

View file

@ -72,7 +72,6 @@
(define-symbol-macro :q (quicklisp))) (define-symbol-macro :q (quicklisp)))
(export (export
(list #+ios (list 'start-swank
'start-swank
'stop-swank 'stop-swank
'quicklisp)) 'quicklisp))

View file

@ -14,12 +14,8 @@ Rectangle {
Ext.MenuBack { Ext.MenuBack {
id: menuBack id: menuBack
Layout.fillWidth: true
label: "Debug Dialog" label: "Debug Dialog"
onPressed: {
debugInput.text = ":q"
Lisp.call("dialogs:exited")
}
} }
TextField { TextField {

View file

@ -26,11 +26,6 @@ Rectangle {
Ext.MenuBack { Ext.MenuBack {
id: menuBack id: menuBack
onPressed: {
Lisp.call("dialogs:set-file-name", "")
Lisp.call("dialogs:pop-dialog")
}
Row { Row {
id: buttonRow id: buttonRow
spacing: 4 spacing: 4

View file

@ -0,0 +1,43 @@
import QtQuick 2.15
import "." as Ext
Rectangle {
color: "lightyellow"
Column {
anchors.fill: parent
Ext.MenuBack {
label: "Help"
}
Ext.Flickable {
id: flick
width: parent.width
height: parent.height
contentWidth: help.paintedWidth
contentHeight: help.paintedHeight + 75
Text {
id: help
width: flick.width
height: flick.height
padding: 20
wrapMode: Text.WordWrap
font.pixelSize: 20
text:
"<h2>Help</h2>
<ul>
<p><b>:?</b> find regular expression, e.g. <b>:?&nbsp;prin[c1]</b></p>
<p><b>*</b> copy result to clipboard</p>
<p><b>:s</b> start swank server</p>
<p><b>:c</b> clear all output</p>
<p><b>:k</b> kill eval thread (long running task)</p>
<p><b>double [Space]</b> auto completion, e.g. <b>m-v-b</b></p>
<p><b>tap and hold</b> in the editor to select/copy/paste/eval s-expression, e.g. on <b>defun</b></p>
<p><b>tap and hold</b> cursor buttons to move to beginning/end of line/file</p>
</ul>"
}
}
}
}

View file

@ -7,9 +7,7 @@ Rectangle {
height: backButton.height height: backButton.height
color: "#f0f0f0" color: "#f0f0f0"
property string label property alias label: label.text
signal pressed()
Button { Button {
id: backButton id: backButton
@ -27,15 +25,27 @@ Rectangle {
color: "#007aff" color: "#007aff"
text: "\uf104" text: "\uf104"
} }
Text {
x: 30
height: backButton.height * 1.1 // align correction (different font from above)
verticalAlignment: Text.AlignVCenter
font.weight: Font.DemiBold
color: iconBack.color
text: "Repl"
visible: (Qt.platform.os === "ios")
}
implicitWidth: 90
color: menuBack.color color: menuBack.color
} }
onPressed: parent.pressed() onPressed: Lisp.call("dialogs:exited")
} }
Text { Text {
id: label
anchors.centerIn: parent anchors.centerIn: parent
text: menuBack.label
font.weight: Font.DemiBold font.weight: Font.DemiBold
} }
} }

View file

@ -14,11 +14,6 @@ Rectangle {
Ext.MenuBack { Ext.MenuBack {
id: menuBack id: menuBack
label: "Query Dialog" label: "Query Dialog"
onPressed: {
queryInput.clear()
Lisp.call("dialogs:exited")
}
} }
TextField { TextField {
@ -44,29 +39,4 @@ Rectangle {
font.pixelSize: queryInput.font.pixelSize - (main.small ? 2 : 0) font.pixelSize: queryInput.font.pixelSize - (main.small ? 2 : 0)
} }
} }
Row {
anchors.horizontalCenter: parent.horizontalCenter
y: queryInput.y + queryInput.height + (main.small ? 7 : 10)
spacing: 20
visible: queryInput.focus
// cursor back
Ext.ArrowButton {
opacity: 0.15
text: "\uf137"
onPressed: queryInput.cursorPosition--
onPressAndHold: queryInput.cursorPosition = 0
}
// cursor forward
Ext.ArrowButton {
opacity: 0.15
text: "\uf138"
onPressed: queryInput.cursorPosition++
onPressAndHold: queryInput.cursorPosition = queryInput.length
}
}
} }

View file

@ -33,6 +33,7 @@ StackView {
case "file": main.push(dialogFile); break; case "file": main.push(dialogFile); break;
case "debug": main.push(dialogDebug); break; case "debug": main.push(dialogDebug); break;
case "query": main.push(dialogQuery); break; case "query": main.push(dialogQuery); break;
case "help": main.push(dialogHelp); break;
} }
} }
@ -616,6 +617,7 @@ StackView {
Ext.FileBrowser { id: dialogFile; opacity: 0 } Ext.FileBrowser { id: dialogFile; opacity: 0 }
Ext.QueryDialog { id: dialogQuery; opacity: 0 } Ext.QueryDialog { id: dialogQuery; opacity: 0 }
Ext.DebugDialog { id: dialogDebug; opacity: 0 } Ext.DebugDialog { id: dialogDebug; opacity: 0 }
Ext.Help { id: dialogHelp; opacity: 0 }
Ext.ClipboardMenu {} Ext.ClipboardMenu {}

View file

@ -72,7 +72,6 @@
(define-symbol-macro :q (quicklisp))) (define-symbol-macro :q (quicklisp)))
(export (export
(list #+ios (list 'start-swank
'start-swank
'stop-swank 'stop-swank
'quicklisp)) 'quicklisp))

View file

@ -72,7 +72,6 @@
(define-symbol-macro :q (quicklisp))) (define-symbol-macro :q (quicklisp)))
(export (export
(list #+ios (list 'start-swank
'start-swank
'stop-swank 'stop-swank
'quicklisp)) 'quicklisp))

BIN
screenshots/cl-repl.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

View file

@ -7,7 +7,7 @@
#include <QQuickView> #include <QQuickView>
#include <QDebug> #include <QDebug>
const char LQML::version[] = "22.4.1"; // Apr 2022 const char LQML::version[] = "22.4.2"; // Apr 2022
extern "C" void ini_LQML(cl_object); extern "C" void ini_LQML(cl_object);