mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-02-03 14:10:47 -08:00
* doc/emacs/android.texi (Android Fonts): * doc/emacs/input.texi (On-Screen Keyboards): * doc/lispref/commands.texi (Misc Events): Update documentation. * java/org/gnu/emacs/EmacsInputConnection.java (setSelection): New function. * java/org/gnu/emacs/EmacsSurfaceView.java (EmacsSurfaceView) (reconfigureFrontBuffer): Make bitmap references weak references. * java/org/gnu/emacs/EmacsView.java (handleDirtyBitmap): Don't clear surfaceView bitmap. * lisp/comint.el (comint-mode): * lisp/international/fontset.el (script-representative-chars) (setup-default-fontset): Improve detection of CJK fonts. * lisp/isearch.el (set-text-conversion-style): New variable. (isearch-mode, isearch-done): Save and restore the text conversion style. * lisp/minibuffer.el (minibuffer-mode): Set an appropriate text conversion style. * lisp/simple.el (analyze-text-conversion): Run post-self-insert-hook properly. * lisp/subr.el (read-char-from-minibuffer): Disable text conversion when reading character. * src/androidterm.c (show_back_buffer): Don't check that F is not garbaged. (android_update_selection, android_reset_conversion): Use the ephemeral last point and handle text conversion being disabled. * src/buffer.c (syms_of_buffer): Convert old style DEFVAR. * src/keyboard.c (kbd_buffer_get_event): Handle text conversion first. * src/lisp.h: Update prototypes. * src/lread.c (read_filtered_event): Temporarily disable text conversion. * src/sfnt.c (sfnt_decompose_glyph_1, sfnt_decompose_glyph_2): New functions. (sfnt_decompose_glyph, sfnt_decompose_instructed_outline): Refactor contour decomposition to those two functions. (main): Update tests. * src/sfntfont-android.c (system_font_directories): Add empty field. (Fandroid_enumerate_fonts, init_sfntfont_android): Enumerate fonts in a user fonts directory. * src/sfntfont.c (struct sfnt_font_desc): New field `num_glyphs'. (sfnt_enum_font_1): Set num_glyphs and avoid duplicate fonts. (sfntfont_glyph_valid): New function. (sfntfont_lookup_char, sfntfont_list_1): Make sure glyphs found are valid. * src/textconv.c (sync_overlay, really_commit_text) (really_set_composing_text, really_set_composing_region) (really_delete_surrounding_text, really_set_point_and_mark) (handle_pending_conversion_events_1) (handle_pending_conversion_events, conversion_disabled_p) (disable_text_conversion, resume_text_conversion) (Fset_text_conversion_style, syms_of_textconv): Update to respect new options. * src/textconv.h: * src/window.h (GCALIGNED_STRUCT): New field `ephemeral_last_point'. * src/xdisp.c (mark_window_display_accurate_1): Set it.
141 lines
3.8 KiB
Java
141 lines
3.8 KiB
Java
/* Communication module for Android terminals. -*- c-file-style: "GNU" -*-
|
|
|
|
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/>. */
|
|
|
|
package org.gnu.emacs;
|
|
|
|
import android.view.View;
|
|
|
|
import android.os.Build;
|
|
|
|
import android.graphics.Bitmap;
|
|
import android.graphics.Canvas;
|
|
import android.graphics.Rect;
|
|
import android.graphics.Paint;
|
|
|
|
import java.lang.ref.WeakReference;
|
|
|
|
/* This originally extended SurfaceView. However, doing so proved to
|
|
be too slow, and Android's surface view keeps up to three of its
|
|
own back buffers, which use too much memory (up to 96 MB for a
|
|
single frame.) */
|
|
|
|
public class EmacsSurfaceView extends View
|
|
{
|
|
private static final String TAG = "EmacsSurfaceView";
|
|
private EmacsView view;
|
|
private Bitmap frontBuffer;
|
|
private Canvas bitmapCanvas;
|
|
private WeakReference<Bitmap> bitmap;
|
|
private Paint bitmapPaint;
|
|
|
|
public
|
|
EmacsSurfaceView (final EmacsView view)
|
|
{
|
|
super (view.getContext ());
|
|
|
|
this.view = view;
|
|
this.bitmapPaint = new Paint ();
|
|
this.bitmap = new WeakReference<Bitmap> (null);
|
|
}
|
|
|
|
private void
|
|
copyToFrontBuffer (Bitmap bitmap, Rect damageRect)
|
|
{
|
|
if (damageRect != null)
|
|
bitmapCanvas.drawBitmap (bitmap, damageRect, damageRect,
|
|
bitmapPaint);
|
|
else
|
|
bitmapCanvas.drawBitmap (bitmap, 0f, 0f, bitmapPaint);
|
|
}
|
|
|
|
private void
|
|
reconfigureFrontBuffer (Bitmap bitmap)
|
|
{
|
|
/* First, remove the old front buffer. */
|
|
|
|
if (frontBuffer != null)
|
|
{
|
|
frontBuffer.recycle ();
|
|
frontBuffer = null;
|
|
bitmapCanvas = null;
|
|
}
|
|
|
|
this.bitmap = new WeakReference<Bitmap> (bitmap);
|
|
|
|
/* Next, create the new front buffer if necessary. */
|
|
|
|
if (bitmap != null && frontBuffer == null)
|
|
{
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
|
|
frontBuffer = Bitmap.createBitmap (bitmap.getWidth (),
|
|
bitmap.getHeight (),
|
|
Bitmap.Config.ARGB_8888,
|
|
false);
|
|
else
|
|
frontBuffer = Bitmap.createBitmap (bitmap.getWidth (),
|
|
bitmap.getHeight (),
|
|
Bitmap.Config.ARGB_8888);
|
|
|
|
bitmapCanvas = new Canvas (frontBuffer);
|
|
|
|
/* And copy over the bitmap contents. */
|
|
copyToFrontBuffer (bitmap, null);
|
|
}
|
|
else if (bitmap != null)
|
|
/* Just copy over the bitmap contents. */
|
|
copyToFrontBuffer (bitmap, null);
|
|
}
|
|
|
|
public synchronized void
|
|
setBitmap (Bitmap bitmap, Rect damageRect)
|
|
{
|
|
if (bitmap != this.bitmap.get ())
|
|
reconfigureFrontBuffer (bitmap);
|
|
else if (bitmap != null)
|
|
copyToFrontBuffer (bitmap, damageRect);
|
|
|
|
if (bitmap != null)
|
|
{
|
|
/* In newer versions of Android, the invalid rectangle is
|
|
supposedly internally calculated by the system. How that
|
|
is done is unknown, but calling `invalidateRect' is now
|
|
deprecated.
|
|
|
|
Fortunately, nobody has deprecated the version of
|
|
`postInvalidate' that accepts a dirty rectangle. */
|
|
|
|
if (damageRect != null)
|
|
postInvalidate (damageRect.left, damageRect.top,
|
|
damageRect.right, damageRect.bottom);
|
|
else
|
|
postInvalidate ();
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public synchronized void
|
|
onDraw (Canvas canvas)
|
|
{
|
|
/* Paint the view's bitmap; the bitmap might be recycled right
|
|
now. */
|
|
|
|
if (frontBuffer != null)
|
|
canvas.drawBitmap (frontBuffer, 0f, 0f, bitmapPaint);
|
|
}
|
|
};
|