본문으로 바로가기

r_t key

category 기타(ETC)/단축키정리 2026. 11. 8. 22:59

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Description: R key (Cycles Rect → Path → Bus), T key (Cycles Via mode)
;;              ESC key: Completely ends commands and immediately resets R/T modes on a single press
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; Global state variables
unless(boundp('myLayoutMode)  myLayoutMode = 0)
unless(boundp('myLayoutTMode) myLayoutTMode = 0)

;; ============================================================
;; R-KEY Toggle : Rect → Path → Bus (3-stage cycle)
;; ============================================================
procedure( MyRKeyToggle()
  let((cmd win)
    win = hiGetCurrentWindow()
    cmd = hiGetCurrentCmd(win)
    
    when( cmd != ""
      hiEnqueueCmd("cancelEnterFun()")
      hiEnqueueCmd("cancelEnterFun()")
    )
    
    myLayoutMode = myLayoutMode + 1
    if( myLayoutMode > 3 then myLayoutMode = 1 )
    
    case( myLayoutMode
      (1
        printf(">>> [R] Create Rect\n")
        hiEnqueueCmd("leHiCreateRect()")
      )
      (2
        printf(">>> [R] Create Path\n")
        hiEnqueueCmd("leHiCreatePath()")
      )
      (3
        printf(">>> [R] Create Bus\n")
        hiEnqueueCmd("leHiCreateBus()")
      )
    )
  )
)

;; ============================================================
;; T-KEY Toggle : Manual → AutoVia(Area) → AutoVia(SameNet) (3 stages)
;; ============================================================
procedure( MyTKeyToggle()
  let((cmd win)
    win = hiGetCurrentWindow()
    cmd = hiGetCurrentCmd(win)
    
    when( cmd != ""
      hiEnqueueCmd("cancelEnterFun()")
      hiEnqueueCmd("cancelEnterFun()")
    )
    
    myLayoutTMode = myLayoutTMode + 1
    if( myLayoutTMode > 3 then myLayoutTMode = 1 )
    
    case( myLayoutTMode
      (1
        printf(">>> [T] Manual Via mode\n")
      )
      (2
        printf(">>> [T] AutoVia (Area)\n")
        hiEnqueueCmd("leHiCreateVia()")
      )
      (3
        printf(">>> [T] AutoVia (Same Net)\n")
        hiEnqueueCmd("leHiCreateVia()")
      )
    )
  )
)

;; ============================================================
;; ESC Key: Immediate reset and forced command termination on a single press
;; ============================================================
procedure( MyEscapeKey()
  let((cmd win)
    win = hiGetCurrentWindow()
    cmd = hiGetCurrentCmd(win)
    
    ;; 1. Immediately reset state variables
    myLayoutMode = 0
    myLayoutTMode = 0
    printf(">>> [ESC] R/T modes reset to 0 (Idle)\n")
    
    ;; 2. If a command was running, cancel it twice consecutively for a complete and unconditional termination
    when( cmd != ""
      hiEnqueueCmd("cancelEnterFun()")
      hiEnqueueCmd("cancelEnterFun()")
      printf(">>> [ESC] Current command cancelled completely\n")
    )
  )
)

;; ============================================================
;; Register Bindkeys (This part is both the source of the issue and the solution)
;; ============================================================
hiSetBindKey("Layout" "<Key>r" "MyRKeyToggle()")
hiSetBindKey("Layout" "<Key>t" "MyTKeyToggle()")

;; 1. Normal state (when no command is active) ESC
hiSetBindKey("Layout" "<Key>Escape" "MyEscapeKey()")

;; 2. Intercept ESC using our custom function while a command is running (EnterFunction active)
hiSetBindKey("Layout" "<Key>Escape EF" "MyEscapeKey()")

printf("[KeyBinds] R / T / ESC shortcuts loaded (ESC now works in EnterFunction)\n")



;; Use ESDF keys as arrow keys (panning the screen) only while running object creation/editing commands (EnterFunction)
hiSetBindKey("Layout" "<Key>e EF" "geScroll(nil \"n\" nil)")  ;; E -> North
hiSetBindKey("Layout" "<Key>d EF" "geScroll(nil \"s\" nil)")  ;; D -> South
hiSetBindKey("Layout" "<Key>s EF" "geScroll(nil \"w\" nil)")  ;; S -> West
hiSetBindKey("Layout" "<Key>f EF" "geScroll(nil \"e\" nil)")  ;; F -> East

hiSetBindKey("Layout" "<Key>4 EF" "leHiAddWireVia(hiGetCurrentWindow() \"down\")")  ;; 4 -> Down Via
hiSetBindKey("Layout" "<Key>5 EF" "leHiAddWireVia(hiGetCurrentWindow() \"up\")")  ;; 5 -> Up Via

'기타(ETC) > 단축키정리' 카테고리의 다른 글

bus route  (0) 2026.11.08
poly ext  (0) 2026.11.08
sd metal  (0) 2026.11.08
quick align  (0) 2026.11.08