mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-02-16 17:24:23 +00:00
* configure.ac (HAVE_TEXT_CONVERSION): Define on Android. * doc/emacs/input.texi (On-Screen Keyboards): Document ``text conversion'' slightly. * doc/lispref/commands.texi (Misc Events): Document new `text-conversion' event. * java/org/gnu/emacs/EmacsContextMenu.java (display): Use `syncRunnable'. * java/org/gnu/emacs/EmacsDialog.java (display): Likewise. * java/org/gnu/emacs/EmacsEditable.java: Delete file. * java/org/gnu/emacs/EmacsInputConnection.java (EmacsInputConnection): Reimplement from scratch. * java/org/gnu/emacs/EmacsNative.java (EmacsNative): Add new functions. * java/org/gnu/emacs/EmacsService.java (EmacsService, getEmacsView) (getLocationOnScreen, sync, getClipboardManager, restartEmacs): Use syncRunnable. (syncRunnable): New function. (updateIC, resetIC): New functions. * java/org/gnu/emacs/EmacsView.java (EmacsView): New field `inputConnection' and `icMode'. (onCreateInputConnection): Update accordingly. (setICMode, getICMode): New functions. * lisp/bindings.el (global-map): Ignore text conversion events. * src/alloc.c (mark_frame): Mark text conversion data. * src/android.c (struct android_emacs_service): New fields `update_ic' and `reset_ic'. (event_serial): Export. (android_query_sem): New function. (android_init_events): Initialize new semaphore. (android_write_event): Export. (android_select): Check for UI thread code. (setEmacsParams, android_init_emacs_service): Initialize new methods. (android_check_query, android_begin_query, android_end_query) (android_run_in_emacs_thread): (android_update_ic, android_reset_ic): New functions for managing synchronous queries from one thread to another. * src/android.h: Export new functions. * src/androidgui.h (enum android_event_type): Add input method events. (enum android_ime_operation, struct android_ime_event) (union android_event, enum android_ic_mode): New structs and enums. * src/androidterm.c (android_window_to_frame): Allow DPYINFO to be NULL. (android_decode_utf16, android_handle_ime_event) (handle_one_android_event, android_sync_edit) (android_copy_java_string, beginBatchEdit, endBatchEdit) (commitCompletion, deleteSurroundingText, finishComposingText) (getSelectedtext, getTextAfterCursor, getTextBeforeCursor) (setComposingText, setComposingRegion, setSelection, getSelection) (performEditorAction, getExtractedText): New functions. (struct android_conversion_query_context): (android_perform_conversion_query): (android_text_to_string): (struct android_get_selection_context): (android_get_selection): (struct android_get_extracted_text_context): (android_get_extracted_text): (struct android_extracted_text_request_class): (struct android_extracted_text_class): (android_update_selection): (android_reset_conversion): (android_set_point): (android_compose_region_changed): (android_notify_conversion): (text_conversion_interface): New functions and structures. (android_term_init): Initialize text conversion. * src/coding.c (syms_of_coding): Define Qutf_16le on Android. * src/frame.c (make_frame): Clear conversion data. (delete_frame): Reset conversion state. * src/frame.h (enum text_conversion_operation) (struct text_conversion_action, struct text_conversion_state) (GCALIGNED_STRUCT): Update structures. * src/keyboard.c (read_char, readable_events, kbd_buffer_get_event) (syms_of_keyboard): Handle text conversion events. * src/lisp.h: * src/process.c: Fix includes. * src/textconv.c (enum textconv_batch_edit_flags, textconv_query) (reset_frame_state, detect_conversion_events) (restore_selected_window, really_commit_text) (really_finish_composing_text, really_set_composing_text) (really_set_composing_region, really_delete_surrounding_text) (really_set_point, complete_edit) (handle_pending_conversion_events_1) (handle_pending_conversion_events, start_batch_edit) (end_batch_edit, commit_text, finish_composing_text) (set_composing_text, set_composing_region, textconv_set_point) (delete_surrounding_text, get_extracted_text) (report_selected_window_change, report_point_change) (register_texconv_interface): New functions. * src/textconv.h (struct textconv_interface) (TEXTCONV_SKIP_CONVERSION_REGION): Update prototype. * src/xdisp.c (mark_window_display_accurate_1): * src/xfns.c (xic_string_conversion_callback): * src/xterm.c (init_xterm): Adjust accordingly.
138 lines
4.1 KiB
C
138 lines
4.1 KiB
C
/* Android initialization for GNU Emacs.
|
||
|
||
Copyright (C) 2023 Free Software Foundation, Inc.
|
||
|
||
This file is part of GNU Emacs.
|
||
|
||
GNU Emacs is free software: you can redistribute it and/or modify
|
||
it under the terms of the GNU General Public License as published by
|
||
the Free Software Foundation, either version 3 of the License, or (at
|
||
your option) any later version.
|
||
|
||
GNU Emacs is distributed in the hope that it will be useful,
|
||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
GNU General Public License for more details.
|
||
|
||
You should have received a copy of the GNU General Public License
|
||
along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
|
||
|
||
/* On Android, Emacs is built as a shared library loaded from Java
|
||
using the Java Native Interface. Emacs's `main' function is
|
||
renamed `android_emacs_init', and runs with some modifications
|
||
inside a separate thread, communicating with the Java code through
|
||
a table of function pointers. */
|
||
|
||
#ifndef _ANDROID_H_
|
||
#ifndef ANDROID_STUBIFY
|
||
#include <jni.h>
|
||
#include <pwd.h>
|
||
|
||
#include <sys/stat.h>
|
||
#include <dirent.h>
|
||
#include <stdio.h>
|
||
|
||
#include <android/bitmap.h>
|
||
|
||
#include "androidgui.h"
|
||
#include "lisp.h"
|
||
#endif
|
||
|
||
extern bool android_init_gui;
|
||
|
||
#ifndef ANDROID_STUBIFY
|
||
|
||
extern int android_emacs_init (int, char **, char *);
|
||
extern int android_select (int, fd_set *, fd_set *, fd_set *,
|
||
struct timespec *);
|
||
|
||
extern int android_open (const char *, int, int);
|
||
extern char *android_user_full_name (struct passwd *);
|
||
extern int android_fstat (int, struct stat *);
|
||
extern int android_fstatat (int, const char *restrict,
|
||
struct stat *restrict, int);
|
||
extern int android_faccessat (int, const char *, int, int);
|
||
extern int android_close (int);
|
||
extern int android_fclose (FILE *);
|
||
extern const char *android_get_home_directory (void);
|
||
|
||
extern double android_pixel_density_x, android_pixel_density_y;
|
||
|
||
enum android_handle_type
|
||
{
|
||
ANDROID_HANDLE_WINDOW,
|
||
ANDROID_HANDLE_GCONTEXT,
|
||
ANDROID_HANDLE_PIXMAP,
|
||
};
|
||
|
||
extern jobject android_resolve_handle (android_handle,
|
||
enum android_handle_type);
|
||
extern unsigned char *android_lock_bitmap (android_window,
|
||
AndroidBitmapInfo *,
|
||
jobject *);
|
||
extern void android_damage_window (android_window,
|
||
struct android_rectangle *);
|
||
extern int android_get_screen_width (void);
|
||
extern int android_get_screen_height (void);
|
||
extern int android_get_mm_width (void);
|
||
extern int android_get_mm_height (void);
|
||
extern bool android_detect_mouse (void);
|
||
|
||
extern void android_set_dont_focus_on_map (android_window, bool);
|
||
extern void android_set_dont_accept_focus (android_window, bool);
|
||
|
||
extern jstring android_build_string (Lisp_Object);
|
||
extern jstring android_build_jstring (const char *);
|
||
extern void android_exception_check (void);
|
||
|
||
extern void android_get_keysym_name (int, char *, size_t);
|
||
extern void android_wait_event (void);
|
||
extern void android_toggle_on_screen_keyboard (android_window, bool);
|
||
extern _Noreturn void android_restart_emacs (void);
|
||
extern int android_get_current_api_level (void);
|
||
|
||
|
||
|
||
/* Directory listing emulation. */
|
||
|
||
struct android_dir;
|
||
|
||
extern struct android_dir *android_opendir (const char *);
|
||
extern int android_dirfd (struct android_dir *);
|
||
extern struct dirent *android_readdir (struct android_dir *);
|
||
extern void android_closedir (struct android_dir *);
|
||
|
||
|
||
|
||
/* Very miscellaneous functions. */
|
||
|
||
extern Lisp_Object android_browse_url (Lisp_Object);
|
||
|
||
|
||
|
||
/* Event loop functions. */
|
||
|
||
extern void android_check_query (void);
|
||
extern int android_run_in_emacs_thread (void (*) (void *), void *);
|
||
extern void android_write_event (union android_event *);
|
||
|
||
extern unsigned int event_serial;
|
||
|
||
#endif
|
||
|
||
/* JNI functions should not be built when Emacs is stubbed out for the
|
||
build. These should be documented in EmacsNative.java. */
|
||
|
||
#ifndef ANDROID_STUBIFY
|
||
#include <jni.h>
|
||
|
||
extern JNIEnv *android_java_env;
|
||
|
||
#define ANDROID_DELETE_LOCAL_REF(ref) \
|
||
((*android_java_env)->DeleteLocalRef (android_java_env, \
|
||
(ref)))
|
||
|
||
#define NATIVE_NAME(name) Java_org_gnu_emacs_EmacsNative_##name
|
||
|
||
#endif
|
||
#endif /* _ANDROID_H_ */
|