aboutsummaryrefslogtreecommitdiffstats
path: root/src/term.c
diff options
context:
space:
mode:
authorPo Lu2022-12-31 18:04:18 +0800
committerPo Lu2022-12-31 18:04:18 +0800
commitcfbc8a5dbcd362b69b37b4e6832ae4a31834364c (patch)
treece003d03c4ae98f4e1d02186d78e5ae6e0d36e55 /src/term.c
parent785095c416f9bae43d2947849282b814e2c7942e (diff)
downloademacs-cfbc8a5dbcd362b69b37b4e6832ae4a31834364c.tar.gz
emacs-cfbc8a5dbcd362b69b37b4e6832ae4a31834364c.zip
Bring up the Android operating system and its window system
* .dir-locals.el (c-mode): Add ANDROID_EXPORT noise macro. * .gitignore: Add new files to ignore. * Makefile.in: Adjust for Android. * admin/merge-gnulib: Add new warning. * configure.ac: Detect Android. Run cross-configuration for Android when appropriate. * etc/DEBUG: Document how to debug Emacs on Android. * java/AndroidManifest.xml: * java/Makefile.in: * java/README: * java/debug.sh: * java/org/gnu/emacs/EmacsActivity.java (EmacsActivity): * java/org/gnu/emacs/EmacsApplication.java (EmacsApplication): * java/org/gnu/emacs/EmacsCopyArea.java (EmacsCopyArea): * java/org/gnu/emacs/EmacsDrawLine.java (EmacsDrawLine): * java/org/gnu/emacs/EmacsDrawPoint.java (EmacsDrawPoint): * java/org/gnu/emacs/EmacsDrawRectangle.java (EmacsDrawRectangle): * java/org/gnu/emacs/EmacsDrawable.java (EmacsDrawable): * java/org/gnu/emacs/EmacsFillPolygon.java (EmacsFillPolygon): * java/org/gnu/emacs/EmacsFillRectangle.java (EmacsFillRectangle): * java/org/gnu/emacs/EmacsFontDriver.java (EmacsFontDriver): * java/org/gnu/emacs/EmacsGC.java (EmacsGC): * java/org/gnu/emacs/EmacsHandleObject.java (EmacsHandleObject): * java/org/gnu/emacs/EmacsNative.java (EmacsNative): * java/org/gnu/emacs/EmacsPaintQueue.java (EmacsPaintQueue): * java/org/gnu/emacs/EmacsPaintReq.java (EmacsPaintReq): * java/org/gnu/emacs/EmacsPixmap.java (EmacsPixmap): * java/org/gnu/emacs/EmacsSdk7FontDriver.java (EmacsSdk7FontDriver): * java/org/gnu/emacs/EmacsService.java (class Holder<T>) (EmacsService): * java/org/gnu/emacs/EmacsSurfaceView.java (EmacsSurfaceView): * java/org/gnu/emacs/EmacsThread.java (EmacsThread): * java/org/gnu/emacs/EmacsView.java (EmacsView): * java/org/gnu/emacs/EmacsWindow.java (EmacsWindow): New files and classes. * lib-src/Makefile.in (srcdir): * lib/Makefile.in (VPATH): (HAVE_NATIVE_COMP): (libgnu_a_SOURCES): (DEPFLAGS): Configure correctly for cross-compiling. * lib/faccessat.c: * lib/fpending.c (__fpending): * lib/open.c: * lib/unistd.c (_GL_UNISTD_INLINE): Temporary adjustments to gnulib. * lisp/frame.el (display-graphic-p): (display-screens): (display-pixel-height): (display-pixel-width): (display-mm-height): (display-mm-width): (display-backing-store): (display-save-under): (display-planes): (display-color-cells): (display-visual-class): Adjust for new window system `android'. * lisp/image/wallpaper.el (x-open-connection): Add declaration. * lisp/loadup.el (featurep): Load up files for Android. * lisp/net/eww.el (eww-form-submit, eww-form-file) (eww-form-checkbox, eww-form-select): Adjust faces for android. * lisp/term/android-win.el: New file. * src/Makefile.in: Add new targets emacs.so and android-emacs, then adjust for cross compilation. * src/alloc.c (cleanup_vector): Clean up Android font entities as well. (garbage_collect): Mark androidterm. * src/android-emacs.c (main): * src/android.c (ANDROID_THROW, enum android_fd_table_entry_flags) (struct android_emacs_service, struct android_emacs_pixmap) (struct android_graphics_point, struct android_event_container) (struct android_event_queue, android_run_select_thread) (android_handle_sigusr1, android_init_events, android_pending) (android_next_event, android_write_event, android_select) (android_run_debug_thread, android_user_full_name) (android_get_asset_name, android_fstat, android_fstatat) (android_file_access_p, android_hack_asset_fd, android_open) (android_close, JNICALL, android_init_emacs_service) (android_init_emacs_pixmap, android_init_graphics_point) (MAX_HANDLE, struct android_handle_entry, android_alloc_id) (android_destroy_handle, android_resolve_handle) (android_resolve_handle2, android_change_window_attributes) (android_create_window, android_set_window_background) (android_destroy_window, android_init_android_rect_class) (android_init_emacs_gc_class, android_create_gc, android_free_gc) (android_change_gc, android_set_clip_rectangles) (android_reparent_window, android_lookup_method) (android_clear_window, android_map_window, android_unmap_window) (android_resize_window, android_move_window, android_swap_buffers) (android_get_gc_values, android_set_foreground) (android_fill_rectangle, android_create_pixmap_from_bitmap_data) (android_set_clip_mask, android_set_fill_style, android_copy_area) (android_free_pixmap, android_set_background, android_fill_polygon) (android_draw_rectangle, android_draw_point, android_draw_line) (android_create_pixmap, android_set_ts_origin, android_clear_area): * src/android.h (ANDROID_EXPORT): * src/androidfns.c (android_display_info_for_name) (check_android_display_info, check_x_display_info, gamma_correct) (android_defined_color, android_decode_color) (android_implicitly_set_name, android_explicitly_set_name) (android_set_tool_bar_lines, android_change_tool_bar_height) (android_set_tab_bar_lines, android_change_tab_bar_height) (android_set_scroll_bar_default_height) (android_set_scroll_bar_default_width, android_icon_verify) (android_icon, android_make_gc, android_free_gcs) (unwind_create_frame, do_unwind_create_frame) (android_default_font_parameter, android_create_frame_window) (Fx_create_frame, Fxw_color_defined_p, Fxw_color_values) (Fxw_display_color_p, Fx_display_grayscale_p) (Fx_display_pixel_width, Fx_display_pixel_height) (Fx_display_planes, Fx_display_color_cells, Fx_display_screens) (Fx_display_mm_width, Fx_display_mm_height) (Fx_display_backing_store, Fx_display_visual_class) (Fx_display_monitor_attributes_list, Fx_frame_geometry) (Fx_frame_list_z_order, Fx_frame_restack) (Fx_mouse_absolute_pixel_position) (Fx_set_mouse_absolute_pixel_position, Fandroid_get_connection) (Fx_display_list, Fx_show_tip, Fx_hide_tip) (android_set_background_color, android_set_border_color) (android_set_cursor_color, android_set_cursor_type) (android_set_foreground_color) (android_set_child_frame_border_width) (android_set_internal_border_width, android_set_menu_bar_lines) (android_set_mouse_color, android_set_title, android_set_alpha) (android_frame_parm_handlers, syms_of_androidfns): * src/androidfont.c (struct android_emacs_font_driver) (struct android_emacs_font_spec, struct android_emacs_font_metrics) (struct android_emacs_font_object, struct android_integer) (struct androidfont_info, struct androidfont_entity) (android_init_font_driver, android_init_font_spec) (android_init_font_metrics, android_init_integer) (android_init_font_object, androidfont_get_cache) (androidfont_from_lisp, androidfont_from_java, androidfont_list) (androidfont_match, androidfont_draw, androidfont_open_font) (androidfont_close_font, androidfont_has_char) (androidfont_encode_char, androidfont_text_extents) (androidfont_list_family, androidfont_driver) (syms_of_androidfont_for_pdumper, syms_of_androidfont) (init_androidfont, android_finalize_font_entity): * src/androidgui.h (_ANDROID_GUI_H_, struct android_rectangle) (struct android_point, enum android_gc_function) (enum android_gc_value_mask, enum android_fill_style) (enum android_window_value_mask) (struct android_set_window_attributes, struct android_gc_values) (struct android_gc, enum android_swap_action, enum android_shape) (enum android_coord_mode, struct android_swap_info) (NativeRectangle, struct android_any_event) (struct android_key_event, struct android_configure_event) (union android_event): * src/androidterm.c (android_window_to_frame, android_clear_frame) (android_ring_bell, android_toggle_invisible_pointer) (android_update_begin, android_update_end, show_back_buffer) (android_flush_dirty_back_buffer_on, handle_one_android_event) (android_read_socket, android_frame_up_to_date) (android_buffer_flipping_unblocked_hook) (android_query_frame_background_color, android_parse_color) (android_alloc_nearest_color, android_query_colors) (android_mouse_position, android_get_focus_frame) (android_focus_frame, android_frame_rehighlight) (android_frame_raise_lower, android_make_frame_visible) (android_make_frame_invisible) (android_make_frame_visible_invisible, android_fullscreen_hook) (android_iconify_frame, android_set_window_size_1) (android_set_window_size, android_set_offset, android_set_alpha) (android_new_font, android_bitmap_icon, android_free_pixmap_hook) (android_free_frame_resources, android_delete_frame) (android_delete_terminal, android_scroll_run) (android_after_update_window_line, android_flip_and_flush) (android_clear_rectangle, android_reset_clip_rectangles) (android_clip_to_row, android_draw_fringe_bitmap) (android_set_cursor_gc, android_set_mouse_face_gc) (android_set_mode_line_face_gc, android_set_glyph_string_gc) (android_set_glyph_string_clipping) (android_set_glyph_string_clipping_exactly) (android_compute_glyph_string_overhangs) (android_clear_glyph_string_rect) (android_draw_glyph_string_background, android_fill_triangle) (android_make_point, android_inside_rect_p, android_clear_point) (android_draw_relief_rect, android_draw_box_rect) (HIGHLIGHT_COLOR_DARK_BOOST_LIMIT, android_setup_relief_color) (android_setup_relief_colors, android_draw_glyph_string_box) (android_draw_glyph_string_bg_rect, android_draw_image_relief) (android_draw_image_foreground, android_draw_image_foreground_1) (android_draw_image_glyph_string) (android_draw_stretch_glyph_string, android_draw_underwave) (android_draw_glyph_string_foreground) (android_draw_composite_glyph_string_foreground) (android_draw_glyphless_glyph_string_foreground) (android_draw_glyph_string, android_define_frame_cursor) (android_clear_frame_area, android_clear_under_internal_border) (android_draw_hollow_cursor, android_draw_bar_cursor) (android_draw_window_cursor, android_draw_vertical_window_border) (android_draw_window_divider, android_redisplay_interface) (frame_set_mouse_pixel_position, get_keysym_name) (android_create_terminal, android_term_init, syms_of_androidterm) (mark_androidterm): * src/androidterm.h (_ANDROID_TERM_H_, struct android_display_info) (struct android_output, FRAME_ANDROID_OUTPUT, XSCROLL_BAR): New files. * src/dired.c (file_attributes): Do not use openat on Android. * src/dispextern.h (No_Cursor): Define appropriately on Android. (struct glyph_string, struct face): Make gc field of type struct android_gc on Android. * src/dispnew.c (clear_current_matrices, clear_desired_matrices) (adjust_frame_glyphs_for_window_redisplay, free_glyphs) (update_frame, scrolling, char_ins_del_cost, update_frame_line) (init_display_interactive): Disable text terminal support completely on Android. Fix non-toolkit menus for non-X systems. * src/editfns.c (Fuser_full_name): Call android_user_full_name. * src/emacs.c (android_emacs_init): Make main this on Android. Prohibit argv sorting from exceeding end of argv. * src/epaths.in: Add path definitions for Android. * src/fileio.c (file_access_p): Call android_file_access_p. (file_name_directory): Avoid using openat on Android. (Fcopy_file): Adjust to call sys_fstat instead. (file_directory_p): (Finsert_file_contents): (write_region): Likewise. * src/filelock.c: * src/fns.c (Flocale_info): Pacify warning on Android. * src/font.c (font_make_entity_android): New function. * src/font.h: * src/frame.c (Fframep): (Fwindow_system): Handle new window system `android'. Update doc strings. (Fmake_terminal_frame): Disable on Android. (gui_display_get_resource): Disable get_string_resource_hook on Android. (syms_of_frame): New defsym `android'. * src/frame.h (GCALIGNED_STRUCT): Add new output data for Android. (ENUM_BF): Expand enumerator size. (FRAME_ANDROID_P, FRAME_WINDOW_P, MOUSE_HL_INFO): Add definitions for Android. * src/image.c (GET_PIXEL): (image_create_bitmap_from_file): (image_create_x_image_and_pixmap_1): (image_get_x_image): (slurp_file): (lookup_rgb_color): (image_to_emacs_colors): (image_from_emacs_colors): (image_pixmap_draw_cross): (image_disable_image): (MaskForeground): (gif_load): Add stubs for Android. * src/lisp.h: * src/lread.c (safe_to_load_version, maybe_swap_for_eln1, openp): * src/pdumper.c (pdumper_load): Call sys_fstat instead of fstat. * src/process.c (wait_reading_process_output): Use android_select instead of pselect. * src/scroll.c: Disable on Android. * src/sysdep.c (widen_foreground_group, reset_sys_modes) (init_signals, emacs_fstatat, sys_fstat): New function. (emacs_open, emacs_open_noquit, emacs_close): Implement differently on Android. (close_output_streams): Disable what is not required on Android. * src/term.c (OUTPUT1_IF, encode_terminal_code, string_cost) (string_cost_one_line, per_line_cost, calculate_costs) (struct fkey_table, tty_append_glyph, produce_glyphs) (tty_capable_p, Fsuspend_tty, Fresume_tty, device, init_tty) (maybe_fatal, syms_of_term): Disable text terminal support on Android. * src/termhooks.h (enum output_method): Add android output method. (GCALIGNED_STRUCT, TERMINAL_FONT_CACHE): Define for Android. * src/terminal.c (Fterminal_live_p): Implement for Android. * src/verbose.mk.in (AM_V_GLOBALS): Add JAVAC and DX. * src/xdisp.c (redisplay_internal): Disable text terminals on Android. (display_menu_bar): (display_tty_menu_item): (draw_row_with_mouse_face): (expose_frame): Make the non toolkit menu bar work on Android. * src/xfaces.c (GCGraphicsExposures): (x_create_gc): (x_free_gc): (Fx_load_color_file): Define for Android. * xcompile/Makefile.in (top_srcdir): (top_builddir): * xcompile/README: * xcompile/langinfo.h (nl_langinfo): New files.
Diffstat (limited to 'src/term.c')
-rw-r--r--src/term.c135
1 files changed, 119 insertions, 16 deletions
diff --git a/src/term.c b/src/term.c
index f8104e0304e..05c54accdee 100644
--- a/src/term.c
+++ b/src/term.c
@@ -62,6 +62,8 @@ static int been_here = -1;
62#include "w32term.h" 62#include "w32term.h"
63#endif 63#endif
64 64
65#ifndef HAVE_ANDROID
66
65static void tty_set_scroll_region (struct frame *f, int start, int stop); 67static void tty_set_scroll_region (struct frame *f, int start, int stop);
66static void turn_on_face (struct frame *, int face_id); 68static void turn_on_face (struct frame *, int face_id);
67static void turn_off_face (struct frame *, int face_id); 69static void turn_off_face (struct frame *, int face_id);
@@ -73,11 +75,15 @@ static void clear_tty_hooks (struct terminal *terminal);
73static void set_tty_hooks (struct terminal *terminal); 75static void set_tty_hooks (struct terminal *terminal);
74static void dissociate_if_controlling_tty (int fd); 76static void dissociate_if_controlling_tty (int fd);
75static void delete_tty (struct terminal *); 77static void delete_tty (struct terminal *);
78
79#endif
80
76static AVOID maybe_fatal (bool, struct terminal *, const char *, const char *, 81static AVOID maybe_fatal (bool, struct terminal *, const char *, const char *,
77 ...) 82 ...)
78 ATTRIBUTE_FORMAT_PRINTF (3, 5) ATTRIBUTE_FORMAT_PRINTF (4, 5); 83 ATTRIBUTE_FORMAT_PRINTF (3, 5) ATTRIBUTE_FORMAT_PRINTF (4, 5);
79static AVOID vfatal (const char *, va_list) ATTRIBUTE_FORMAT_PRINTF (1, 0); 84static AVOID vfatal (const char *, va_list) ATTRIBUTE_FORMAT_PRINTF (1, 0);
80 85
86#ifndef HAVE_ANDROID
81 87
82#define OUTPUT(tty, a) \ 88#define OUTPUT(tty, a) \
83 emacs_tputs ((tty), a, \ 89 emacs_tputs ((tty), a, \
@@ -95,6 +101,8 @@ static AVOID vfatal (const char *, va_list) ATTRIBUTE_FORMAT_PRINTF (1, 0);
95 101
96#define OUTPUT1_IF(tty, a) do { if (a) emacs_tputs ((tty), a, 1, cmputc); } while (0) 102#define OUTPUT1_IF(tty, a) do { if (a) emacs_tputs ((tty), a, 1, cmputc); } while (0)
97 103
104#endif
105
98/* Display space properties. */ 106/* Display space properties. */
99 107
100/* Chain of all tty device parameters. */ 108/* Chain of all tty device parameters. */
@@ -117,10 +125,14 @@ enum no_color_bit
117 125
118/* internal state */ 126/* internal state */
119 127
128#ifndef HAVE_ANDROID
129
120/* The largest frame width in any call to calculate_costs. */ 130/* The largest frame width in any call to calculate_costs. */
121 131
122static int max_frame_cols; 132static int max_frame_cols;
123 133
134#endif
135
124 136
125 137
126#ifdef HAVE_GPM 138#ifdef HAVE_GPM
@@ -133,6 +145,8 @@ struct tty_display_info *gpm_tty = NULL;
133static int last_mouse_x, last_mouse_y; 145static int last_mouse_x, last_mouse_y;
134#endif /* HAVE_GPM */ 146#endif /* HAVE_GPM */
135 147
148#ifndef HAVE_ANDROID
149
136/* Ring the bell on a tty. */ 150/* Ring the bell on a tty. */
137 151
138static void 152static void
@@ -718,7 +732,20 @@ encode_terminal_code (struct glyph *src, int src_len,
718 return (encode_terminal_dst); 732 return (encode_terminal_dst);
719} 733}
720 734
735#else /* !HAVE_ANDROID */
736
737unsigned char *
738encode_terminal_code (struct glyph *src, int src_len,
739 struct coding_system *coding)
740{
741 /* Text terminals are simply not supported on Android. */
742 coding->produced = 0;
743 return NULL;
744}
745
746#endif /* HAVE_ANDROID */
721 747
748#ifndef HAVE_ANDROID
722 749
723/* An implementation of write_glyphs for termcap frames. */ 750/* An implementation of write_glyphs for termcap frames. */
724 751
@@ -1046,8 +1073,10 @@ int
1046string_cost (const char *str) 1073string_cost (const char *str)
1047{ 1074{
1048 cost = 0; 1075 cost = 0;
1076#ifndef HAVE_ANDROID
1049 if (str) 1077 if (str)
1050 tputs (str, 0, evalcost); 1078 tputs (str, 0, evalcost);
1079#endif
1051 return cost; 1080 return cost;
1052} 1081}
1053 1082
@@ -1058,8 +1087,10 @@ static int
1058string_cost_one_line (const char *str) 1087string_cost_one_line (const char *str)
1059{ 1088{
1060 cost = 0; 1089 cost = 0;
1090#ifndef HAVE_ANDROID
1061 if (str) 1091 if (str)
1062 tputs (str, 1, evalcost); 1092 tputs (str, 1, evalcost);
1093#endif
1063 return cost; 1094 return cost;
1064} 1095}
1065 1096
@@ -1070,11 +1101,13 @@ int
1070per_line_cost (const char *str) 1101per_line_cost (const char *str)
1071{ 1102{
1072 cost = 0; 1103 cost = 0;
1104#ifndef HAVE_ANDROID
1073 if (str) 1105 if (str)
1074 tputs (str, 0, evalcost); 1106 tputs (str, 0, evalcost);
1075 cost = - cost; 1107 cost = - cost;
1076 if (str) 1108 if (str)
1077 tputs (str, 10, evalcost); 1109 tputs (str, 10, evalcost);
1110#endif
1078 return cost; 1111 return cost;
1079} 1112}
1080 1113
@@ -1147,11 +1180,14 @@ calculate_ins_del_char_costs (struct frame *f)
1147 *p++ = (ins_startup_cost += ins_cost_per_char); 1180 *p++ = (ins_startup_cost += ins_cost_per_char);
1148} 1181}
1149 1182
1183#endif
1184
1150void 1185void
1151calculate_costs (struct frame *frame) 1186calculate_costs (struct frame *frame)
1152{ 1187{
1153 FRAME_COST_BAUD_RATE (frame) = baud_rate; 1188 FRAME_COST_BAUD_RATE (frame) = baud_rate;
1154 1189
1190#ifndef HAVE_ANDROID
1155 if (FRAME_TERMCAP_P (frame)) 1191 if (FRAME_TERMCAP_P (frame))
1156 { 1192 {
1157 struct tty_display_info *tty = FRAME_TTY (frame); 1193 struct tty_display_info *tty = FRAME_TTY (frame);
@@ -1206,13 +1242,15 @@ calculate_costs (struct frame *frame)
1206 1242
1207 cmcostinit (FRAME_TTY (frame)); /* set up cursor motion costs */ 1243 cmcostinit (FRAME_TTY (frame)); /* set up cursor motion costs */
1208 } 1244 }
1245#endif
1209} 1246}
1210 1247
1211struct fkey_table { 1248struct fkey_table
1249{
1212 const char *cap, *name; 1250 const char *cap, *name;
1213}; 1251};
1214 1252
1215#ifndef DOS_NT 1253#if !defined DOS_NT && !defined HAVE_ANDROID
1216 /* Termcap capability names that correspond directly to X keysyms. 1254 /* Termcap capability names that correspond directly to X keysyms.
1217 Some of these (marked "terminfo") aren't supplied by old-style 1255 Some of these (marked "terminfo") aren't supplied by old-style
1218 (Berkeley) termcap entries. They're listed in X keysym order; 1256 (Berkeley) termcap entries. They're listed in X keysym order;
@@ -1443,6 +1481,9 @@ term_get_fkeys_1 (void)
1443#endif /* not DOS_NT */ 1481#endif /* not DOS_NT */
1444 1482
1445 1483
1484
1485#ifndef HAVE_ANDROID
1486
1446/*********************************************************************** 1487/***********************************************************************
1447 Character Display Information 1488 Character Display Information
1448 ***********************************************************************/ 1489 ***********************************************************************/
@@ -1519,14 +1560,17 @@ append_glyph (struct it *it)
1519 } 1560 }
1520} 1561}
1521 1562
1563#endif
1564
1522/* For external use. */ 1565/* For external use. */
1523void 1566void
1524tty_append_glyph (struct it *it) 1567tty_append_glyph (struct it *it)
1525{ 1568{
1569#ifndef HAVE_ANDROID
1526 append_glyph (it); 1570 append_glyph (it);
1571#endif
1527} 1572}
1528 1573
1529
1530/* Produce glyphs for the display element described by IT. *IT 1574/* Produce glyphs for the display element described by IT. *IT
1531 specifies what we want to produce a glyph for (character, image, ...), 1575 specifies what we want to produce a glyph for (character, image, ...),
1532 and where in the glyph matrix we currently are (glyph row and hpos). 1576 and where in the glyph matrix we currently are (glyph row and hpos).
@@ -1549,6 +1593,7 @@ tty_append_glyph (struct it *it)
1549void 1593void
1550produce_glyphs (struct it *it) 1594produce_glyphs (struct it *it)
1551{ 1595{
1596#ifndef HAVE_ANDROID
1552 /* If a hook is installed, let it do the work. */ 1597 /* If a hook is installed, let it do the work. */
1553 1598
1554 /* Nothing but characters are supported on terminal frames. */ 1599 /* Nothing but characters are supported on terminal frames. */
@@ -1661,8 +1706,11 @@ produce_glyphs (struct it *it)
1661 it->current_x += it->pixel_width; 1706 it->current_x += it->pixel_width;
1662 it->ascent = it->max_ascent = it->phys_ascent = it->max_phys_ascent = 0; 1707 it->ascent = it->max_ascent = it->phys_ascent = it->max_phys_ascent = 0;
1663 it->descent = it->max_descent = it->phys_descent = it->max_phys_descent = 1; 1708 it->descent = it->max_descent = it->phys_descent = it->max_phys_descent = 1;
1709#endif
1664} 1710}
1665 1711
1712#ifndef HAVE_ANDROID
1713
1666/* Append glyphs to IT's glyph_row for the composition IT->cmp_id. 1714/* Append glyphs to IT's glyph_row for the composition IT->cmp_id.
1667 Called from produce_composite_glyph for terminal frames if 1715 Called from produce_composite_glyph for terminal frames if
1668 IT->glyph_row != NULL. IT->face_id contains the character's 1716 IT->glyph_row != NULL. IT->face_id contains the character's
@@ -2020,6 +2068,7 @@ turn_off_face (struct frame *f, int face_id)
2020 OUTPUT1_IF (tty, tty->TS_orig_pair); 2068 OUTPUT1_IF (tty, tty->TS_orig_pair);
2021} 2069}
2022 2070
2071#endif /* !HAVE_ANDROID */
2023 2072
2024/* Return true if the terminal on frame F supports all of the 2073/* Return true if the terminal on frame F supports all of the
2025 capabilities in CAPS simultaneously. */ 2074 capabilities in CAPS simultaneously. */
@@ -2027,8 +2076,9 @@ turn_off_face (struct frame *f, int face_id)
2027bool 2076bool
2028tty_capable_p (struct tty_display_info *tty, unsigned int caps) 2077tty_capable_p (struct tty_display_info *tty, unsigned int caps)
2029{ 2078{
2079#ifndef HAVE_ANDROID
2030#define TTY_CAPABLE_P_TRY(tty, cap, TS, NC_bit) \ 2080#define TTY_CAPABLE_P_TRY(tty, cap, TS, NC_bit) \
2031 if ((caps & (cap)) && (!(TS) || !MAY_USE_WITH_COLORS_P(tty, NC_bit))) \ 2081 if ((caps & (cap)) && (!(TS) || !MAY_USE_WITH_COLORS_P (tty, NC_bit))) \
2032 return 0; 2082 return 0;
2033 2083
2034 TTY_CAPABLE_P_TRY (tty, 2084 TTY_CAPABLE_P_TRY (tty,
@@ -2048,6 +2098,9 @@ tty_capable_p (struct tty_display_info *tty, unsigned int caps)
2048 2098
2049 /* We can do it! */ 2099 /* We can do it! */
2050 return 1; 2100 return 1;
2101#else
2102 return false;
2103#endif
2051} 2104}
2052 2105
2053/* Return non-zero if the terminal is capable to display colors. */ 2106/* Return non-zero if the terminal is capable to display colors. */
@@ -2081,7 +2134,7 @@ TERMINAL does not refer to a text terminal. */)
2081 return make_fixnum (t ? t->display_info.tty->TN_max_colors : 0); 2134 return make_fixnum (t ? t->display_info.tty->TN_max_colors : 0);
2082} 2135}
2083 2136
2084#ifndef DOS_NT 2137#if !defined DOS_NT && !defined HAVE_ANDROID
2085 2138
2086/* Declare here rather than in the function, as in the rest of Emacs, 2139/* Declare here rather than in the function, as in the rest of Emacs,
2087 to work around an HPUX compiler bug (?). See 2140 to work around an HPUX compiler bug (?). See
@@ -2186,7 +2239,7 @@ set_tty_color_mode (struct tty_display_info *tty, struct frame *f)
2186 } 2239 }
2187} 2240}
2188 2241
2189#endif /* !DOS_NT */ 2242#endif /* !DOS_NT && !HAVE_ANDROID */
2190 2243
2191char * 2244char *
2192tty_type_name (Lisp_Object terminal) 2245tty_type_name (Lisp_Object terminal)
@@ -2278,6 +2331,7 @@ suspended.
2278A suspended tty may be resumed by calling `resume-tty' on it. */) 2331A suspended tty may be resumed by calling `resume-tty' on it. */)
2279 (Lisp_Object tty) 2332 (Lisp_Object tty)
2280{ 2333{
2334#ifndef HAVE_ANDROID
2281 struct terminal *t = decode_tty_terminal (tty); 2335 struct terminal *t = decode_tty_terminal (tty);
2282 FILE *f; 2336 FILE *f;
2283 2337
@@ -2314,6 +2368,10 @@ A suspended tty may be resumed by calling `resume-tty' on it. */)
2314 2368
2315 /* Clear display hooks to prevent further output. */ 2369 /* Clear display hooks to prevent further output. */
2316 clear_tty_hooks (t); 2370 clear_tty_hooks (t);
2371#else
2372 /* This will always signal on Android. */
2373 decode_tty_terminal (tty);
2374#endif
2317 2375
2318 return Qnil; 2376 return Qnil;
2319} 2377}
@@ -2337,9 +2395,12 @@ TTY may be a terminal object, a frame, or nil (meaning the selected
2337frame's terminal). */) 2395frame's terminal). */)
2338 (Lisp_Object tty) 2396 (Lisp_Object tty)
2339{ 2397{
2340 struct terminal *t = decode_tty_terminal (tty); 2398#ifndef HAVE_ANDROID
2399 struct terminal *t;
2341 int fd; 2400 int fd;
2342 2401
2402 t = decode_tty_terminal (tty);
2403
2343 if (!t) 2404 if (!t)
2344 error ("Attempt to resume a non-text terminal device"); 2405 error ("Attempt to resume a non-text terminal device");
2345 2406
@@ -2396,10 +2457,15 @@ frame's terminal). */)
2396 } 2457 }
2397 2458
2398 set_tty_hooks (t); 2459 set_tty_hooks (t);
2460#else
2461 decode_tty_terminal (tty);
2462#endif
2399 2463
2400 return Qnil; 2464 return Qnil;
2401} 2465}
2402 2466
2467#ifndef HAVE_ANDROID
2468
2403DEFUN ("tty--set-output-buffer-size", Ftty__set_output_buffer_size, 2469DEFUN ("tty--set-output-buffer-size", Ftty__set_output_buffer_size,
2404 Stty__set_output_buffer_size, 1, 2, 0, doc: 2470 Stty__set_output_buffer_size, 1, 2, 0, doc:
2405 /* Set the output buffer size for a TTY. 2471 /* Set the output buffer size for a TTY.
@@ -2438,12 +2504,14 @@ A value of zero means TTY uses the system's default value. */)
2438 error ("Not a tty terminal"); 2504 error ("Not a tty terminal");
2439} 2505}
2440 2506
2507#endif
2508
2441 2509
2442/*********************************************************************** 2510/***********************************************************************
2443 Mouse 2511 Mouse
2444 ***********************************************************************/ 2512 ***********************************************************************/
2445 2513
2446#ifndef DOS_NT 2514#if !defined DOS_NT && !defined HAVE_ANDROID
2447 2515
2448/* Implementation of draw_row_with_mouse_face for TTY/GPM and macOS. */ 2516/* Implementation of draw_row_with_mouse_face for TTY/GPM and macOS. */
2449void 2517void
@@ -2713,7 +2781,7 @@ DEFUN ("gpm-mouse-stop", Fgpm_mouse_stop, Sgpm_mouse_stop,
2713 Menus 2781 Menus
2714 ***********************************************************************/ 2782 ***********************************************************************/
2715 2783
2716#if !defined (MSDOS) 2784#if !defined (MSDOS) && !defined HAVE_ANDROID
2717 2785
2718/* TTY menu implementation and main ideas are borrowed from msdos.c. 2786/* TTY menu implementation and main ideas are borrowed from msdos.c.
2719 2787
@@ -3813,10 +3881,12 @@ tty_menu_show (struct frame *f, int x, int y, int menuflags,
3813 return SAFE_FREE_UNBIND_TO (specpdl_count, entry); 3881 return SAFE_FREE_UNBIND_TO (specpdl_count, entry);
3814} 3882}
3815 3883
3816#endif /* !MSDOS */ 3884#endif /* !MSDOS && !defined HAVE_ANDROID */
3817 3885
3818 3886
3819#ifndef MSDOS 3887
3888#if !defined MSDOS && !defined HAVE_ANDROID
3889
3820/*********************************************************************** 3890/***********************************************************************
3821 Initialization 3891 Initialization
3822 ***********************************************************************/ 3892 ***********************************************************************/
@@ -3846,7 +3916,7 @@ tty_free_frame_resources (struct frame *f)
3846 xfree (f->output_data.tty); 3916 xfree (f->output_data.tty);
3847} 3917}
3848 3918
3849#else /* MSDOS */ 3919#elif defined MSDOS
3850 3920
3851/* Delete frame F's face cache. */ 3921/* Delete frame F's face cache. */
3852 3922
@@ -3856,8 +3926,13 @@ tty_free_frame_resources (struct frame *f)
3856 eassert (FRAME_TERMCAP_P (f) || FRAME_MSDOS_P (f)); 3926 eassert (FRAME_TERMCAP_P (f) || FRAME_MSDOS_P (f));
3857 free_frame_faces (f); 3927 free_frame_faces (f);
3858} 3928}
3859#endif /* MSDOS */ 3929
3930#endif
3931
3860 3932
3933
3934#ifndef HAVE_ANDROID
3935
3861/* Reset the hooks in TERMINAL. */ 3936/* Reset the hooks in TERMINAL. */
3862 3937
3863static void 3938static void
@@ -3952,6 +4027,8 @@ dissociate_if_controlling_tty (int fd)
3952 } 4027 }
3953} 4028}
3954 4029
4030#endif /* !HAVE_ANDROID */
4031
3955/* Create a termcap display on the tty device with the given name and 4032/* Create a termcap display on the tty device with the given name and
3956 type. 4033 type.
3957 4034
@@ -3961,11 +4038,23 @@ dissociate_if_controlling_tty (int fd)
3961 4038
3962 TERMINAL_TYPE is the termcap type of the device, e.g. "vt100". 4039 TERMINAL_TYPE is the termcap type of the device, e.g. "vt100".
3963 4040
3964 If MUST_SUCCEED is true, then all errors are fatal. */ 4041 If MUST_SUCCEED is true, then all errors are fatal. This function
4042 always signals on Android, where text terminals are prohibited by
4043 system policy (and the required libraries are usually not
4044 available.) */
4045
4046#ifdef HAVE_ANDROID
4047_Noreturn
4048#endif
3965 4049
3966struct terminal * 4050struct terminal *
3967init_tty (const char *name, const char *terminal_type, bool must_succeed) 4051init_tty (const char *name, const char *terminal_type, bool must_succeed)
3968{ 4052{
4053#ifdef HAVE_ANDROID
4054 maybe_fatal (must_succeed, 0, "Text terminals are not supported"
4055 " under Android", "Text terminals are not supported"
4056 " under Android");
4057#else
3969 struct tty_display_info *tty = NULL; 4058 struct tty_display_info *tty = NULL;
3970 struct terminal *terminal = NULL; 4059 struct terminal *terminal = NULL;
3971#ifndef DOS_NT 4060#ifndef DOS_NT
@@ -4447,6 +4536,7 @@ use the Bourne shell command 'TERM=...; export TERM' (C-shell:\n\
4447 init_sys_modes (tty); 4536 init_sys_modes (tty);
4448 4537
4449 return terminal; 4538 return terminal;
4539#endif /* !HAVE_ANDROID */
4450} 4540}
4451 4541
4452 4542
@@ -4471,8 +4561,13 @@ maybe_fatal (bool must_succeed, struct terminal *terminal,
4471{ 4561{
4472 va_list ap; 4562 va_list ap;
4473 va_start (ap, str2); 4563 va_start (ap, str2);
4564
4565#ifndef HAVE_ANDROID
4474 if (terminal) 4566 if (terminal)
4475 delete_tty (terminal); 4567 delete_tty (terminal);
4568#else
4569 eassert (terminal == NULL);
4570#endif
4476 4571
4477 if (must_succeed) 4572 if (must_succeed)
4478 vfatal (str2, ap); 4573 vfatal (str2, ap);
@@ -4490,6 +4585,8 @@ fatal (const char *str, ...)
4490 4585
4491 4586
4492 4587
4588#ifndef HAVE_ANDROID
4589
4493/* Delete the given tty terminal, closing all frames on it. */ 4590/* Delete the given tty terminal, closing all frames on it. */
4494 4591
4495static void 4592static void
@@ -4547,6 +4644,8 @@ delete_tty (struct terminal *terminal)
4547 xfree (tty); 4644 xfree (tty);
4548} 4645}
4549 4646
4647#endif
4648
4550void 4649void
4551syms_of_term (void) 4650syms_of_term (void)
4552{ 4651{
@@ -4594,21 +4693,25 @@ trigger redisplay. */);
4594 defsubr (&Stty_top_frame); 4693 defsubr (&Stty_top_frame);
4595 defsubr (&Ssuspend_tty); 4694 defsubr (&Ssuspend_tty);
4596 defsubr (&Sresume_tty); 4695 defsubr (&Sresume_tty);
4696#ifndef HAVE_ANDROID
4597 defsubr (&Stty__set_output_buffer_size); 4697 defsubr (&Stty__set_output_buffer_size);
4598 defsubr (&Stty__output_buffer_size); 4698 defsubr (&Stty__output_buffer_size);
4699#endif /* !HAVE_ANDROID */
4599#ifdef HAVE_GPM 4700#ifdef HAVE_GPM
4600 defsubr (&Sgpm_mouse_start); 4701 defsubr (&Sgpm_mouse_start);
4601 defsubr (&Sgpm_mouse_stop); 4702 defsubr (&Sgpm_mouse_stop);
4602#endif /* HAVE_GPM */ 4703#endif /* HAVE_GPM */
4603 4704
4604#ifndef DOS_NT 4705#if !defined DOS_NT && !defined HAVE_ANDROID
4605 default_orig_pair = NULL; 4706 default_orig_pair = NULL;
4606 default_set_foreground = NULL; 4707 default_set_foreground = NULL;
4607 default_set_background = NULL; 4708 default_set_background = NULL;
4608#endif /* !DOS_NT */ 4709#endif /* !DOS_NT && !HAVE_ANDROID */
4609 4710
4711#ifndef HAVE_ANDROID
4610 encode_terminal_src = NULL; 4712 encode_terminal_src = NULL;
4611 encode_terminal_dst = NULL; 4713 encode_terminal_dst = NULL;
4714#endif
4612 4715
4613 DEFSYM (Qtty_mode_set_strings, "tty-mode-set-strings"); 4716 DEFSYM (Qtty_mode_set_strings, "tty-mode-set-strings");
4614 DEFSYM (Qtty_mode_reset_strings, "tty-mode-reset-strings"); 4717 DEFSYM (Qtty_mode_reset_strings, "tty-mode-reset-strings");