p4switch - little app that switches between different P4 servers
- From: "Dimiter \"malkia\" Stanev" <malkia@xxxxxxxxx>
- Date: Thu, 27 Sep 2007 15:58:45 -0700
Hi,
I wrote a little application, that switches between different P4 servers. It's Win32 specific, and uses what P4Win stores in the Windows registry to retrieve the most recent specified servers.
It's also LispWorks specific (I've used 5.0.2 professional).
The delivered executable is quite big - 5MB, couldn't find a way to squeeze it.
Thanks,
Dimiter "malkia" Stanev.
(defpackage "P4SWITCH" (:use "CL" "LISPWORKS"))
(in-package "P4SWITCH")
(defconstant +p4-client-list-registry-key+
"Software\\Perforce\\P4Win\\Recent Port-Client-User List")
(defconstant +p4-environment-registry-key+
"Software\\Perforce\\Environment")
(defun p4-get-default-client ()
(mapcar #'(lambda (value-name)
(win32:registry-value
+p4-environment-registry-key+
value-name))
'("P4PORT" "P4CLIENT" "P4USER")))
(defun p4-set-default-client (client-list)
(assert (= (length client-list) 3))
(mapcar #'(lambda (value-name value)
(setf (win32:registry-value
+p4-environment-registry-key+
value-name
:expected-type :string)
value))
'("P4PORT" "P4CLIENT" "P4USER")
client-list))
#+nil
(p4-get-default-client)
#+nil
(p4-set-default-client (p4-get-default-client))
(defun p4-get-recent-clients ()
(let ((clients-list
(win32:collect-registry-values
+p4-client-list-registry-key+))
(clients))
(dolist (client clients-list)
(let ((client-list
(split-sequence " " (cdr client))))
(when (= (length client-list) 3)
(pushnew client-list clients)
#+nil
(format t "P4PORT=~A P4CLIENT=~A P4USER=~A~&"
(first client-list)
(second client-list)
(third client-list)))))
(nreverse clients)))
#+nil
(p4-get-recent-clients)
(capi:define-interface p4switch-interface ()
((p4-default-client :initform (p4-get-default-client))
(p4-recent-clients :initform (p4-get-recent-clients)))
(:panes
(listbox
capi:multi-column-list-panel
:columns '((:title "Server:port")
(:title "Client")
(:title "User"))
:items p4-recent-clients
:action-callback #'(lambda (item self)
(p4-set-default-client item))))
(:layouts
(simple-layout-1
capi:simple-layout
'(listbox)))
(:default-initargs
:layout 'simple-layout-1
:best-height 300
:best-width 300
:title "p4switch - malkia@xxxxxxxxx"))
(defmethod initialize-instance :after ((self p4switch-interface)
&key &allow-other-keys)
(with-slots (listbox p4-default-client) self
(print p4-default-client)
(setf (capi:collection-test-function listbox) #'equal)
(setf (capi:choice-selected-item listbox) p4-default-client)))
(defun main ()
(capi:display (make-instance 'p4switch-interface)))
#+nil
(main)
(in-package "CL-USER")
(load-all-patches)
(defvar *delivered-image-name* "p4switch")
(compile-file-if-needed (current-pathname *delivered-image-name*) :load t :output-file (pathname-location *delivered-image-name*))
(deliver 'p4switch::main *delivered-image-name* 5 :interface :capi)
- Prev by Date: Re: (not about) Re: How To Learn Lisp
- Next by Date: Explain why calling a named function conses and lambda doesn't?!?!?!?!
- Previous by thread: How to implement heap as a binary tree in lisp?
- Next by thread: Explain why calling a named function conses and lambda doesn't?!?!?!?!
- Index(es):
Relevant Pages
|