# core/textinput (vanilla-engine 0.4.0)

> https://vanillapunch.com/docs/vanilla-engine/0.4.0/api/core/textinput/

글 입력 줄. (InputManager 가 든다)
- 원본에는 이런 층이 없다. 원본 UIInputField 는 DOM <input> 과 document keydown 에 직접 리스너를 단다.
  러스트 판은 플랫폼이 창 이벤트(데스크탑 winit 의 KeyboardInput / Ime, 웹 숨긴 <input> 의 input / composition / keydown)를
  여기 줄에 넣고, 포커스를 가진 입력 필드가 tick 에서 꺼내 쓴다. (ui/uiinputfield.rs)
- 컴포넌트는 &Engine 만 받는다. 그래서 필드가 쓰는 쪽(꺼내기, 상태 올리기)은 RefCell 로 &self 에서 되게 했다.
  플랫폼은 &Engine 을 쥐므로 넣는 쪽은 &mut self 다.
- 프레임 흐름:
  1. 플랫폼이 프레임 사이에 이벤트를 넣는다. (push_event)
  2. 씬 tick 에서 필드가 자기 몫을 꺼낸다. (take_events_for_field) 붙어 있는(attach) 필드와 포커스를 가진 필드는 상태를 올린다. (register_field_state)
  3. 프레임 끝에 엔진이 finish_frame 을 부른다. 남은 이벤트를 버리고, 올라온 상태를 "지난 프레임 상태"로 넘긴다.
  4. 플랫폼이 지난 프레임 상태를 읽어 적용한다. (데스크탑: IME 켜고 끄기와 후보 창 자리, 웹: 숨긴 <input> 자리, 값, 포커스)
- 글자 자리는 모두 문자(char) 단위다. 원본(자바스크립트 문자열)은 UTF-16 단위다. 한글은 둘이 같고, 이모지 같은 글자에서만 다르다.
  웹 플랫폼은 DOM 의 UTF-16 자리를 여기 함수로 바꿔 넣는다.

예제: 문자 자리와 바이트 자리, UTF-16 자리 바꾸기

```rust
use vanilla::core::textinput::{convert_byte_index_to_character_index, convert_character_index_to_byte_index, convert_character_index_to_utf16_index, convert_utf16_index_to_character_index, count_characters};

let text = "a\u{D55C}\u{1F600}b";
assert_eq!(count_characters(text), 4);
assert_eq!(convert_character_index_to_byte_index(text, 2), 4);
assert_eq!(convert_byte_index_to_character_index(text, 4), 2);
assert_eq!(convert_character_index_to_utf16_index(text, 3), 4);
assert_eq!(convert_utf16_index_to_character_index(text, 4), 3);
```

## TextInputEvent (struct) (Clone, Debug, PartialEq)

글 입력 이벤트. (받을 필드 + 내용)

예제: 포커스를 가진 필드에 확정 글 보내기

```rust
use vanilla::{TextInput, TextInputEvent, TextInputEventKind};

let mut text_input = TextInput::new();
text_input.push_event(TextInputEvent {
	target_field_id: 0,
	kind: TextInputEventKind::Commit(String::from("hello")),
});
assert_eq!(text_input.get_event_count(), 1);
```

- `pub target_field_id: u64` (field, since 0.3.2): 받을 필드 id. 0 이면 지금 포커스를 가진 필드. (데스크탑 키와 IME, 웹 캔버스 모드 키)
  - returns u64
- `pub kind: TextInputEventKind` (field, since 0.3.2): 이벤트 내용.
  - returns TextInputEventKind

## TextInputFieldState (struct) (Clone, Debug, PartialEq)

필드가 프레임마다 올리는 상태. (플랫폼이 IME 와 숨긴 <input> 을 맞출 때 읽는다)
- 자리는 창 안쪽 논리 좌표(웹은 캔버스 기준 CSS 픽셀)다.

