-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#25 use tmux capture-pane to create meaninful screen captures
- Loading branch information
Showing
5 changed files
with
204 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
|
||
(defvar *demo-root* (concat | ||
(vc-find-root | ||
(buffer-file-name | ||
(current-buffer)) | ||
".git") | ||
"/demo")) | ||
|
||
(defvar *demo-annotations* ()) | ||
|
||
(defun demo-frame-annotation (svg) | ||
(assoc-string | ||
svg | ||
*demo-annotations*)) | ||
|
||
(defun demo-annotate-frame (root svg) | ||
(save-window-excursion | ||
;; (toggle-frame-fullscreen ) | ||
(save-excursion | ||
(let ((buffer | ||
(find-file (concat root "/" svg)))) | ||
(unwind-protect | ||
(progn | ||
(delete-other-windows) | ||
(with-current-buffer buffer | ||
(let* ((size (image-size (image--get-image))) | ||
(width (car size)) | ||
(height (cdr size)) | ||
(scale (min (/ (window-width) width) | ||
(/ (window-height) height)))) | ||
(image--change-size scale))) | ||
(push | ||
(cons svg | ||
(read-string "Annotate this frame: ")) | ||
*demo-annotations*)) | ||
(kill-buffer buffer)))))) | ||
|
||
(defun demo-annotate-all-frames-in-folder (root) | ||
(cl-loop for svg in (directory-files root nil "\\.svg$") | ||
repeat 1 | ||
unless (demo-frame-annotation svg) | ||
do (demo-annotate-frame root svg))) | ||
|
||
(demo-annotate-all-frames-in-folder | ||
(concat | ||
*demo-root* | ||
"/annotated")) | ||
|
||
|
||
|
||
|
||
(defun demo-read-annotation-from-text-file (file) | ||
(cl-loop for line in | ||
(split-string | ||
(with-temp-buffer | ||
(insert-file-contents file) | ||
(buffer-substring-no-properties (point-min) (point-max))) | ||
"\n" | ||
t) | ||
collect | ||
(save-match-data | ||
(and (string-match | ||
"^\\([a-z0-9]+\\) \\([^ ]+\\) ?\\(.*\\)$" line) | ||
(let ((filename | ||
(match-string 2 line)) | ||
(hash (match-string 1 line)) | ||
(annotation (match-string 3 line))) | ||
(list | ||
filename | ||
:sha1 hash | ||
:annotation | ||
(if (string-empty-p annotation) | ||
;; Get from global variable | ||
(getf | ||
(cdr (demo-frame-annotation | ||
(match-string 2 line))) | ||
:annotation) | ||
annotation))))))) | ||
|
||
|
||
|
||
(defvar *demo-annotation-from-file* | ||
(let* ((root (concat | ||
*demo-root* | ||
"/annotated")) | ||
(file (concat root "/annotations.txt"))) | ||
(demo-read-annotation-from-text-file file))) | ||
|
||
|
||
(getf | ||
(cdr | ||
(assoc-string "termtosvg_00001.svg" | ||
*demo-annotation-from-file*)) | ||
:annotation) | ||
|
||
;; (setf *demo-annotations* *demo-annotation-from-file*) | ||
;; (setf *demo-annotation-from-file* *demo-annotations*) | ||
|
||
;; Write it back | ||
(let* ((root (concat | ||
*demo-root* | ||
"/annotated")) | ||
(file (concat root "/annotations2.txt"))) | ||
(with-temp-buffer | ||
(cl-loop for (filename _ hash _ annotation) in *demo-annotation-from-file* | ||
do (insert hash " " filename " " annotation "\n")) | ||
(when (file-writable-p file) | ||
(write-region (point-min) | ||
(point-max) | ||
file)) | ||
(buffer-substring-no-properties (point-min) (point-max)) | ||
)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/usr/bin/env sh | ||
# | ||
# This is an example of how to take a bunch of capture made with tmux | ||
# and assemble them with termtosvg | ||
# | ||
# usage: termtosvg output.svg -c ./animate.sh | ||
# or: termtosvg $demo_root -s -c ./animate.sh | ||
# | ||
|
||
# Stop on first error | ||
set -e | ||
|
||
# Move to repo's root | ||
cd "$(git rev-parse --show-toplevel)" | ||
|
||
demo_root=scripts/demo/ | ||
|
||
if [ ! -d "$demo_root" ]; then | ||
echo "Demo folder doesn't exits" | ||
exit 1 | ||
fi | ||
|
||
for capture in $(echo $demo_root/*.capture | sort -n) ; do | ||
# echo "$capture" | ||
cat "$capture" | ||
sleep 0.5 | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
;; Setup a lisp process before making a demo | ||
|
||
(cl:in-package #:cl) | ||
|
||
(ql:quickload '(swank breeze)) | ||
|
||
(swank:create-server :port 40050 :dont-close t) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,28 @@ | ||
#!/usr/bin/env sh | ||
# | ||
# In another shell, run | ||
# sbcl --load demo.lisp | ||
# | ||
|
||
# Stop on first error | ||
set -e | ||
|
||
# Move to repo's root | ||
cd "$(git rev-parse --show-toplevel)" | ||
|
||
termtosvg demo.svg -c 'emacs -nw -Q -l scripts/emacs-director/util/director-bootstrap.el -l scripts/demo.el' | ||
# firefox demo.svg | ||
demo_root=scripts/demo | ||
mkdir -p scripts/demo | ||
|
||
tail demo.log | ||
screencast="demo.svg" | ||
command='emacs -nw -Q -l scripts/emacs-director/util/director-bootstrap.el -l scripts/demo.el -- asdf' | ||
# ^^^ -- asdf is just an example of passing arguments (e.g. swank's | ||
# port). | ||
|
||
if true; then | ||
$command | ||
else | ||
termtosvg "$screencast" -m 100 -c "$command" | ||
# firefox demo.svg | ||
fi | ||
|
||
tail $demo_root/demo.log |