説明
レイアウト作業で煩わしいことの一つにキーボードからの入力があります。例えば、ルーラーで測った距離の分だけセルを動かしたい場合に、ルーラーの数値を Move の設定フォームにキーボードから手入力するのは面倒です。選択したルーラーの長さをクリップボード経由で転送できたら便利だろぉ…、ということで、そんな関数を作ってみました。
(jp_wikiwiki_aiou_InteractiveBuffer_Clipboard_setSelectedRulerLength)
ルーラーを選択して(IC6以上ではルーラーを選択できます)、その長さをクリップボードに転送するものです。あとは、Move の設定フォームで、Ctrl+V を押せば(またはポップアップ・メニューで Paste を選択すれば)長さの文字列がスバリ入ります。
また、開いているセルのライブラリー名、セル名、ビュー名をクリップボードに送る関数もあります。
(jp_wikiwiki_aiou_InteractiveBuffer_Clipboard_setCurrentLCV)
これらの関数をバインドキーに設定すると便利です。
; バインドキー設定の例 (hiSetBindKey "Layout" "<Key>F5" "(jp_wikiwiki_aiou_InteractiveBuffer_Clipboard_setSelectedRulerLength)") (hiSetBindKey "Layout" "<Key>F9" "(jp_wikiwiki_aiou_InteractiveBuffer_Clipboard_setCurrentLCV)")
X-Window のクリップボードに任意の文字列を送る汎用の関数もありますので、あなた好みの色々な機能を作ってみて下さい。(*´∀`*)
; クリップボードの内容を消去する。 (jp_wikiwiki_aiou_InteractiveBuffer_ClipBoard_clear)
; 文字列 string をクリップボードに設定する。 (jp_wikiwiki_aiou_InteractiveBuffer_ClipBoard_set string)
; 文字列 string をクリップボードに追加する。 (jp_wikiwiki_aiou_InteractiveBuffer_ClipBoard_append string)
なお、上記のすべての関数は 子プロセスとして Tcl 処理系「wish」を用いていますので、wish がインストールされていない環境では使えません。(Interactive DRC、LVS、RVE が使える環境であれば wish はインストールされています。)
また、これらの関数では(X-Window の)セレクションを操作することはできません。
ソースコード
; Virtuoso から Tcl 処理系に Tcl コマンド command を送る関数。(内部で使用する関数)
; 子プロセスとして Tcl 処理系 「wish」 を起動する。
(define (jp_wikiwiki_aiou_InteractiveBuffer__sendCommands commands)
(unless
(and
(boundp (quote jp_wikiwiki_aiou_InteractiveBuffer__tcl))
jp_wikiwiki_aiou_InteractiveBuffer__tcl
(ipcIsAliveProcess jp_wikiwiki_aiou_InteractiveBuffer__tcl)
)
(setq jp_wikiwiki_aiou_InteractiveBuffer__tcl
(ipcBeginProcess "wish" "" (lambda (a b) t) (lambda (a b) t))
)
)
(ipcWriteProcess jp_wikiwiki_aiou_InteractiveBuffer__tcl commands)
)
; クリップボードの内容を消去する。 (define (jp_wikiwiki_aiou_InteractiveBuffer_ClipBoard_clear) (jp_wikiwiki_aiou_InteractiveBuffer__sendCommands "clipboard clear\n") )
; 文字列 string をクリップボードに設定する。
(define (jp_wikiwiki_aiou_InteractiveBuffer_ClipBoard_set string)
(jp_wikiwiki_aiou_InteractiveBuffer__sendCommands "clipboard clear\n")
(jp_wikiwiki_aiou_InteractiveBuffer__sendCommands "clipboard append {%s}\n" string)
)
; 文字列 string をクリップボードに追加する。
(define (jp_wikiwiki_aiou_InteractiveBuffer_ClipBoard_append string)
(jp_wikiwiki_aiou_InteractiveBuffer__sendCommands "clipboard append {%s}\n")
)
; 現在開いているセルのライブラリ名、セル名、ビュー名をスペースで繋げたものを
; クリップボードに設定する。
; ★ この関数をバインドキーに設定すると便利かもしれません。 (・∀・)
;
; 《例》 (hiSetBindKey "Layout" "<Key>F9" "(jp_wikiwiki_aiou_InteractiveBuffer_Clipboard_setCurrentLCV)")
(define (jp_wikiwiki_aiou_InteractiveBuffer_Clipboard_setCurrentLCV)
(let
((cv (hiGetCurrentWindow)~>cellView))
(jp_wikiwiki_aiou_InteractiveBuffer__sendCommands "clipboard clear\n")
(jp_wikiwiki_aiou_InteractiveBuffer__sendCommands
(sprintf nil "clipboard append {%s %s %s}\n" cv~>libName cv~>cellName cv~>viewName)
)
cv
)
)
; 現在選択されているルーラーの長さを求めて、それをクリップボードに設定する。
; ★ この関数をバインドキーに設定すると便利かもしれません。 (・∀・)
;
; 《例》 (hiSetBindKey "Layout" "<Key>F5" "(jp_wikiwiki_aiou_InteractiveBuffer_Clipboard_setSelectedRulerLength)")
(define (jp_wikiwiki_aiou_InteractiveBuffer_Clipboard_setSelectedRulerLength)
(letseq
((rulers (setof o (geGetSelectedSet) (equal o~>objType "ruler"))))
(when rulers
(jp_wikiwiki_aiou_InteractiveBuffer__sendCommands "clipboard clear\n")
(jp_wikiwiki_aiou_InteractiveBuffer__sendCommands
(sprintf nil "clipboard append {%f}\n" (Path_getLength (car rulers)~>points))
)
(car rulers)
)
)
)
; ----------------------------------------------------------------------------- ; (Path_getLength this) ; ----------------------------------------------------------------------------- ; パスの頂点列 this を受け取り、隣り合う頂点間の距離の合計を求めて返す、汎用の関数。 ; ; ※ レイアウトのパスオブジェクト path の頂点列は path~>points で得られます。、 ; path の両端が truncate の場合には (Path_getLength path~>points) で長さが得ら ; れますが、path の片方または両方の端が extended、round、variable の場合は、 ; この関数だけでは正確な長さは求まりませんので、ご注意ください。 ; -----------------------------------------------------------------------------
(define (Path_getLength this)
(letrec
(
(p (car this))
(ps (cdr this))
(len 0.0)
)
(while ps
(setq len (plus len (Point_getDistanceTo p (car ps))))
(setq p (car ps))
(setq ps (cdr ps))
)
len
)
)
; ----------------------------------------------------------------------------- ; (Point_getDistanceTo this another) ; ----------------------------------------------------------------------------- ; 二点 this と another の間の距離を求めて返す、汎用の関数。 ; -----------------------------------------------------------------------------
(define (Point_getDistanceTo this another)
(let
(
(dx (difference (car this) (car another)))
(dy (difference (cadr this) (cadr another)))
)
(sqrt (plus (times dx dx) (times dy dy)))
)
)