예제: 필드 상태를 올리고 프레임 끝에 넘기기

```rust
use vanilla::{Rect, TextInput, TextInputFieldState};

let mut text_input = TextInput::new();
text_input.register_field_state(TextInputFieldState {
	field_id: 3,
	focus_serial: 1,
	is_focused: true,
	is_attached: true,
	use_dominput: true,
	use_touch_end_focus: false,
	use_direct_touch: false,
	is_visible: true,
	field_rect: Rect::create(10.0, 20.0, 200.0, 40.0),
	caret_rect: Rect::create(10.0, 20.0, 1.0, 40.0),
	value: String::from("abc"),
	selection_start: 0,
	cursor_index: 3,
	max_length: 0,
	value_revision: 0,
	is_multiline: false,
});
text_input.finish_frame();
assert_eq!(text_input.get_published_field_states().len(), 1);
assert_eq!(text_input.get_published_field_states()[0].value, "abc");
```

- `pub field_id: u64` (field, since 0.3.2): 필드 id. (UIInputField 가 만들 때 1 부터 매긴다)
  - returns u64
- `pub focus_serial: u64` (field, since 0.3.2): 포커스를 얻은 차례. (클수록 나중. 포커스가 없으면 0)
  - returns u64
- `pub is_focused: bool` (field, since 0.3.2): 포커스를 가졌는지.
  - returns bool
- `pub is_attached: bool` (field, since 0.3.2): attach() 로 입력을 받기로 했는지.
  - returns bool
- `pub use_dominput: bool` (field, since 0.3.2): 플랫폼 글 입력(IME, 시스템 키보드, 웹 숨긴 <input>)을 쓰는지. (원본 setUseDOMInput)
  - returns bool
- `pub use_touch_end_focus: bool` (field, since 0.3.2): 손을 뗄 때도 포커스를 줄지. (웹 DOM 입력 전용)
  - returns bool
- `pub use_direct_touch: bool` (field, since 0.3.2): DOM 입력을 필드 위에서 직접 누르게 할지. (웹 DOM 입력 전용)
  - returns bool
- `pub is_visible: bool` (field, since 0.3.2): 노드와 조상이 모두 보이는지.
  - returns bool
- `pub field_rect: Rect` (field, since 0.3.2): 필드 사각형.
  - returns Rect
- `pub caret_rect: Rect` (field, since 0.3.2): 커서 사각형. (필드 높이만큼의 세로 막대)
  - returns Rect
- `pub value: String` (field, since 0.3.2): 지금 값.
  - returns String
- `pub selection_start: usize` (field, since 0.3.2): 선택 시작 자리. (문자 단위, 선택을 늘릴 때 고정되는 쪽. cursor_index 와 같으면 선택 없음)
  - returns usize
- `pub cursor_index: usize` (field, since 0.3.2): 커서 자리. (문자 단위)
  - returns usize
- `pub max_length: usize` (field, since 0.3.2): 최대 길이. (UTF-16 단위, 0 이면 제한 없음)
  - returns usize
- `pub value_revision: u64` (field, since 0.3.2): 필드 쪽에서 값이나 커서를 바꿀 때마다 는다. (웹이 숨긴 <input> 에 다시 써야 하는지 볼 때)
  - returns u64
- `pub is_multiline: bool` (field, since 0.4.0): 여러 줄 필드인지. (웹은 숨긴 `<textarea>` 를 쓴다)
  - returns bool

## TextInput (struct) (Default)

글 입력 줄.
- InputManager 가 하나 든다. 플랫폼이 이벤트를 넣고, 입력 필드가 꺼내 쓰고, 엔진이 프레임 끝에 finish_frame 을 부른다.

예제: 넣고, 필드가 꺼내고, 프레임 끝에 남은 것을 버리기

