Skip to content

Commit

Permalink
NEARESTCORNER must be onscreen (addresses #1294 (#1295)
Browse files Browse the repository at this point in the history
* NEARESTCORNER must be onscreen  (addresses #1294

Mouse jumps to the nearest onscreen corner of the ghost region

* MODERNIZE:  Fixed off by one bug in NEARESTCORNER
  • Loading branch information
rmkaplan authored Nov 4, 2023
1 parent 5b90251 commit 328d3f5
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 61 deletions.
122 changes: 61 additions & 61 deletions lispusers/MODERNIZE
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
(DEFINE-FILE-INFO PACKAGE "INTERLISP" READTABLE "INTERLISP" BASE 10)

(FILECREATED " 7-Oct-2022 21:45:29" 
{DSK}<Users>kaplan>Local>medley3.5>working-medley>lispusers>MODERNIZE.;43 30755
(FILECREATED "29-Oct-2023 10:56:48" {WMEDLEY}<lispusers>MODERNIZE.;48 30909

:CHANGES-TO (FNS MODERNWINDOW)
:EDIT-BY rmk

:PREVIOUS-DATE " 5-Mar-2022 23:20:21"
{DSK}<Users>kaplan>Local>medley3.5>working-medley>lispusers>MODERNIZE.;40)
:CHANGES-TO (FNS NEARESTCORNER)

:PREVIOUS-DATE "29-Jul-2023 10:48:55" {WMEDLEY}<lispusers>MODERNIZE.;47)


(PRETTYCOMPRINT MODERNIZECOMS)
Expand All @@ -30,7 +30,7 @@

(* ;; "Add some Meta commands")

(FNS TEDIT.MODERNIZE \MODERNIZED.TEDIT.BUTTONEVENTFN TEDIT.SELECTALL)
(FNS TEDIT.MODERNIZE \MODERNIZED.TEDIT.BUTTONEVENTFN)
(DECLARE%: DONTEVAL@LOAD DOCOPY (P
(* ;; "Tedit")

Expand Down Expand Up @@ -325,21 +325,47 @@
(IGREATERP LASTMOUSEX (IPLUS LEFT (TIMES WIDTH (DIFFERENCE 1 TITLEPROPORTION])

(NEARESTCORNER
[LAMBDA (REGION) (* ; "Edited 14-Feb-2021 21:46 by rmk:")

(* ;;
"Moves the cursor to the corner of REGION that is closest to the current LASTMOUSEX AND LASTMOUSEY")

(\CURSORPOSITION (CL:IF (ILESSP (IDIFFERENCE LASTMOUSEX (FETCH LEFT OF REGION))
(IDIFFERENCE (FETCH RIGHT OF REGION)
LASTMOUSEX))
(FETCH LEFT OF REGION)
(FETCH RIGHT OF REGION))
(CL:IF (ILESSP (IDIFFERENCE LASTMOUSEY (FETCH BOTTOM OF REGION))
(IDIFFERENCE (FETCH TOP OF REGION)
LASTMOUSEY))
(FETCH BOTTOM OF REGION)
(FETCH TOP OF REGION))])
[LAMBDA (REGION) (* ; "Edited 29-Oct-2023 10:56 by rmk")
(* ; "Edited 29-Jul-2023 10:32 by rmk")
(* ; "Edited 14-Feb-2021 21:46 by rmk:")

(* ;; "Moves the cursor to the corner of REGION that is closest to the current LASTMOUSEX and LASTMOUSEY, provided that that corner is on-screen.")

(LET ((LEFT (FETCH (REGION LEFT) OF REGION))
(RIGHT (FETCH (REGION RIGHT) OF REGION))
(TOP (FETCH (REGION TOP) OF REGION))
(BOTTOM (FETCH (REGION BOTTOM) OF REGION))
X Y)

(* ;; "If the nearest corner is offscreen, pick the other one.")

(SETQ X (if (OR (ILESSP LEFT 0)
(IGEQ LEFT SCREENWIDTH))
then
(* ;; "LEFT is offscreen")

RIGHT
elseif (ILESSP (IDIFFERENCE LASTMOUSEX LEFT)
(IDIFFERENCE RIGHT LASTMOUSEX))
then
(* ;; "Closer to LEFT")

LEFT
else RIGHT))
(SETQ Y (if (OR (ILESSP TOP 0)
(IGEQ TOP SCREENHEIGHT))
then
(* ;; "TOP is offscreen")

BOTTOM
elseif (ILESSP (IDIFFERENCE LASTMOUSEY BOTTOM)
(IDIFFERENCE TOP LASTMOUSEY))
then
(* ;; "Closer to BOTTOM")

BOTTOM
else TOP))
(\CURSORPOSITION X Y])

(INCORNER.REGION
[LAMBDA (CORNERREGION TOPMARGIN) (* ; "Edited 13-Oct-2021 15:04 by rmk:")
Expand Down Expand Up @@ -470,50 +496,25 @@
(DEFINEQ

(TEDIT.MODERNIZE
[LAMBDA NIL (* ; "Edited 11-Oct-2021 15:02 by rmk:")
[LAMBDA NIL (* ; "Edited 14-Jun-2023 16:56 by rmk")
(* ; "Edited 11-Oct-2021 15:02 by rmk:")
(MODERNWINDOW.SETUP (FUNCTION \TEDIT.BUTTONEVENTFN)
(FUNCTION \MODERNIZED.TEDIT.BUTTONEVENTFN))
(CL:WHEN (GETD '\TEDIT.BUTTONEVENTFN)

(* ;; "All")

(TEDIT.SETFUNCTION (CHARCODE "Meta,a")
(FUNCTION TEDIT.SELECTALL)
TEDIT.READTABLE)
(TEDIT.SETFUNCTION (CHARCODE "Meta,A")
(FUNCTION TEDIT.SELECTALL)
TEDIT.READTABLE)

(* ;; "Quit")

(TEDIT.SETFUNCTION (CHARCODE "Meta,q")
(FUNCTION TEDIT.QUIT)
TEDIT.READTABLE)
(TEDIT.SETFUNCTION (CHARCODE "Meta,Q")
(FUNCTION TEDIT.QUIT)
TEDIT.READTABLE))])
(FUNCTION \MODERNIZED.TEDIT.BUTTONEVENTFN])

(\MODERNIZED.TEDIT.BUTTONEVENTFN
[LAMBDA (W STREAM) (* ; "Edited 13-Oct-2021 21:43 by rmk:")
[LAMBDA (W STREAM) (* ; "Edited 29-Jul-2023 10:48 by rmk")
(* ; "Edited 13-Oct-2021 21:43 by rmk:")

(* ;; "If a TEDIT window has been split, we have to make sure that movement happens only for clicks at the top of the main window and at the bottom of the bottom-most split window. Clicks near the split lines must be ignored. Essentially, the %"region%" of the Tedit window is the union of the regions of all of its split-panes.")

(* ;; "We pass the pain that received the click, because that's what the original \TEDIT.BUTTONEVENTFN needs to see, if we decide not to shape or move.")
(* ;; "We pass the pane that received the click, because that's what the original \TEDIT.BUTTONEVENTFN needs to see, if we decide not to shape or move.")

(MODERNWINDOW.BUTTONEVENTFN W (FUNCTION MODERN-ORIG-\TEDIT.BUTTONEVENTFN)
NIL NIL [APPLY (FUNCTION UNIONREGIONS)
(bind PANE _ (CENTRALWINDOW W) collect (WINDOWPROP PANE
'REGION)
(bind PANE _ (CENTRALWINDOW W) collect (WINDOWPROP PANE 'REGION)
repeatwhile (SETQ PANE (WINDOWPROP PANE 'TEDIT-NEXT-PANE-DOWN]
(WINDOWPROP (CENTRALWINDOW W)
'TITLE])

(TEDIT.SELECTALL
[LAMBDA (STREAM TEXTOBJ SEL) (* ; "Edited 3-May-2020 17:29 by rmk:")
(LET [(TEXTSTREAM (TEXTSTREAM (TTY.PROCESS]
(CL:WHEN TEXTSTREAM
(TEDIT.SETSEL TEXTSTREAM 0 (ADD1 (fetch TEXTLEN of (TEXTOBJ TEXTSTREAM)))
'LEFT))])
)
(DECLARE%: DONTEVAL@LOAD DOCOPY

Expand Down Expand Up @@ -614,12 +615,11 @@
(ADDTOVAR LAMA MODERN-ADD-EXEC)
)
(DECLARE%: DONTCOPY
(FILEMAP (NIL (5125 11487 (MODERNWINDOW 5135 . 6675) (MODERNWINDOW.SETUP 6677 . 9626) (UNMODERNWINDOW
9628 . 10022) (MODERNWINDOW.UNSETUP 10024 . 10836) (\MODERNIZED.FREEMENU.BUTTONEVENTFN 10838 . 11485))
(11552 21714 (MODERNWINDOW.BUTTONEVENTFN 11562 . 18589) (NEARTOP 18591 . 19519) (NEARESTCORNER 19521
. 20400) (INCORNER.REGION 20402 . 21712)) (21772 24244 (MODERN-ADD-EXEC 21782 . 22213) (MODERN-SNAPW
22215 . 22758) (TOTOPW.MODERNIZE 22760 . 23188) (MODERN-MENUBUTTONFN 23190 . 24242)) (24245 26674 (
\MODERNIZED.FREEMENU.BUTTONEVENTFN 24255 . 24902) (MODERNIZED.TB.BUTTONEVENTFN 24904 . 26672)) (26715
28994 (TEDIT.MODERNIZE 26725 . 27539) (\MODERNIZED.TEDIT.BUTTONEVENTFN 27541 . 28663) (TEDIT.SELECTALL
28665 . 28992)))))
(FILEMAP (NIL (5048 11410 (MODERNWINDOW 5058 . 6598) (MODERNWINDOW.SETUP 6600 . 9549) (UNMODERNWINDOW
9551 . 9945) (MODERNWINDOW.UNSETUP 9947 . 10759) (\MODERNIZED.FREEMENU.BUTTONEVENTFN 10761 . 11408)) (
11475 22625 (MODERNWINDOW.BUTTONEVENTFN 11485 . 18512) (NEARTOP 18514 . 19442) (NEARESTCORNER 19444 .
21311) (INCORNER.REGION 21313 . 22623)) (22683 25155 (MODERN-ADD-EXEC 22693 . 23124) (MODERN-SNAPW
23126 . 23669) (TOTOPW.MODERNIZE 23671 . 24099) (MODERN-MENUBUTTONFN 24101 . 25153)) (25156 27585 (
\MODERNIZED.FREEMENU.BUTTONEVENTFN 25166 . 25813) (MODERNIZED.TB.BUTTONEVENTFN 25815 . 27583)) (27626
29148 (TEDIT.MODERNIZE 27636 . 27989) (\MODERNIZED.TEDIT.BUTTONEVENTFN 27991 . 29146)))))
STOP
Binary file modified lispusers/MODERNIZE.LCOM
Binary file not shown.

0 comments on commit 328d3f5

Please sign in to comment.