Last active 1 day ago

A description

samask revised this gist 1 day ago. Go to revision

1 file changed, 0 insertions, 0 deletions

Science Magazine - This is how you can remove a tree stump using physics.mp4(file created)

Binary file changes are not shown

samask revised this gist 1 day ago. Go to revision

No changes

samask revised this gist 1 day ago. Go to revision

1 file changed, 96 insertions

hello-world.lisp(file created)

@@ -0,0 +1,96 @@
1 + ;;; hello-name.lisp - A simple croatoan "Hello World" + name input example
2 + ;;;
3 + ;;; Prerequisites:
4 + ;;; 1. ncurses must be installed on your system
5 + ;;; macOS: brew install ncurses (usually pre-installed)
6 + ;;; Linux: apt-get install libncurses-dev
7 + ;;; 2. Load croatoan via Quicklisp:
8 + ;;; (ql:quickload :croatoan)
9 + ;;;
10 + ;;; To run: Load this file and call (hello-name)
11 + ;;; Note: Run from a real terminal, not from SLIME/Emacs REPL
12 + ;;; (ncurses doesn't work properly in SLIME)
13 +
14 + (defpackage :hello-name
15 + (:use :cl :croatoan)
16 + (:export #:hello-name))
17 +
18 + (in-package :hello-name)
19 +
20 + (defun hello-name ()
21 + "Display 'Hello World' and prompt for the user's name."
22 + (with-screen (scr :input-echoing t
23 + :input-buffering nil
24 + :cursor-visible t
25 + :enable-colors t)
26 + ;; Clear and set up
27 + (clear scr)
28 +
29 + ;; Display "Hello, World!" at top
30 + (move scr 2 5)
31 + (setf (color-pair scr) '(:cyan :black))
32 + (setf (attributes scr) '(:bold))
33 + (add-string scr "Hello, World!")
34 +
35 + ;; Prompt for name
36 + (setf (attributes scr) nil)
37 + (setf (color-pair scr) '(:white :black))
38 + (move scr 4 5)
39 + (add-string scr "Enter your name: ")
40 + (refresh scr)
41 +
42 + ;; Read the name character by character
43 + (let ((name (make-array 0 :element-type 'character
44 + :adjustable t
45 + :fill-pointer 0)))
46 + (event-case (scr event)
47 + ;; Enter key - finish input
48 + (#\Newline
49 + (return-from event-case))
50 + (#\Return
51 + (return-from event-case))
52 +
53 + ;; Backspace handling
54 + (#\Backspace
55 + (when (> (length name) 0)
56 + (vector-pop name)
57 + ;; Move cursor back and erase character
58 + (move scr 4 (+ 22 (length name)))
59 + (add-char scr #\Space)
60 + (move scr 4 (+ 22 (length name))))
61 + (refresh scr))
62 +
63 + ;; Delete key (also backspace on some terminals)
64 + (#\Rubout
65 + (when (> (length name) 0)
66 + (vector-pop name)
67 + (move scr 4 (+ 22 (length name)))
68 + (add-char scr #\Space)
69 + (move scr 4 (+ 22 (length name))))
70 + (refresh scr))
71 +
72 + ;; Regular character input
73 + (otherwise
74 + (when (and (characterp event)
75 + (graphic-char-p event))
76 + (vector-push-extend event name)
77 + (add-char scr event)
78 + (refresh scr))))
79 +
80 + ;; Display greeting
81 + (setf (color-pair scr) '(:green :black))
82 + (setf (attributes scr) '(:bold))
83 + (move scr 6 5)
84 + (add-string scr (format nil "Nice to meet you, ~A!" name))
85 +
86 + (setf (attributes scr) nil)
87 + (setf (color-pair scr) '(:white :black))
88 + (move scr 8 5)
89 + (add-string scr "Press any key to exit...")
90 + (refresh scr)
91 +
92 + ;; Wait for a keypress before exiting
93 + (get-char scr)
94 +
95 + ;; Return the name
96 + name)))
Newer Older