```rust
use vanilla::{TextInput, TextInputEvent, TextInputEventKind};

let mut text_input = TextInput::new();
text_input.push_focused_field_event(TextInputEventKind::Commit(String::from("a")));
text_input.push_event(TextInputEvent {
	target_field_id: 7,
	kind: TextInputEventKind::FocusGained,
});
text_input.push_event(TextInputEvent {
	target_field_id: 9,
	kind: TextInputEventKind::FocusLost,
});
let taken_list = text_input.take_events_for_field(7, true);
assert_eq!(taken_list, vec![TextInputEventKind::Commit(String::from("a")), TextInputEventKind::FocusGained]);
assert_eq!(text_input.get_event_count(), 1);
text_input.finish_frame();
assert_eq!(text_input.get_event_count(), 0);
```

- `pub fn new() -> TextInput` (constructor, since 0.3.2): 생성.
  - returns TextInput: 이벤트도 필드 상태도 없는 빈 줄.
- `pub fn push_event(&mut self, event: TextInputEvent)` (method, since 0.3.2): 이벤트 넣기. (플랫폼)
  - `event` TextInputEvent: 넣을 이벤트. (target_field_id 가 0 이면 포커스를 가진 필드 몫)
- `pub fn push_focused_field_event(&mut self, kind: TextInputEventKind)` (method, since 0.3.2): 포커스를 가진 필드에 갈 이벤트 넣기. (플랫폼)
  - `kind` TextInputEventKind: 넣을 이벤트 내용. (target_field_id 0 으로 넣는다)
- `pub fn get_event_count(&self) -> usize` (method, since 0.3.2): 쌓인 이벤트 수.
  - returns usize: 아직 아무도 꺼내지 않은 이벤트 수.
- `pub fn take_events_for_field(&self, field_id: u64, accepts_focused_field_events: bool) -> Vec<TextInputEventKind>` (method, since 0.3.2): 필드 몫의 이벤트 꺼내기. (자기 id 로 온 것, 그리고 포커스 이벤트를 받을 수 있으면 0 으로 온 것)
  - 꺼낸 이벤트는 줄에서 빠진다. 포커스를 가진 필드가 둘이 되는 한 프레임 동안에도 같은 글이 두 번 들어가지 않는다.
  - `field_id` u64: 꺼낼 필드 id.
  - `accepts_focused_field_events` bool: true 면 target_field_id 가 0 인 이벤트(포커스를 가진 필드 몫)도 꺼낸다.
  - returns Vec<TextInputEventKind>: 꺼낸 이벤트 내용 목록. (넣은 차례대로, 없으면 빈 목록)

  예제: id 로 온 것과 포커스 몫 꺼내기

  ```rust
  use vanilla::{TextInput, TextInputEvent, TextInputEventKind};
  
  let mut text_input = TextInput::new();
  text_input.push_focused_field_event(TextInputEventKind::CompositionStart);
  text_input.push_event(TextInputEvent {
  	target_field_id: 5,
  	kind: TextInputEventKind::FocusGained,
  });
  assert!(text_input.take_events_for_field(3, false).is_empty());
  assert_eq!(text_input.take_events_for_field(5, false), vec![TextInputEventKind::FocusGained]);
  assert_eq!(text_input.take_events_for_field(3, true), vec![TextInputEventKind::CompositionStart]);
  ```

- `pub fn register_field_state(&self, field_state: TextInputFieldState)` (method, since 0.3.2): 필드 상태 올리기. (필드 tick, 같은 필드가 두 번 올리면 뒤의 것)
  - `field_state` TextInputFieldState: 올릴 상태. (finish_frame 뒤 get_published_field_states 로 보인다)
- `pub fn get_published_field_states(&self) -> &[TextInputFieldState]` (method, since 0.3.2): 지난 프레임에 올라온 필드 상태 목록. (올라온 순서 = 트리 순서)
  - returns &[TextInputFieldState]: 지난 프레임 상태 목록. (첫 finish_frame 전에는 비었다)
