@@ -67,7 +67,8 @@ enum UpdateLocationStrategy {
6767 activeScreen: NSScreen ,
6868 hideCircularWidget: Bool = UserDefaults . shared. value ( for: \. hideCircularWidget) ,
6969 preferredInsideEditorMinWidth: Double = UserDefaults . shared
70- . value ( for: \. preferWidgetToStayInsideEditorWhenWidthGreaterThan)
70+ . value ( for: \. preferWidgetToStayInsideEditorWhenWidthGreaterThan) ,
71+ editorFrameExpendedSize: CGSize = . zero
7172 ) -> WidgetLocation {
7273 return HorizontalMovable ( ) . framesForWindows (
7374 y: mainScreen. frame. height - editorFrame. maxY + Style. widgetPadding,
@@ -76,7 +77,8 @@ enum UpdateLocationStrategy {
7677 mainScreen: mainScreen,
7778 activeScreen: activeScreen,
7879 preferredInsideEditorMinWidth: preferredInsideEditorMinWidth,
79- hideCircularWidget: hideCircularWidget
80+ hideCircularWidget: hideCircularWidget,
81+ editorFrameExpendedSize: editorFrameExpendedSize
8082 )
8183 }
8284 }
@@ -89,7 +91,8 @@ enum UpdateLocationStrategy {
8991 mainScreen: NSScreen ,
9092 activeScreen: NSScreen ,
9193 preferredInsideEditorMinWidth: Double ,
92- hideCircularWidget: Bool = UserDefaults . shared. value ( for: \. hideCircularWidget)
94+ hideCircularWidget: Bool = UserDefaults . shared. value ( for: \. hideCircularWidget) ,
95+ editorFrameExpendedSize: CGSize = . zero
9396 ) -> WidgetLocation {
9497 let maxY = max (
9598 y,
@@ -121,8 +124,9 @@ enum UpdateLocationStrategy {
121124 proposedAnchorFrameOnTheRightSide = widgetFrameOnTheRightSide
122125 }
123126
124- let proposedPanelX = proposedAnchorFrameOnTheRightSide. maxX + Style
125- . widgetPadding * 2
127+ let proposedPanelX = proposedAnchorFrameOnTheRightSide. maxX
128+ + Style. widgetPadding * 2
129+ - editorFrameExpendedSize. width
126130 let putPanelToTheRight = {
127131 if editorFrame. size. width >= preferredInsideEditorMinWidth { return false }
128132 return activeScreen. frame. maxX > proposedPanelX + Style. panelWidth
@@ -133,8 +137,9 @@ enum UpdateLocationStrategy {
133137 let anchorFrame = proposedAnchorFrameOnTheRightSide
134138 let panelFrame = CGRect (
135139 x: proposedPanelX,
136- y: alignPanelTopToAnchor ? anchorFrame. maxY - Style. panelHeight : anchorFrame
137- . minY,
140+ y: alignPanelTopToAnchor
141+ ? anchorFrame. maxY - Style. panelHeight
142+ : anchorFrame. minY - editorFrameExpendedSize. height,
138143 width: Style . panelWidth,
139144 height: Style . panelHeight
140145 )
@@ -175,8 +180,10 @@ enum UpdateLocationStrategy {
175180 proposedAnchorFrameOnTheLeftSide = widgetFrameOnTheLeftSide
176181 }
177182
178- let proposedPanelX = proposedAnchorFrameOnTheLeftSide. minX - Style
179- . widgetPadding * 2 - Style. panelWidth
183+ let proposedPanelX = proposedAnchorFrameOnTheLeftSide. minX
184+ - Style. widgetPadding * 2
185+ - Style. panelWidth
186+ + editorFrameExpendedSize. width
180187 let putAnchorToTheLeft = {
181188 if editorFrame. size. width >= preferredInsideEditorMinWidth {
182189 if editorFrame. maxX <= activeScreen. frame. maxX {
@@ -190,9 +197,9 @@ enum UpdateLocationStrategy {
190197 let anchorFrame = proposedAnchorFrameOnTheLeftSide
191198 let panelFrame = CGRect (
192199 x: proposedPanelX,
193- y: alignPanelTopToAnchor ? anchorFrame . maxY - Style
194- . panelHeight : anchorFrame
195- . minY,
200+ y: alignPanelTopToAnchor
201+ ? anchorFrame . maxY - Style . panelHeight
202+ : anchorFrame . minY - editorFrameExpendedSize . height ,
196203 width: Style . panelWidth,
197204 height: Style . panelHeight
198205 )
@@ -217,9 +224,11 @@ enum UpdateLocationStrategy {
217224 let anchorFrame = proposedAnchorFrameOnTheRightSide
218225 let panelFrame = CGRect (
219226 x: anchorFrame. maxX - Style. panelWidth,
220- y: alignPanelTopToAnchor ? anchorFrame. maxY - Style. panelHeight - Style
221- . widgetHeight - Style. widgetPadding : anchorFrame. maxY + Style
222- . widgetPadding,
227+ y: alignPanelTopToAnchor
228+ ? anchorFrame. maxY - Style. panelHeight - Style. widgetHeight
229+ - Style. widgetPadding
230+ : anchorFrame. maxY + Style. widgetPadding
231+ - editorFrameExpendedSize. height,
223232 width: Style . panelWidth,
224233 height: Style . panelHeight
225234 )
@@ -393,9 +402,11 @@ enum UpdateLocationStrategy {
393402 var firstLineRange : CFRange = . init( )
394403 let foundFirstLine = AXValueGetValue ( selectedRange, . cfRange, & firstLineRange)
395404 firstLineRange. length = 0
396-
397- #warning("FIXME: When selection is too low and out of the screen, the selection range becomes something else.")
398-
405+
406+ #warning(
407+ " FIXME: When selection is too low and out of the screen, the selection range becomes something else. "
408+ )
409+
399410 if foundFirstLine,
400411 let firstLineSelectionRange = AXValueCreate ( . cfRange, & firstLineRange) ,
401412 let firstLineRect: AXValue = try ? editor. copyParameterizedValue (
@@ -413,3 +424,4 @@ enum UpdateLocationStrategy {
413424 return selectionFrame
414425 }
415426}
427+
0 commit comments