diff options
| author | YAMAMOTO Mitsuharu | 2008-04-23 08:56:12 +0000 |
|---|---|---|
| committer | YAMAMOTO Mitsuharu | 2008-04-23 08:56:12 +0000 |
| commit | e1adb1392e09cf5b57b93671e77ef0b583b0d44e (patch) | |
| tree | 4badceaddeb5f8d786d11d4926c1cc653560eefe /src | |
| parent | 81fe843b5a3cc7708e0800aeb5bc0dbe448e800a (diff) | |
| download | emacs-e1adb1392e09cf5b57b93671e77ef0b583b0d44e.tar.gz emacs-e1adb1392e09cf5b57b93671e77ef0b583b0d44e.zip | |
(Vmac_ts_active_input_buf) [USE_MAC_TSM]: New variable.
(syms_of_macterm) [USE_MAC_TSM]: Defvar it.
(Qmouse_drag_overlay) [MAC_OSX]: New variable.
(syms_of_macterm) [MAC_OSX]: Intern and staticpro it.
(mac_get_selected_range, mac_store_buffer_text_to_unicode_chars)
(mac_ax_selected_text_range) [MAC_OSX]: New functions.
(mac_ax_number_of_characters) [MAC_OS_X_VERSION_MAX_ALLOWED >= 1030]:
Likewise.
Diffstat (limited to 'src')
| -rw-r--r-- | src/macterm.c | 143 |
1 files changed, 142 insertions, 1 deletions
diff --git a/src/macterm.c b/src/macterm.c index 2a8142938a9..1efa2667f15 100644 --- a/src/macterm.c +++ b/src/macterm.c | |||
| @@ -8154,7 +8154,7 @@ Lisp_Object Qtoolbar_switch_mode; | |||
| 8154 | #if USE_MAC_TSM | 8154 | #if USE_MAC_TSM |
| 8155 | Lisp_Object Qtext_input; | 8155 | Lisp_Object Qtext_input; |
| 8156 | Lisp_Object Qupdate_active_input_area, Qunicode_for_key_event; | 8156 | Lisp_Object Qupdate_active_input_area, Qunicode_for_key_event; |
| 8157 | Lisp_Object Vmac_ts_active_input_overlay; | 8157 | Lisp_Object Vmac_ts_active_input_overlay, Vmac_ts_active_input_buf; |
| 8158 | static Lisp_Object Vmac_ts_script_language_on_focus; | 8158 | static Lisp_Object Vmac_ts_script_language_on_focus; |
| 8159 | static Lisp_Object saved_ts_script_language_on_focus; | 8159 | static Lisp_Object saved_ts_script_language_on_focus; |
| 8160 | static ScriptLanguageRecord saved_ts_language; | 8160 | static ScriptLanguageRecord saved_ts_language; |
| @@ -8162,6 +8162,7 @@ static Component saved_ts_component; | |||
| 8162 | #endif | 8162 | #endif |
| 8163 | #ifdef MAC_OSX | 8163 | #ifdef MAC_OSX |
| 8164 | Lisp_Object Qservice, Qpaste, Qperform; | 8164 | Lisp_Object Qservice, Qpaste, Qperform; |
| 8165 | Lisp_Object Qmouse_drag_overlay; | ||
| 8165 | #endif | 8166 | #endif |
| 8166 | #endif /* TARGET_API_MAC_CARBON */ | 8167 | #endif /* TARGET_API_MAC_CARBON */ |
| 8167 | extern Lisp_Object Qundefined; | 8168 | extern Lisp_Object Qundefined; |
| @@ -8336,6 +8337,138 @@ mac_get_emulated_btn ( UInt32 modifiers ) | |||
| 8336 | return result; | 8337 | return result; |
| 8337 | } | 8338 | } |
| 8338 | 8339 | ||
| 8340 | #ifdef MAC_OSX | ||
| 8341 | void | ||
| 8342 | mac_get_selected_range (w, range) | ||
| 8343 | struct window *w; | ||
| 8344 | CFRange *range; | ||
| 8345 | { | ||
| 8346 | Lisp_Object overlay = find_symbol_value (Qmouse_drag_overlay); | ||
| 8347 | struct buffer *b = XBUFFER (w->buffer); | ||
| 8348 | int begv = BUF_BEGV (b), zv = BUF_ZV (b); | ||
| 8349 | int start, end; | ||
| 8350 | |||
| 8351 | if (OVERLAYP (overlay) | ||
| 8352 | && EQ (Foverlay_buffer (overlay), w->buffer) | ||
| 8353 | && (start = XINT (Foverlay_start (overlay)), | ||
| 8354 | end = XINT (Foverlay_end (overlay)), | ||
| 8355 | start != end)) | ||
| 8356 | ; | ||
| 8357 | else | ||
| 8358 | { | ||
| 8359 | if (w == XWINDOW (selected_window) && b == current_buffer) | ||
| 8360 | start = PT; | ||
| 8361 | else | ||
| 8362 | start = marker_position (w->pointm); | ||
| 8363 | |||
| 8364 | if (NILP (Vtransient_mark_mode) || NILP (b->mark_active)) | ||
| 8365 | end = start; | ||
| 8366 | else | ||
| 8367 | { | ||
| 8368 | int mark_pos = marker_position (b->mark); | ||
| 8369 | |||
| 8370 | if (start <= mark_pos) | ||
| 8371 | end = mark_pos; | ||
| 8372 | else | ||
| 8373 | { | ||
| 8374 | end = start; | ||
| 8375 | start = mark_pos; | ||
| 8376 | } | ||
| 8377 | } | ||
| 8378 | } | ||
| 8379 | |||
| 8380 | if (start != end) | ||
| 8381 | { | ||
| 8382 | if (start < begv) | ||
| 8383 | start = begv; | ||
| 8384 | else if (start > zv) | ||
| 8385 | start = zv; | ||
| 8386 | |||
| 8387 | if (end < begv) | ||
| 8388 | end = begv; | ||
| 8389 | else if (end > zv) | ||
| 8390 | end = zv; | ||
| 8391 | } | ||
| 8392 | |||
| 8393 | range->location = start - begv; | ||
| 8394 | range->length = end - start; | ||
| 8395 | } | ||
| 8396 | |||
| 8397 | /* Store the text of the buffer BUF from START to END as Unicode | ||
| 8398 | characters in CHARACTERS. Return non-zero if successful. */ | ||
| 8399 | |||
| 8400 | int | ||
| 8401 | mac_store_buffer_text_to_unicode_chars (buf, start, end, characters) | ||
| 8402 | struct buffer *buf; | ||
| 8403 | int start, end; | ||
| 8404 | UniChar *characters; | ||
| 8405 | { | ||
| 8406 | int start_byte, end_byte, char_count, byte_count; | ||
| 8407 | struct coding_system coding; | ||
| 8408 | unsigned char *dst = (unsigned char *) characters; | ||
| 8409 | |||
| 8410 | start_byte = buf_charpos_to_bytepos (buf, start); | ||
| 8411 | end_byte = buf_charpos_to_bytepos (buf, end); | ||
| 8412 | char_count = end - start; | ||
| 8413 | byte_count = end_byte - start_byte; | ||
| 8414 | |||
| 8415 | if (setup_coding_system ( | ||
| 8416 | #ifdef WORDS_BIG_ENDIAN | ||
| 8417 | intern ("utf-16be") | ||
| 8418 | #else | ||
| 8419 | intern ("utf-16le") | ||
| 8420 | #endif | ||
| 8421 | , &coding) < 0) | ||
| 8422 | return 0; | ||
| 8423 | |||
| 8424 | coding.src_multibyte = !NILP (buf->enable_multibyte_characters); | ||
| 8425 | coding.dst_multibyte = 0; | ||
| 8426 | coding.mode |= CODING_MODE_LAST_BLOCK; | ||
| 8427 | coding.composing = COMPOSITION_DISABLED; | ||
| 8428 | |||
| 8429 | if (BUF_GPT_BYTE (buf) <= start_byte || end_byte <= BUF_GPT_BYTE (buf)) | ||
| 8430 | encode_coding (&coding, BUF_BYTE_ADDRESS (buf, start_byte), dst, | ||
| 8431 | byte_count, char_count * sizeof (UniChar)); | ||
| 8432 | else | ||
| 8433 | { | ||
| 8434 | int first_byte_count = BUF_GPT_BYTE (buf) - start_byte; | ||
| 8435 | |||
| 8436 | encode_coding (&coding, BUF_BYTE_ADDRESS (buf, start_byte), dst, | ||
| 8437 | first_byte_count, char_count * sizeof (UniChar)); | ||
| 8438 | if (coding.result == CODING_FINISH_NORMAL) | ||
| 8439 | encode_coding (&coding, | ||
| 8440 | BUF_BYTE_ADDRESS (buf, start_byte + first_byte_count), | ||
| 8441 | dst + coding.produced, | ||
| 8442 | byte_count - first_byte_count, | ||
| 8443 | char_count * sizeof (UniChar) - coding.produced); | ||
| 8444 | } | ||
| 8445 | |||
| 8446 | if (coding.result != CODING_FINISH_NORMAL) | ||
| 8447 | return 0; | ||
| 8448 | |||
| 8449 | return 1; | ||
| 8450 | } | ||
| 8451 | |||
| 8452 | void | ||
| 8453 | mac_ax_selected_text_range (f, range) | ||
| 8454 | struct frame *f; | ||
| 8455 | CFRange *range; | ||
| 8456 | { | ||
| 8457 | mac_get_selected_range (XWINDOW (f->selected_window), range); | ||
| 8458 | } | ||
| 8459 | |||
| 8460 | #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030 | ||
| 8461 | unsigned int | ||
| 8462 | mac_ax_number_of_characters (f) | ||
| 8463 | struct frame *f; | ||
| 8464 | { | ||
| 8465 | struct buffer *b = XBUFFER (XWINDOW (f->selected_window)->buffer); | ||
| 8466 | |||
| 8467 | return BUF_ZV (b) - BUF_BEGV (b); | ||
| 8468 | } | ||
| 8469 | #endif | ||
| 8470 | #endif | ||
| 8471 | |||
| 8339 | #if USE_MAC_TSM | 8472 | #if USE_MAC_TSM |
| 8340 | OSStatus | 8473 | OSStatus |
| 8341 | mac_restore_keyboard_input_source () | 8474 | mac_restore_keyboard_input_source () |
| @@ -9377,6 +9510,9 @@ syms_of_macterm () | |||
| 9377 | Qservice = intern ("service"); staticpro (&Qservice); | 9510 | Qservice = intern ("service"); staticpro (&Qservice); |
| 9378 | Qpaste = intern ("paste"); staticpro (&Qpaste); | 9511 | Qpaste = intern ("paste"); staticpro (&Qpaste); |
| 9379 | Qperform = intern ("perform"); staticpro (&Qperform); | 9512 | Qperform = intern ("perform"); staticpro (&Qperform); |
| 9513 | |||
| 9514 | Qmouse_drag_overlay = intern ("mouse-drag-overlay"); | ||
| 9515 | staticpro (&Qmouse_drag_overlay); | ||
| 9380 | #endif | 9516 | #endif |
| 9381 | #if USE_MAC_TSM | 9517 | #if USE_MAC_TSM |
| 9382 | Qtext_input = intern ("text-input"); staticpro (&Qtext_input); | 9518 | Qtext_input = intern ("text-input"); staticpro (&Qtext_input); |
| @@ -9537,6 +9673,11 @@ CODING_SYSTEM is a coding system corresponding to TEXT-ENCODING. */); | |||
| 9537 | doc: /* Overlay used to display Mac TSM active input area. */); | 9673 | doc: /* Overlay used to display Mac TSM active input area. */); |
| 9538 | Vmac_ts_active_input_overlay = Qnil; | 9674 | Vmac_ts_active_input_overlay = Qnil; |
| 9539 | 9675 | ||
| 9676 | DEFVAR_LISP ("mac-ts-active-input-buf", &Vmac_ts_active_input_buf, | ||
| 9677 | doc: /* Byte sequence of the current Mac TSM active input area. */); | ||
| 9678 | /* `empty_string' is not ready yet on Mac OS Classic. */ | ||
| 9679 | Vmac_ts_active_input_buf = build_string (""); | ||
| 9680 | |||
| 9540 | DEFVAR_LISP ("mac-ts-script-language-on-focus", &Vmac_ts_script_language_on_focus, | 9681 | DEFVAR_LISP ("mac-ts-script-language-on-focus", &Vmac_ts_script_language_on_focus, |
| 9541 | doc: /* *How to change Mac TSM script/language when a frame gets focus. | 9682 | doc: /* *How to change Mac TSM script/language when a frame gets focus. |
| 9542 | If the value is t, the input script and language are restored to those | 9683 | If the value is t, the input script and language are restored to those |