; 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)))
)
)