- `pub fn get_latest_focus_serial(&self) -> u64` (method, since 0.3.2): 지난 프레임에 가장 나중에 포커스를 얻은 필드의 포커스 차례. (없으면 0)
  - returns u64: 포커스를 가진 필드의 focus_serial 가운데 가장 큰 값. (없으면 0)
- `pub fn get_active_field_state(&self) -> Option<&TextInputFieldState>` (method, since 0.3.2): 글 입력을 받는 필드 상태. (지난 프레임에 포커스를 가진, 붙어 있는 필드 가운데 가장 나중 것)
  - returns Option<&TextInputFieldState>: 그 필드 상태. 포커스를 가지고 붙어 있는(is_attached) 필드가 없으면 None.

  예제: 포커스를 가진 붙은 필드 가운데 나중 것

  ```rust
  use vanilla::{Rect, TextInput, TextInputFieldState};
  
  fn create_field_state(field_id: u64, focus_serial: u64) -> TextInputFieldState {
  	TextInputFieldState {
  		field_id,
  		focus_serial,
  		is_focused: true,
  		is_attached: true,
  		use_dominput: true,
  		use_touch_end_focus: false,
  		use_direct_touch: false,
  		is_visible: true,
  		field_rect: Rect::zero(),
  		caret_rect: Rect::zero(),
  		value: String::new(),
  		selection_start: 0,
  		cursor_index: 0,
  		max_length: 0,
  		value_revision: 0,
  		is_multiline: false,
  	}
  }
  
  let mut text_input = TextInput::new();
  text_input.register_field_state(create_field_state(1, 4));
  text_input.register_field_state(create_field_state(2, 6));
  assert!(text_input.get_active_field_state().is_none());
  text_input.finish_frame();
  assert_eq!(text_input.get_active_field_state().map(|field_state| field_state.field_id), Some(2));
  assert_eq!(text_input.get_latest_focus_serial(), 6);
  ```

- `pub fn set_context_menu_request_position(&mut self, view_position: Option<Vector2>)` (method, since 0.3.2): 문맥 메뉴 요청 자리 설정. (데스크탑 오른쪽 단추, 웹 필드 위의 오른쪽 클릭, 뷰 좌표. 이번 프레임에만 남는다)
  - `view_position` Option<Vector2>: 요청 자리. (뷰 좌표, None 이면 요청 없음. finish_frame 이 None 으로 돌린다)
- `pub fn get_context_menu_request_position(&self) -> Option<Vector2>` (method, since 0.3.2): 문맥 메뉴 요청 자리.
  - returns Option<Vector2>: 이번 프레임의 요청 자리. (뷰 좌표, 요청이 없으면 None)
- `pub fn set_ime_commit_guard(&self, committed_text: &str)` (method, since 0.3.2): 포커스를 잃으며 필드가 스스로 확정한 조합 글 기록. (필드)
  - 데스크탑에서 IME 를 끄면 OS 가 같은 조합 글을 Commit 으로 한 번 더 보낼 수 있다. 플랫폼이 그것을 버리게 한다.
  - `committed_text` &str: 필드가 확정한 글. (finish_frame 을 두 번 지나면 기록이 사라진다)
- `pub fn consume_ime_commit_guard(&mut self, committed_text: &str) -> bool` (method, since 0.3.2): IME 확정 글이 필드가 이미 확정한 글이면 true 를 돌려주고 기록을 지운다. (플랫폼)
  - `committed_text` &str: IME 가 보낸 확정 글.
  - returns bool: 기록된 글과 같으면 true. (기록이 없거나 다르면 false, 기록은 그대로 둔다)

  예제: 같은 확정 글을 한 번만 막기

  ```rust
  use vanilla::TextInput;
  
  let mut text_input = TextInput::new();
  text_input.set_ime_commit_guard("abc");
  assert!(!text_input.consume_ime_commit_guard("xyz"));
  assert!(text_input.consume_ime_commit_guard("abc"));
  assert!(!text_input.consume_ime_commit_guard("abc"));
  ```

