;; ============================================================
;; [Helper Function] Temporarily display text at mouse position and clear it
;; ============================================================
procedure( ShowQATransientText( textStr )
let((cv win mousePt centerX centerY textId timerStr fontSize)
cv = geGetEditCellView()
win = hiGetCurrentWindow()
if(cv && win then
;; 1. Prevent overlapping: If a previous label still exists, delete it immediately
if( win->myTempQALabel && dbIsId(win->myTempQALabel) then
dbDeleteObject(win->myTempQALabel)
)
;; 2. Dynamically calculate font size according to screen zoom ratio (1/30 of screen width)
fontSize = (caadr(hiGetViewBBox(win)) - caar(hiGetViewBBox(win))) / 30.0
if( fontSize <= 0.0 then fontSize = 1.0 )
;; 3. Get current mouse pointer coordinates
mousePt = hiGetCommandPoint()
if(mousePt then
centerX = car(mousePt)
centerY = cadr(mousePt)
;; 4. Create temporary label (text)
textId = dbCreateLabel(cv list("text" "drawing") centerX:centerY
textStr "centerCenter" "R0" "roman" fontSize)
if(textId && dbIsId(textId) then
textId->isTransient = t
win->myTempQALabel = textId
hiRedraw(win)
;; 5. Run timer to delete the label after 1.0 second (10 ticks)
timerStr = "
let((win targetId)
win = hiGetCurrentWindow()
if(win && win->myTempQALabel then
targetId = win->myTempQALabel
if(dbIsId(targetId) then
dbDeleteObject(targetId)
hiRedraw(win)
)
win->myTempQALabel = nil
)
)
"
hiRegTimer(timerStr 10)
)
)
)
)
)
;; ============================================================
;; [Main Function 1] Check current value (for Shift + `) - No value change
;; ============================================================
procedure( CheckAlignSpacing()
let( (currentStr dispStr)
if( boundp('leQckAlignForm) && leQckAlignForm then
;; Get current value (string) from the form
currentStr = leQckAlignForm->qckAlignSpacingValField->value
if( currentStr == nil || currentStr == "" then
currentStr = "0.000"
)
;; Output current state to mouse cursor (e.g., Current: 0.120)
sprintf(dispStr "Current: %s" currentStr)
ShowQATransientText(dispStr)
else
ShowQATransientText("Press F3 First!")
printf(">>> [Notice] Align form is not loaded yet.\n")
)
)
)
;; ============================================================
;; [Main Function 2] Reset function (for Ctrl + `)
;; ============================================================
procedure( ResetAlignSpacing()
if( boundp('leQckAlignForm) && leQckAlignForm then
;; Switch to User Spacing mode unconditionally
errset( leQckAlignForm->qckAlignSpacingField->value = "User Spacing" nil )
;; Initialize value to 0
errset( leQckAlignForm->qckAlignSpacingValField->value = "0.000" nil )
;; Output status text to mouse cursor
ShowQATransientText("Space: 0.000")
else
ShowQATransientText("Press F3 First!")
printf(">>> [Notice] Align form is not loaded yet.\n")
)
)
;; ============================================================
;; [Main Function 3] Addition function (for Ctrl + 1, 2, 3, 4)
;; ============================================================
procedure( AddToAlignSpacing( addVal )
let( (currentStr currentVal newVal newStr dispStr)
if( boundp('leQckAlignForm) && leQckAlignForm then
errset( leQckAlignForm->qckAlignSpacingField->value = "User Spacing" nil )
currentStr = leQckAlignForm->qckAlignSpacingValField->value
if( currentStr == nil || currentStr == "" then
currentVal = 0.0
else
currentVal = atof(currentStr)
)
newVal = currentVal + addVal
sprintf(newStr "%.3f" newVal)
errset( leQckAlignForm->qckAlignSpacingValField->value = newStr nil )
sprintf(dispStr "Space: %s" newStr)
ShowQATransientText(dispStr)
else
ShowQATransientText("Press F3 First!")
printf(">>> [Notice] Align form is not loaded yet.\n")
)
)
)
;; ============================================================
;; [Bindkeys Settings]
;; ============================================================
;; Shift + ` (Tilde) : Check current value only
hiSetBindKey("Layout" "Shift<Key>`" "CheckAlignSpacing()")
hiSetBindKey("Layout" "<Key>~" "CheckAlignSpacing()") ;; Depending on the keyboard, Shift+` may be recognized as ~
;; Ctrl + ` (Backtick) : Reset (Switch to User Spacing and set to 0)
hiSetBindKey("Layout" "Ctrl<Key>`" "ResetAlignSpacing()")
;; Ctrl + 1 : Current value + 1.0
hiSetBindKey("Layout" "Ctrl<Key>1" "AddToAlignSpacing(1.0)")
;; Ctrl + 2 : Current value + 0.1
hiSetBindKey("Layout" "Ctrl<Key>2" "AddToAlignSpacing(0.1)")
;; Ctrl + 3 : Current value + 0.01
hiSetBindKey("Layout" "Ctrl<Key>3" "AddToAlignSpacing(0.01)")
;; Ctrl + 4 : Current value + 0.001
hiSetBindKey("Layout" "Ctrl<Key>4" "AddToAlignSpacing(0.001)")
printf(">>> Quick Align Hotkeys & Transient Display Loaded!\n")
quick align
2026. 11. 8. 22:49

