stumpwm-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [STUMP] Elementary ruler


From: David Bjergaard
Subject: Re: [STUMP] Elementary ruler
Date: Tue, 02 Sep 2014 10:19:57 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

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 <address@hidden> 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
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/stumpwm-devel



reply via email to

[Prev in Thread] Current Thread [Next in Thread]