- `pub fn set_pointer_click_count(&self, pointer_click_count: u32)` (method, since 0.4.0): 마우스 누름 수 넣기. (웹 플랫폼이 mousedown 의 detail 을 넣는다, 0 이면 1)
  - `pointer_click_count` u32: 누름 수. (mousedown 의 detail, 두 번 누름이면 2, 0 이면 1)
- `pub fn get_pointer_click_count(&self) -> u32` (method, since 0.4.0): 마지막 마우스 누름 수. (넣은 적이 없으면 1)
  - returns u32: 마지막 누름 수. (1 이상, 넣은 적이 없으면 1)
- `pub fn request_ime_reset(&self)` (method, since 0.3.2): IME 조합 끊기 부탁. (필드가 조합 글을 스스로 확정했을 때. 데스크탑 플랫폼이 IME 를 껐다 켠다)
- `pub fn take_ime_reset_request(&self) -> bool` (method, since 0.3.2): IME 조합 끊기 부탁 꺼내기. (플랫폼, 꺼내면 지워진다)
  - returns bool: request_ime_reset 이 불렸으면 true.
- `pub fn finish_frame(&mut self)` (method, since 0.3.2): 프레임 마무리. (엔진이 프레임 끝에 부른다)
  - 아무도 꺼내지 않은 이벤트를 버리고, 이번 프레임에 올라온 상태를 지난 프레임 상태로 넘긴다.

## Functions and constants

- `pub fn count_characters(text: &str) -> usize` (method, since 0.3.2): 문자 수.
  - `text` &str: 셀 글.
  - returns usize: char 수. (바이트 수가 아니다)
- `pub fn convert_character_index_to_byte_index(text: &str, character_index: usize) -> usize` (method, since 0.3.2): 문자 자리 → 바이트 자리. (넘으면 끝)
  - `text` &str: 글.
  - `character_index` usize: 문자 자리.
  - returns usize: 그 문자가 시작하는 바이트 자리. (글 문자 수 이상이면 text.len())
- `pub fn convert_byte_index_to_character_index(text: &str, byte_index: usize) -> usize` (method, since 0.3.2): 바이트 자리 → 문자 자리. (winit Ime::Preedit 의 커서가 바이트 단위다)
  - `text` &str: 글.
  - `byte_index` usize: 바이트 자리.
  - returns usize: byte_index 앞에서 시작하는 문자 수. (글자 가운데 바이트면 그 글자 뒤 자리)
- `pub fn convert_utf16_index_to_character_index(text: &str, utf16_index: usize) -> usize` (method, since 0.3.2): UTF-16 자리 → 문자 자리. (DOM selection_start / selection_end)
  - `text` &str: 글.
  - `utf16_index` usize: UTF-16 자리.
  - returns usize: 문자 자리. (서로게이트 쌍 가운데면 그 글자 뒤 자리, 넘으면 문자 수)

  예제: 이모지는 UTF-16 두 칸

  ```rust
  use vanilla::core::textinput::convert_utf16_index_to_character_index;
  
  let text = "a\u{1F600}b";
  assert_eq!(convert_utf16_index_to_character_index(text, 1), 1);
  assert_eq!(convert_utf16_index_to_character_index(text, 2), 2);
  assert_eq!(convert_utf16_index_to_character_index(text, 3), 2);
  assert_eq!(convert_utf16_index_to_character_index(text, 99), 3);
  ```

- `pub fn convert_character_index_to_utf16_index(text: &str, character_index: usize) -> usize` (method, since 0.3.2): 문자 자리 → UTF-16 자리. (DOM setSelectionRange)
  - `text` &str: 글.
  - `character_index` usize: 문자 자리. (문자 수를 넘으면 끝으로 본다)
  - returns usize: UTF-16 자리.
- `pub fn find_previous_grapheme_boundary(text: &str, character_index: usize) -> usize` (method, since 0.4.0): 앞 글자 묶음 경계. (크롬 왼쪽 화살표의 PositionMoveType::kGraphemeCluster, 확장 자소 묶음 UAX #29)
  - `text` &str: 글.
  - `character_index` usize: 문자 자리.
  - returns usize: 자리보다 앞인 가장 가까운 경계의 문자 자리. (0 이면 0, 묶음 가운데면 그 묶음 앞)
- `pub fn find_next_grapheme_boundary(text: &str, character_index: usize) -> usize` (method, since 0.4.0): 뒤 글자 묶음 경계. (크롬 오른쪽 화살표와 Delete 키의 PositionMoveType::kGraphemeCluster)
  - `text` &str: 글.
  - `character_index` usize: 문자 자리.
  - returns usize: 자리보다 뒤인 가장 가까운 경계의 문자 자리. (글 끝이면 문자 수)
- `pub fn collect_grapheme_boundaries(text: &str) -> Vec<usize>` (method, since 0.4.0): 글자 묶음 경계 목록. (0 과 문자 수를 넣는다, 오름차순)
  - `text` &str: 나눌 글.
  - returns Vec<usize>: 글자 묶음 경계의 문자 자리 목록. (0 과 문자 수를 넣는다, 오름차순)
- `pub fn find_backward_deletion_boundary(text: &str, character_index: usize) -> usize` (method, since 0.4.0): 뒤로 지우기(Backspace)로 지울 범위의 앞. (블링크 BackspaceStateMachine 을 옮긴 것)
  - 크롬은 뒤로 지우기를 글자 묶음이 아니라 코드 포인트 하나씩 지운다. 다만 CR LF, 이모지 표현 선택자(VS)와 그 바탕,
    피부색 조정자와 그 바탕, ZWJ 로 이은 이모지, 국기(지역 표시 글자 둘), 키캡, 태그 묶음은 통째로 지운다.
  - 블링크의 그림 문자(IsExtendedPictographicGb11)는 Extended_Pictographic 이나 Emoji 다.
  - VS 앞 글자의 결합 등급(canonical combining class)이 0 인지는 원본(브라우저는 알려 주지 않는다)과 같게 결합 부호(일반 범주 M)가 아닌지로 본다.
  - `text` &str: 글.
  - `character_index` usize: 커서의 문자 자리.
  - returns usize: 지울 범위 앞의 문자 자리.
- `pub fn collect_word_boundaries(text: &str) -> Vec<usize>` (method, since 0.4.0): 낱말 경계 목록. (크롬 낱말 나누기와 같게)
  - ICU 낱말 나누기(segment_words)에 크로미엄 ICU 의 wordbrk.patch 규칙을 더한다. 크롬은 마침표(U+002E, U+FF0E)를 숫자 사이에서만 잇고, 쌍점(U+003A, U+FE55, U+FF1A)은 잇지 않는다.
    (웹의 크롬 Intl.Segmenter 는 이미 그렇다)
  - `text` &str: 글.
  - returns Vec<usize>: 낱말 경계의 문자 자리 목록. (0 과 문자 수를 넣는다, 오름차순)

  예제: 주소는 마침표에서 나뉘고 소수는 한 낱말이다

  ```rust
  use vanilla::core::textinput::collect_word_boundaries;
  
  assert_eq!(collect_word_boundaries("www.example.com 3.14"), vec![0, 3, 4, 11, 12, 15, 16, 20]);
  ```

- `pub fn find_next_word_position(text: &str, character_index: usize, is_skip_spaces: bool) -> usize` (method, since 0.4.0): 다음 낱말 자리. (크롬 오른쪽 낱말 이동과 앞으로 낱말 지우기, 블링크 NextWordPosition)
  - 맥과 리눅스는 지금 낱말의 끝("abc| def|"), 윈도우는 뒤 공백을 건너뛴 다음 낱말 앞("abc |def")이다. (editing_behavior.h 의 ShouldSkipSpaceWhenMovingRight)
  - 줄 끝에서는 다음 줄 앞으로 간다. 글 끝이면 문자 수다.
  - `text` &str: 글.
  - `character_index` usize: 커서의 문자 자리.
  - `is_skip_spaces` bool: 뒤 공백을 건너뛸지. (윈도우면 true)
  - returns usize: 다음 낱말의 문자 자리.

  예제: 맥, 리눅스와 윈도우의 오른쪽 낱말 이동

  ```rust
  use vanilla::core::textinput::find_next_word_position;
  
  assert_eq!(find_next_word_position("abc def", 0, false), 3);
  assert_eq!(find_next_word_position("abc def", 0, true), 4);
  ```

- `pub fn find_previous_word_position(text: &str, character_index: usize) -> usize` (method, since 0.4.0): 앞 낱말 자리. (크롬 왼쪽 낱말 이동과 뒤로 낱말 지우기, 블링크 PreviousWordPosition, 모든 플랫폼에서 낱말 앞 "|abc |def")
  - 크롬 textarea 처럼 글자가 있는 줄의 앞에서는 앞 줄로 넘어가지 않는다. 글 앞이면 0 이다.
  - `text` &str: 글.
  - `character_index` usize: 커서의 문자 자리.
  - returns usize: 앞 낱말의 문자 자리.

  예제: 왼쪽 낱말 이동

  ```rust
  use vanilla::core::textinput::find_previous_word_position;
  
  assert_eq!(find_previous_word_position("abc def", 7), 4);
  assert_eq!(find_previous_word_position("ab\ncd", 3), 3);
  ```

## TextInputKey (enum) (Clone, Copy, Debug, PartialEq, Eq)

편집 키. (원본 handleCanvasKeydown 이 보는 키)

- `Backspace`: 커서 앞 글자 지우기. (선택이 있으면 선택을 지운다)
- `Delete`: 커서 뒤 글자 지우기. (선택이 있으면 선택을 지운다)
- `Left`: 커서를 한 글자 왼쪽으로. (is_shift 면 선택을 늘린다)
- `Right`: 커서를 한 글자 오른쪽으로. (is_shift 면 선택을 늘린다)
- `WordLeft`: 커서를 앞 낱말 앞으로. (윈도우와 리눅스 Ctrl + 왼쪽, 맥 Option + 왼쪽, is_shift 면 선택을 늘린다. 블링크 MoveWordLeft)
- `WordRight`: 커서를 낱말 하나 오른쪽으로. (윈도우와 리눅스 Ctrl + 오른쪽, 맥 Option + 오른쪽, is_shift 면 선택을 늘린다. 블링크 MoveWordRight)
- `DeleteWordBackward`: 커서 앞 낱말 지우기. (윈도우와 리눅스 Ctrl + Backspace, 맥 Option + Backspace, 선택이 있으면 선택을 지운다. 블링크 DeleteWordBackward)
- `DeleteWordForward`: 커서 뒤 낱말 지우기. (윈도우와 리눅스 Ctrl + Delete, 맥 Option + Delete, 선택이 있으면 선택을 지운다. 블링크 DeleteWordForward)
- `Home`: 줄 앞. (여러 줄 필드는 보이는 줄의 앞, 한 줄 필드는 글 앞. 맥은 Cmd + 왼쪽도, is_shift 면 선택을 늘린다)
- `End`: 줄 끝. (여러 줄 필드는 보이는 줄의 끝, 한 줄 필드는 글 끝. 맥은 Cmd + 오른쪽도, is_shift 면 선택을 늘린다)
- `Up`: 위 줄. (여러 줄 필드, 한 줄 DOM 입력 칸은 글 앞)
- `Down`: 아래 줄. (여러 줄 필드, 한 줄 DOM 입력 칸은 글 끝)
- `PageUp`: 한 화면만큼 위. (여러 줄 필드, 맥은 Option 과 함께)
- `PageDown`: 한 화면만큼 아래. (여러 줄 필드, 맥은 Option 과 함께)
- `DocumentStart`: 글 앞. (Ctrl + Home, 맥은 Cmd + 위)
- `DocumentEnd`: 글 끝. (Ctrl + End, 맥은 Cmd + 아래)
- `ScrollToDocumentStart`: 맥 Home, End. (맥 키 묶음의 scrollToBeginningOfDocument, scrollToEndOfDocument)
- 크롬 맥은 커서를 두고 넘길 수 있는 상자를 처음과 끝으로 넘기고, 넘길 것이 없으면 블링크 키 표대로 줄 앞과 끝으로 옮긴다.
- Shift 와 함께면(is_shift) 키 묶음의 moveToBeginningOfDocumentAndModifySelection 처럼 글 앞과 끝까지 고른다.
- `ScrollToDocumentEnd`: 맥 End. (ScrollToDocumentStart 의 끝 쪽, 맥 키 묶음의 scrollToEndOfDocument)
- `ScrollPageUp`: 맥 PageUp, PageDown. (맥 키 묶음의 scrollPageUp, scrollPageDown, 크롬 맥은 커서를 두고 한 화면만큼 넘긴다)
- `ScrollPageDown`: 맥 PageDown. (ScrollPageUp 의 아래 쪽, 맥 키 묶음의 scrollPageDown)
- `Enter`: 엔터. (한 줄 필드는 제출 이벤트를 내고, 여러 줄 필드는 줄을 넣는다)
- `Tab`: 원본 캔버스 모드처럼 필드는 쓰지 않는다. (게임이 다음 칸으로 옮길 때 보라고 넘긴다)
- `SelectAll`: Ctrl(맥은 Cmd) + A
- `Copy`: Ctrl(맥은 Cmd) + C
- `Cut`: Ctrl(맥은 Cmd) + X
- `Paste`: Ctrl(맥은 Cmd) + V
- `Undo`: 되돌리기. (Ctrl(맥은 Cmd) + Z, 윈도우는 Alt + Backspace 도. 원본 DOM 입력 칸의 브라우저 실행 취소)
- `Redo`: 다시 하기. (Ctrl(맥은 Cmd) + Shift + Z, 윈도우와 리눅스는 Ctrl + Y, 윈도우는 Alt + Shift + Backspace 도)

## TextInputEventKind (enum) (Clone, Debug, PartialEq)

글 입력 이벤트 내용.

- `Commit` = `Commit(String)`: 확정된 글. (IME 확정, 키로 친 글자)
- `CompositionStart`: 조합 시작. (원본 compositionstart)
- `Preedit` = `Preedit{ text: String, cursor_index: Option<usize>, }`: 조합 중인 글. 커서는 조합 글 안의 문자 자리. (원본 compositionupdate, winit Ime::Preedit)
- `CompositionEnd`: 조합 끝. (원본 compositionend)
- `Key` = `Key{ key: TextInputKey, is_shift: bool, }`: 편집 키.
- `Paste` = `Paste(String)`: 붙여 넣을 글. (웹에서 클립보드를 비동기로 읽은 뒤)
- `ReplaceValue` = `ReplaceValue{ value: String, selection_start: usize, selection_end: usize, }`: 숨긴 <input> 의 값이 바뀜. (웹, 원본 handleDOMInputEvent)
- `Selection` = `Selection{ start: usize, end: usize, }`: 숨긴 <input> 의 선택이 바뀜. (웹, 원본 tick 의 selection 폴링)
- `FocusGained`: 숨긴 <input> 이 포커스를 얻음. (웹, 원본 input focus 이벤트)
- `FocusLost`: 숨긴 <input> 이 포커스를 잃음. (웹, 원본 input blur 이벤트)
