Hi folks,
I believe this is missing:
(defgeneric listbox-delete (l start &optional end)) (defmethod listbox-delete ((l listbox) start &optional end) (check-type start (integer 0 *)) (format-wish "~a delete ~a ~a" (widget-path l) start (or end "end")))
If it isn't, what function should I be calling? :)
-Shawn
On 6/25/07, Shawn Betts sabetts@gmail.com wrote:
I believe this is missing:
As a general rule, what's the best way to submit patches for LTk? I spoke with Peter at ILC07 about some small changes I submitted 7 months ago but I don't think anything was done with them. I'm now maintaining about 45 methods and functions (many of which I'm sure are not general enough or even well enough written for LTk itself) but I'm sure some could be useful in the main library. I'd certainly like to get them out of my codebase :-)
Phil
Hi,
this mailing list is the best place I would say, as all LTk submitters are reading it. I have been a bit lazy with respect to updating the released LTk version, but I have all intends to fix that soon, so now would be the best moment to submit patches. For non-trivial patches please add a statement that you release them under LLGPL.
Peter
Hi Peter,
How are you?
this mailing list is the best place I would say, as all LTk submitters
OK. All of this can be released under the LLGPL.
Disclaimers follow (!) :
1. Some of this is probably not generic enough for LTk. 2. Some of it may already be in LTk but I've just not found it. 3. Some of it could certainly be improved. 4. I use most of these in ABLE so they do work (for some definition of 'work'!)
Phil
--
;;; This replaces the current ltk implementation of this method to remove ;;; the trailing CR that Tk leaves on (for "internal reasons"). (defmethod text ((text text)) (format-wish "senddatastring [~a get 1.0 end-1c]" (widget-path text)) (read-data))
(defmethod get-selection-start ((txt text)) (when (not (equal (selection-start txt) "")) (format-wish "senddatastring [~a index sel.first]" (widget-path txt)) (read-data)))
(defmethod get-selection-end ((txt text)) (when (not (equal (selection-start txt) "")) (format-wish "senddatastring [~a index sel.last]" (widget-path txt)) (read-data)))
(defmethod selected ((text text)) (when (not (equal (selection-start text) "")) (format-wish "senddatastring [~a get sel.first sel.last]" (widget-path text)) (read-data)))
(defmethod insert-text ((txt text) text &rest tags &key (position "insert")) (format-wish "~a insert ~a "~a" {~{ ~(~a~)~}}" (widget-path txt) position (tkescape text) tags) txt)
(defmethod delete-text ((txt text) start end) (format-wish "~a delete ~a ~a" (widget-path txt) start end))
(defmethod delete-current-char ((txt text)) (format-wish "~a delete "insert -1 chars" "insert"" (widget-path txt)))
(defmethod get-cursor-pos ((text text)) (format-wish "senddatastring [~a index insert]" (widget-path text)) (read-data))
(defmethod get-visible-pos ((txt text)) (format-wish "senddatastring [~a index "@0,0"]" (widget-path txt)) (read-data))
(defgeneric set-cursor-pos (widget pos) (:documentation "Sets the position of the cursor in the widget"))
(defmethod set-cursor-pos ((text text) pos) (format-wish "~a mark set insert ~a" (widget-path text) pos))
(defmethod set-cursor-pos ((ent entry) pos) (format-wish "~a icursor ~a" (widget-path ent) pos))
(defmethod get-last-line-index ((txt text)) (format-wish "senddatastring [~a index end]" (widget-path txt)) (read-data))
(defgeneric get-text-range (object start end) (:documentation "Gets a sub-string from an object using the Tk style text inices start and end"))
(defmethod get-text-range ((text text) start end) "Gets the sub-string by directly querying the Tk text widget" (format-wish "senddatastring [~a get ~a ~a]" (widget-path text) start end) (read-data))
(defmethod get-text-length ((txt text) start end) "Gets the length of text between two tk text indices. May be quicker than sending the text over the process boundaries and then calling length on it." (format-wish "senddatastring [string length [~a get ~a ~a]]" (widget-path txt) start end) (read-from-string (read-data)))
(defmethod get-text-to-cursor ((text text)) (format-wish "senddatastring [~a get "1.0" "insert"]" (widget-path text)) (read-data))
(defmethod get-current-word ((text text)) (format-wish "senddatastring [~a get "insert wordstart" "insert wordend"]" (widget-path text)) (read-data))
(defmethod get-current-line ((text text)) (format-wish "senddatastring [~a get "insert linestart" "insert lineend"]" (widget-path text)) (read-data))
(defmethod get-current-line-to-cursor ((text text)) (format-wish "senddatastring [~a get "insert linestart" "insert"]" (widget-path text)) (read-data))
(defmethod get-modify ((text text)) (format-wish "senddatastring [~a edit modified]" (widget-path text)) (read-data))
(defmethod reset-modify ((text text)) (format-wish "~a edit modified 0" (widget-path text)))
(defmethod un-bind ((w widget) key) "Unbind an event for a specific instance of a widget." (format-wish "bind ~a ~a {break}" (widget-path w) key))
(defun remove-binding (widget event) "Unbind an event for all instances of a widget class." (format-wish "bind ~a ~a { }" widget event))
(defmethod disable-input ((txt text)) (format-wish "bind ~a <Any-Key> {break}" (widget-path txt)))
(defmethod enable-input ((text text)) (format-wish "bind ~a <Any-Key> {}" (widget-path text)))
(defun withdraw-wish-toplevel () (format-wish "wm withdraw ."))
(defmethod add-tag ((txt text) name start end) (format-wish "~a tag add ~a ~a ~a" (widget-path txt) name start end))
(defmethod remove-tag ((txt text) name start end) (format-wish "~a tag remove ~a ~a ~a" (widget-path txt) name start end))
(defmethod add-tags ((txt text) indexed-tokens tag-name) (format-wish "eval ~a tag add ~a ~a" (widget-path txt) tag-name indexed-tokens))
(defmethod select-range ((txt text) start end) (format-wish "~a tag add sel ~a ~a" (widget-path txt) start end))
(defmethod select-all ((txt text)) (format-wish "~a tag add sel 1.0 end" (widget-path txt)))
(defmethod deselect-all ((txt text)) (format-wish "~a tag remove sel 1.0 end" (widget-path txt)))
;;; this can surely be written better... (defun strpos-to-textidx (str end &optional (row 1) (col 0) (index 0)) (let ((achar NIL) (pos (1- end))) (loop for c from index to pos do (setf achar (aref str index)) (if (eq achar #\Newline) (progn (incf row) (setf col 0)) (incf col)) (incf index)) (values row col index)))
(defmethod event-generate ((w widget) evt) (format-wish "event generate ~a ~a" w evt))
(defmethod paste ((txt text)) (format-wish "tk_textPaste ~a" (widget-path txt)))
(defun get-clipboard-text () (format-wish "senddatastring [selection get -selection CLIPBOARD]") (read-data))
(defun create-font (name family size weight slant) (format-wish "font create ~a -family {~a} -size ~a -weight ~a -slant ~a" name family size weight slant))
(defmethod tags-configure ((txt text) tag option1 value1 option2 value2) (format-wish "~a tag configure ~a -~a ~a -~a ~a" (widget-path txt) tag option1 value1 option2 value2) txt)
(defmethod get-cursor-pos-as-screen-coord ((txt text)) (format-wish "senddatastring [~a bbox insert]" (widget-path txt)) (setq pos (read-data)) (if (> (length pos) 0) pos nil))
(defgeneric listbox-get-selected-value (l)) (defmethod listbox-get-selected-value ((l listbox)) (format-wish "senddata "[~a get [~a curselection]]"" (widget-path l) (widget-path l)) (read-data))
Hi Phil,
On 6/25/07, Phil Armitage philip.armitage@gmail.com wrote:
Hi Peter,
How are you?
I am fine, but quite busy, so I never have enough time :)
this mailing list is the best place I would say, as all LTk submitters
OK. All of this can be released under the LLGPL.
Disclaimers follow (!) :
- Some of this is probably not generic enough for LTk.
- Some of it may already be in LTk but I've just not found it.
- Some of it could certainly be improved.
- I use most of these in ABLE so they do work (for some definition of 'work'!)
On the first glance, it looks as if I could use most of your functions. Cheers, Peter
On 6/27/07, Peter Herth herth@peter-herth.de wrote:
On the first glance, it looks as if I could use most of your functions.
I've changed DELETE-CURRENT-CHAR to this which I think is more general:
(defmethod delete-chars ((txt text) &optional (num 1)) (format-wish "~a delete "insert -~a chars" "insert"" (widget-path txt) num))
Also I think TAGS-CONFIGURE is disastrous and shouldn't have been included! I'm sure the current Ltk method allows you to set multiple attributes for a tag but I couldn't work out how to do it (maybe just a small example in the docs would suffice). If not, then something that takes a list of attributes would work.
(I have a tendency to just code what I need as I need it which is of course not the way to write a consistent API!)
Phil