macOS: Move util::EMPTY_RANGE to usage spot (#3685)
This commit is contained in:
parent
0a3cacd577
commit
cb39ab29f4
2 changed files with 7 additions and 8 deletions
|
|
@ -1,8 +1,5 @@
|
||||||
use objc2_foundation::{NSNotFound, NSRange, NSUInteger};
|
|
||||||
use tracing::trace;
|
use tracing::trace;
|
||||||
|
|
||||||
pub static EMPTY_RANGE: NSRange = NSRange { location: NSNotFound as NSUInteger, length: 0 };
|
|
||||||
|
|
||||||
macro_rules! trace_scope {
|
macro_rules! trace_scope {
|
||||||
($s:literal) => {
|
($s:literal) => {
|
||||||
let _crate = $crate::platform_impl::platform::util::TraceGuard::new(module_path!(), $s);
|
let _crate = $crate::platform_impl::platform::util::TraceGuard::new(module_path!(), $s);
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,8 @@ use objc2_app_kit::{
|
||||||
};
|
};
|
||||||
use objc2_foundation::{
|
use objc2_foundation::{
|
||||||
MainThreadMarker, NSArray, NSAttributedString, NSAttributedStringKey, NSCopying,
|
MainThreadMarker, NSArray, NSAttributedString, NSAttributedStringKey, NSCopying,
|
||||||
NSMutableAttributedString, NSObject, NSObjectProtocol, NSPoint, NSRange, NSRect, NSSize,
|
NSMutableAttributedString, NSNotFound, NSObject, NSObjectProtocol, NSPoint, NSRange, NSRect,
|
||||||
NSString, NSUInteger,
|
NSSize, NSString, NSUInteger,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::app_delegate::ApplicationDelegate;
|
use super::app_delegate::ApplicationDelegate;
|
||||||
|
|
@ -25,7 +25,7 @@ use super::event::{
|
||||||
scancode_to_physicalkey,
|
scancode_to_physicalkey,
|
||||||
};
|
};
|
||||||
use super::window::WinitWindow;
|
use super::window::WinitWindow;
|
||||||
use super::{util, DEVICE_ID};
|
use super::DEVICE_ID;
|
||||||
use crate::dpi::{LogicalPosition, LogicalSize};
|
use crate::dpi::{LogicalPosition, LogicalSize};
|
||||||
use crate::event::{
|
use crate::event::{
|
||||||
DeviceEvent, ElementState, Ime, Modifiers, MouseButton, MouseScrollDelta, TouchPhase,
|
DeviceEvent, ElementState, Ime, Modifiers, MouseButton, MouseScrollDelta, TouchPhase,
|
||||||
|
|
@ -259,14 +259,16 @@ declare_class!(
|
||||||
if length > 0 {
|
if length > 0 {
|
||||||
NSRange::new(0, length)
|
NSRange::new(0, length)
|
||||||
} else {
|
} else {
|
||||||
util::EMPTY_RANGE
|
// Documented to return `{NSNotFound, 0}` if there is no marked range.
|
||||||
|
NSRange::new(NSNotFound as NSUInteger, 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[method(selectedRange)]
|
#[method(selectedRange)]
|
||||||
fn selected_range(&self) -> NSRange {
|
fn selected_range(&self) -> NSRange {
|
||||||
trace_scope!("selectedRange");
|
trace_scope!("selectedRange");
|
||||||
util::EMPTY_RANGE
|
// Documented to return `{NSNotFound, 0}` if there is no selection.
|
||||||
|
NSRange::new(NSNotFound as NSUInteger, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[method(setMarkedText:selectedRange:replacementRange:)]
|
#[method(setMarkedText:selectedRange:replacementRange:)]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue