@@ -85,7 +85,7 @@ pub extern "C" fn marked_range(this: &mut Object, _: Sel) -> NSRange {
8585
8686pub extern "C" fn selected_range ( this : & mut Object , _: Sel ) -> NSRange {
8787 with_edit_lock_from_window ( this, false , |mut edit_lock| {
88- let range = edit_lock. selection ( ) . to_range ( ) ;
88+ let range = edit_lock. selection ( ) . range ( ) ;
8989 encode_nsrange ( & mut edit_lock, range)
9090 } )
9191 . unwrap_or ( NSRange :: NONE )
@@ -105,7 +105,7 @@ pub extern "C" fn set_marked_text(
105105 // https://github.com/yvt/Stella2/blob/076fb6ee2294fcd1c56ed04dd2f4644bf456e947/tcw3/pal/src/macos/window.rs#L1144-L1146
106106 decode_nsrange ( & * edit_lock, & replacement_range, 0 ) . unwrap_or_else ( || {
107107 // no replacement range either? apparently we default to the selection in this case
108- edit_lock. selection ( ) . to_range ( )
108+ edit_lock. selection ( ) . range ( )
109109 } )
110110 } ) ;
111111
@@ -141,15 +141,9 @@ pub extern "C" fn set_marked_text(
141141 // preserve ordering of anchor and active
142142 let existing_selection = edit_lock. selection ( ) ;
143143 let new_selection = if existing_selection. anchor < existing_selection. active {
144- Selection {
145- anchor : selection_range. start ,
146- active : selection_range. end ,
147- }
144+ Selection :: new ( selection_range. start , selection_range. end )
148145 } else {
149- Selection {
150- active : selection_range. start ,
151- anchor : selection_range. end ,
152- }
146+ Selection :: new ( selection_range. end , selection_range. start )
153147 } ;
154148 edit_lock. set_selection ( new_selection) ;
155149 }
@@ -206,13 +200,13 @@ pub extern "C" fn insert_text(this: &mut Object, _: Sel, text: id, replacement_r
206200 // https://github.com/yvt/Stella2/blob/076fb6ee2294fcd1c56ed04dd2f4644bf456e947/tcw3/pal/src/macos/window.rs#L1041-L1043
207201 let converted_range = decode_nsrange ( & * edit_lock, & replacement_range, 0 )
208202 . or_else ( || edit_lock. composition_range ( ) )
209- . unwrap_or_else ( || edit_lock. selection ( ) . to_range ( ) ) ;
203+ . unwrap_or_else ( || edit_lock. selection ( ) . range ( ) ) ;
210204
211205 edit_lock. replace_range ( converted_range. clone ( ) , text_string) ;
212206 edit_lock. set_composition_range ( None ) ;
213207 // move the caret next to the inserted text
214208 let caret_index = converted_range. start + text_string. len ( ) ;
215- edit_lock. set_selection ( Selection :: new_caret ( caret_index) ) ;
209+ edit_lock. set_selection ( Selection :: caret ( caret_index) ) ;
216210 } ) ;
217211}
218212
@@ -385,7 +379,7 @@ fn do_command_by_selector_impl(mut edit_lock: Box<dyn InputHandler>, cmd: Sel) {
385379 // textedit testing showed that this operation never fully inverts a selection; if this action
386380 // would cause a selection's active and anchor to swap order, it makes a caret instead. applying
387381 // the operation a second time (on the selection that is now a caret) is required to invert.
388- edit_lock. set_selection ( Selection :: new_caret ( selection. anchor ) ) ;
382+ edit_lock. set_selection ( Selection :: caret ( selection. anchor ) ) ;
389383 }
390384 }
391385 "moveParagraphForwardAndModifySelection:" => {
@@ -399,7 +393,7 @@ fn do_command_by_selector_impl(mut edit_lock: Box<dyn InputHandler>, cmd: Sel) {
399393 // textedit testing showed that this operation never fully inverts a selection; if this action
400394 // would cause a selection's active and anchor to swap order, it makes a caret instead. applying
401395 // the operation a second time (on the selection that is now a caret) is required to invert.
402- edit_lock. set_selection ( Selection :: new_caret ( selection. anchor ) ) ;
396+ edit_lock. set_selection ( Selection :: caret ( selection. anchor ) ) ;
403397 }
404398 }
405399 "moveRight:" => edit_lock. handle_action ( Action :: Move ( Movement :: Grapheme ( Direction :: Right ) ) ) ,
@@ -531,7 +525,7 @@ fn do_command_by_selector_impl(mut edit_lock: Box<dyn InputHandler>, cmd: Sel) {
531525 edit_lock. handle_action ( Action :: MoveSelecting ( Movement :: Grapheme (
532526 Direction :: Downstream ,
533527 ) ) ) ;
534- let new_selection = edit_lock. selection ( ) . to_range ( ) ;
528+ let new_selection = edit_lock. selection ( ) . range ( ) ;
535529 let next_grapheme = edit_lock. slice ( new_selection. clone ( ) ) ;
536530 let next_char = next_grapheme. chars ( ) . next ( ) ;
537531
@@ -545,7 +539,7 @@ fn do_command_by_selector_impl(mut edit_lock: Box<dyn InputHandler>, cmd: Sel) {
545539 edit_lock. set_selection ( old_selection) ;
546540 } else {
547541 // normally, end of transpose range will be next grapheme
548- edit_lock. set_selection ( Selection :: new_caret ( new_selection. end ) ) ;
542+ edit_lock. set_selection ( Selection :: caret ( new_selection. end ) ) ;
549543 }
550544 }
551545
@@ -562,7 +556,7 @@ fn do_command_by_selector_impl(mut edit_lock: Box<dyn InputHandler>, cmd: Sel) {
562556 let second_grapheme = edit_lock. slice ( middle_idx..selection. max ( ) ) ;
563557 let new_string = format ! ( "{}{}" , second_grapheme, first_grapheme) ;
564558 // replace_range should automatically set selection to end of inserted range
565- edit_lock. replace_range ( selection. to_range ( ) , & new_string) ;
559+ edit_lock. replace_range ( selection. range ( ) , & new_string) ;
566560 }
567561 "capitalizeWord:" => {
568562 // this command expands the selection to words, and then applies titlecase to that selection
0 commit comments