Re: [STUMP] Elementary ruler

David Bjergaard <[email protected]>
Newsgroups gmane.comp.window-managers.stumpwm.devel
Message-ID <[email protected]>
Hi,

Thanks for the snippet! If you want to put this on the wiki that would
be great! If you are interested in turning this into a full blown module
that's awesome too.  I can imagine a few cases where I would use this
(comparing scientific plots etc).

    Dave

sea <[email protected]> writes:

> Hi all, I just made this simple ruler for use with mapwork. It prints
> the current mouse position, and for any two consecutive calls, it prints
> the distance the mouse has travelled between the two. It's meant to be
> bound to a hotkey.
>
>
> (defvar *last-cursor-queried-position* (list 0 0))
>
> (defun euclidean-distance (a b)
>   (expt (apply #'+ (mapcar (lambda (x) (* x x)) (mapcar #'- a b)))))
>
> (defun cursor-position ()
>   (let ((x (multiple-value-list
> 	    (xlib:pointer-position 
> 	     (stumpwm::screen-root (stumpwm:current-screen))))))
>     (list (first x) (second x))))
>
> (defcommand show-cursor-position () ()
> 	    (let* ((pos (cursor-position))
> 		   (last-point *last-cursor-queried-position*)
> 		   (distance-from-last-point
> 		    (if *last-cursor-queried-position* 
> 			(euclidean-distance *last-cursor-queried-position* pos)
> 			nil)))
> 	      (setf *last-cursor-queried-position* pos)
> 	      (stumpwm:message 
> 	       (format nil 
> 		       "Now: ~A Distance from last queried point (~A): ~A~%"
> 		       pos last-point distance-from-last-point))))
>
>
> There's no error checking or documentation or anything but I doubt it
> will ever fail.
>
> It's handy when bound to <key>. Put the cursor at the start of a line,
> hit <key>, then put the cursor at the end of the line, hit <key>, it
> prints the length of the line, with a small error down to the accuracy
> of your cursor positioning. Handy for measuring distances on maps, as
> long as you have a scale line to compare the lengths to.
>
>
>
>
> _______________________________________________
> Stumpwm-devel mailing list
> [email protected]
> https://lists.nongnu.org/mailman/listinfo/stumpwm-devel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.