[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] shr-fontified 3669977 3/3: Cherry-pick the `window-text-pi
From: |
Lars Ingebrigtsen |
Subject: |
[Emacs-diffs] shr-fontified 3669977 3/3: Cherry-pick the `window-text-pixel-size' change |
Date: |
Thu, 05 Feb 2015 03:53:36 +0000 |
branch: shr-fontified
commit 3669977bebf5ba77a0fcc14820967f818dc8af92
Author: Martin Rudalics <address@hidden>
Commit: Lars Magne Ingebrigtsen <address@hidden>
Cherry-pick the `window-text-pixel-size' change
---
doc/lispref/ChangeLog | 28 ++++++
doc/lispref/display.texi | 9 ++-
lisp/ChangeLog | 4 +
lisp/net/shr.el | 40 ++++-----
src/ChangeLog | 214 ++++++++++++++++++++++++++++++++++++++++++++++
src/xdisp.c | 44 ++++++---
6 files changed, 302 insertions(+), 37 deletions(-)
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog
index 4c0c116..aa4d320 100644
--- a/doc/lispref/ChangeLog
+++ b/doc/lispref/ChangeLog
@@ -1,3 +1,31 @@
+2015-02-01 Martin Rudalics <address@hidden>
+
+ * display.texi (Size of Displayed Text): Describe optional
+ argument BUFFER of `window-text-pixel-size'.
+
+2015-01-28 Eli Zaretskii <address@hidden>
+
+ * searching.texi (Regexp Search): Add a cross-reference to "Syntax
+ of Regexps". (Bug#19668)
+
+2015-01-28 Daniel Koning <address@hidden> (tiny change)
+
+ * commands.texi (Drag Events, Motion Events, Event Examples)
+ (Accessing Mouse): Describe actual range of values that mouse
+ position objects can have.
+
+2015-01-28 Eli Zaretskii <address@hidden>
+
+ * display.texi (Manipulating Buttons): Explain more about the
+ 'action' property. (Bug#19628)
+
+ * text.texi (Clickable Text): Improve indexing. (Bug#19629)
+
+ * variables.texi (Creating Buffer-Local): Improve indexing. (Bug#19608)
+
+ * frames.texi (Display Feature Testing): Make the description of
+ x-server-version and x-server-vendor less X-specific. (Bug#19502)
+
2015-01-15 Eli Zaretskii <address@hidden>
* streams.texi (Input Functions): Document 'set-binary-mode'.
diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi
index 1b7f21d..4cfea6d 100644
--- a/doc/lispref/display.texi
+++ b/doc/lispref/display.texi
@@ -1880,7 +1880,7 @@ displayed in a given window. This function is used by
@code{fit-frame-to-buffer} (@pxref{Size and Position}) to make a window
exactly as large as the text it contains.
address@hidden window-text-pixel-size &optional window from to x-limit y-limit
mode-and-header-line
address@hidden window-text-pixel-size &optional window from to x-limit y-limit
mode-and-header-line buffer
This function returns the size of the text of @var{window}'s buffer in
pixels. @var{window} must be a live window and defaults to the selected
one. The return value is a cons of the maximum pixel-width of any text
@@ -1919,6 +1919,13 @@ means to not include the height of the mode- or
header-line of
@code{mode-line} or @code{header-line}, include only the height of that
line, if present, in the return value. If it is @code{t}, include the
height of both, if present, in the return value.
+
+The optional argument @var{buffer} allows to specify an alternate buffer
+whose text size will be calculated. If @var{buffer} is @code{nil} or
+omitted, then operate on the buffer of @var{window}. If it is @code{t},
+then operate on the current buffer as if it were displayed in
address@hidden If it specifies a live buffer, then operate on that
+buffer as if it were displayed in @var{window}.
@end defun
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index dbd5bb6..3203289 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,7 @@
+2015-02-05 Lars Ingebrigtsen <address@hidden>
+
+ * net/shr.el (shr-pixel-column): Base in `shr-glyph-widths'.
+
2015-01-31 Lars Ingebrigtsen <address@hidden>
* net/shr.el (shr-glyph-widths-fast): New function to call
diff --git a/lisp/net/shr.el b/lisp/net/shr.el
index 00a2c39..4023833 100644
--- a/lisp/net/shr.el
+++ b/lisp/net/shr.el
@@ -135,6 +135,7 @@ cid: URL as the argument.")
(defvar shr-state nil)
(defvar shr-start nil)
(defvar shr-font-cache nil)
+(defvar shr-fill-cache nil)
(defvar shr-indentation 0)
(defvar shr-internal-width nil)
(defvar shr-list-mode nil)
@@ -209,6 +210,7 @@ DOM should be a parse tree as generated by
(shr-depth 0)
(shr-warning nil)
(shr-font-cache (make-hash-table :test 'eq))
+ (shr-fill-cache (make-hash-table :test 'equal))
(shr-internal-width (or shr-width
(- (window-pixel-width)
(* (frame-fringe-width) 2)))))
@@ -453,19 +455,11 @@ size, and full-buffer size."
(load "kinsoku" nil t))
(defun shr-pixel-column ()
- (let ((width 0)
- (string (buffer-substring (line-beginning-position) (point)))
- (start 0))
- (while (< start (length string))
- (let ((glyphs (font-get-glyphs (font-at start nil string)
- start (1+ start) string)))
- (setq width
- (if (not (aref glyphs 0))
- ;; If we have a degenerate font, just say "10".
- 10
- (+ width (aref (aref glyphs 0) 4)))))
- (setq start (1+ start)))
- width))
+ (let ((glyphs (shr-glyph-widths (line-beginning-position) (point)))
+ (total 0))
+ (dotimes (i (length glyphs))
+ (setq total (+ total (aref glyphs i))))
+ total))
(defun shr-string-pixel-width (string)
(with-temp-buffer
@@ -527,7 +521,15 @@ size, and full-buffer size."
(put-text-property start (1+ start) 'shr-indentation nil)
(when (> indentation 0)
(insert (make-string indentation ?\s)))
- (let ((widths (shr-glyph-widths start (line-end-position)))
+ (let ((widths (if (> shr-table-depth 0)
+ (let ((line (buffer-substring
+ start (line-end-position))))
+ (or (gethash line shr-fill-cache)
+ (let ((widths (shr-glyph-widths
+ start (line-end-position))))
+ (puthash line widths shr-fill-cache)
+ widths)))
+ (shr-glyph-widths start (line-end-position))))
(max-width 0)
(this-width 0)
(i 0))
@@ -571,19 +573,15 @@ size, and full-buffer size."
(while (< pos end)
(setq script (aref char-script-table (char-after pos)))
(when (not (eq script last-script))
- (push (list script-start (1- pos) last-script) scripts)
+ (push (list script-start pos last-script) scripts)
(setq last-script script
script-start pos))
(setq pos (1+ pos)))
(push (list script-start pos script) scripts)
(setq pos 0)
(dolist (spec (nreverse scripts))
- (let* ((font (or (gethash (nth 2 spec) shr-font-cache)
- (let ((font
- (font-at 0 nil (buffer-substring
- (nth 0 spec) (1+ (nth 0 spec))))))
- (puthash (nth 2 spec) font shr-font-cache)
- font)))
+ (let* ((font (font-at 0 nil (buffer-substring
+ (nth 0 spec) (1+ (nth 0 spec)))))
(glyphs (font-get-glyphs font (nth 0 spec) (nth 1 spec))))
(dotimes (i (length glyphs))
(let ((glyph (aref glyphs i)))
diff --git a/src/ChangeLog b/src/ChangeLog
index 4fc0de7..d45b4e3 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,217 @@
+2015-02-01 Martin Rudalics <address@hidden>
+
+ * xdisp.c (Fwindow_text_pixel_size): Add optional argument BUFFER.
+
+2015-02-01 Joakim Verona <address@hidden>
+ Support for the new Xwidget feature.
+ * window.c, Makefile.in, buffer.c, dispextern.h, dispnew.c, emacs.c:
+ * emacsgtkfixed.c, emacsgtkfixed.h, keyboard.c, lisp.h, print.c:
+ * termhooks.h, window.c, xdisp.c, xterm.c
+ New files for xwidgets:
+ * xwidget.c, xwidget.h:
+ Support for testing xwidgets
+ * xwidget-test-manual.el:
+
+2015-02-01 Grégoire Jadi <address@hidden>
+ Support for testing xwidgets
+ * parallell-remote.el, parallell-xwidget.el, parallell.el:
+ * xwidget-tests.el:
+ various improvements to xwidgets:
+ * xwidgets.c:
+
+2015-01-31 Eli Zaretskii <address@hidden>
+
+ * coding.c (raw_text_coding_system_p): New function.
+
+ * keyboard.c (read_decoded_event_from_main_queue): Use it when the
+ keyboard coding-system is 'raw-text'. (Bug#19532)
+
+ * coding.h (raw_text_coding_system_p): Add prototype.
+
+2015-01-31 Andreas Schwab <address@hidden>
+
+ * Makefile.in (gl-stamp): Generate globals.h through the use of
+ move-if-change.
+ (globals.h): Replace with empty command.
+
+2015-01-31 Eli Zaretskii <address@hidden>
+
+ * keyboard.c (kbd_buffer_store_event_hold): Ignore FOCUS_OUT_EVENT
+ and ICONIFY_EVENT for the purposes of breaking while-no-input
+ loops. (Bug#19547)
+
+ * dired.c (read_dirent): Correct the "MSDOS hacks" hack: the
+ special code for errno = ENOENT or EACCES is needed for WINDOWSNT,
+ not for MSDOS.
+
+2015-01-31 Paul Eggert <address@hidden>
+
+ Simplify read_dirent's MSDOS hacks
+ * dired.c (read_dirent): Simplify by removing the need for the
+ DIR_ENTRY argument. All callers changed. This separates the
+ MS-DOS idiosyncrasies better from the rest of the code.
+
+2015-01-30 Eli Zaretskii <address@hidden>
+
+ * dired.c (read_dirent): Accept an additional argument
+ FIRST_ENTRY. If readdir fails with ENOENT or EACCES the first
+ time it is called, report the error as if it happened in
+ open_directory.
+ (directory_files_internal, file_name_completion): Adjust callers
+ or read_dirent.
+
+2015-01-30 Paul Eggert <address@hidden>
+
+ Refactor calls to opendir for simplicity
+ * dired.c (open_directory): Accept Lisp_Object, not char *, for
+ dirname. Signal an error if the open fails. All callers changed.
+
+2015-01-29 Paul Eggert <address@hidden>
+
+ Report readdir failures
+ Previously, on non-MS-Windows platforms the code treated most
+ readdir failures as EOF. This was incorrect, e.g., when readdir
+ fails with errno == EOVERFLOW. Signal an error instead.
+ * dired.c (read_dirent):
+ New function, which signals an error when readdir fails.
+ (directory_files_internal, file_name_completion): Use it.
+
+2015-01-29 Eli Zaretskii <address@hidden>
+
+ Use bool for boolean in w32menu.c, w32font.c, w32uniscribe.c.
+ * w32uniscribe.c (uniscribe_list, uniscribe_match): Use bool where
+ appropriate.
+
+ * w32font.c (struct font_callback_data, w32font_list_internal)
+ (w32font_driver, w32font_match_internal): Use bool where appropriate.
+
+ * w32menu.c (x_activate_menubar, set_frame_menubar)
+ (w32_dialog_show, initialize_frame_menubar, w32_menu_show)
+ (is_simple_dialog): Use bool where appropriate.
+
+2015-01-28 Paul Eggert <address@hidden>
+
+ Use bool, not int, to track face changes
+ * xfaces.c (face_change): Rename from face_change_count, and
+ change from int to bool. The var is now true (instead of nonzero)
+ if attributes have changed; this is simpler. All uses changed.
+ (Bug#19698)
+
+2015-01-28 Eli Zaretskii <address@hidden>
+
+ * dired.c (directory_files_internal, file_name_completion)
+ [WINDOWSNT]: Signal an error when errno is set non-zero by
+ 'readdir', regardless of its value.
+
+ * w32.c (sys_readdir): Set errno to ENOENT when the directory
+ doesn't exist and to EACCES when it's not accessible to the
+ current user. Set errno to zero when FindNextFile exhausts the
+ directory, so that callers don't interpret that as an error and
+ don't signal a file-error.
+ (open_unc_volume): Set errno to ENOENT if WNetOpenEnum fails.
+
+ * dired.c (directory_files_internal) [WINDOWSNT]: If readdir
+ returns NULL and errno is ENOTDIR, behave as if opendir failed to
+ open the directory. (Bug#19701)
+
+ * w32.c (sys_readdir): If FindFirstFile fails because the
+ directory doesn't exist, set errno to ENOTDIR.
+
+2015-01-28 Jan Djärv <address@hidden>
+
+ * nsterm.m (drawRect:): Add block/unblock_input (Bug#19660).
+
+2015-01-28 Paul Eggert <address@hidden>
+
+ Fix coding.c subscript error
+ * coding.c (CODING_ISO_INVOKED_CHARSET):
+ Avoid undefined behavior if CODING_ISO_INVOCATION returns negative.
+
+2015-01-28 Eli Zaretskii <address@hidden>
+
+ * xdisp.c (produce_image_glyph): Fix display of images in R2L
+ screen lines: prepend the new glyph to the ones already there
+ instead of appending it.
+
+ * w32fns.c (w32_set_title_bar_text): New function, including
+ support for titles with non-ASCII characters outside of the
+ current system codepage.
+ (x_set_name, x_set_title): Use it. (Bug#19590)
+
+ * indent.c (Fvertical_motion): Return zero if we started from ZV
+ and there's an overlay after-string there. (Bug#19553)
+
+ * emacs.c (usage_message): Fix the description of the -nl switch.
+ (Bug#19542)
+
+ * xdisp.c (move_it_to, try_cursor_movement): Don't use the window
+ end information if the window_end_valid flag is unset.
+ (try_window_id): If the call to display_line invalidated the
+ window end information, give up the try_window_id optimization.
+ (Bug#19511)
+
+ * w32fns.c (Fx_server_version, Fx_server_vendor): Doc fix.
+ * xfns.c (Fx_server_version, Fx_server_vendor): Doc fix.
+
+ * emacs.c (syms_of_emacs) <system-configuration>: Doc fix. (Bug#19502)
+
+2015-01-28 Stefan Monnier <address@hidden>
+
+ * lisp.mk (lisp): Add cl-preloaded.
+
+2015-01-27 Paul Eggert <address@hidden>
+
+ Use bool for boolean in xfaces.c
+ * dispextern.h: Adjust to signature changes.
+ * font.c (font_at, font_range):
+ * fontset.c (Finternal_char_font):
+ * fringe.c (draw_fringe_bitmap_1):
+ * xdisp.c (handle_face_prop, face_before_or_after_it_pos)
+ (get_next_display_element, highlight_trailing_whitespace)
+ (display_string, calc_line_height_property)
+ (note_mode_line_or_margin_highlight, note_mouse_highlight):
+ * xfaces.c (tty_suppress_bold_inverse_default_colors_p)
+ (menu_face_changed_default, recompute_basic_faces)
+ (Fbitmap_spec_p, parse_rgb_list, tty_lookup_color)
+ (tty_defined_color, defined_color, face_color_gray_p)
+ (face_color_supported_p, load_color2, load_face_colors)
+ (Fx_list_fonts, LFACEP, push_named_merge_point)
+ (resolve_face_name, lface_from_face_name_no_resolve)
+ (lface_from_face_name, get_lface_attributes_no_remap)
+ (get_lface_attributes, lface_fully_specified_p)
+ (set_lface_from_font, merge_face_vectors, merge_named_face)
+ (merge_face_ref, Finternal_make_lisp_face)
+ (Finternal_lisp_face_p, Finternal_copy_lisp_face)
+ (Finternal_set_lisp_face_attribute)
+ (update_face_from_frame_parameter, set_font_frame_param)
+ (face_boolean_x_resource_value)
+ (Finternal_set_lisp_face_attribute_from_resource)
+ (x_update_menu_appearance, Finternal_get_lisp_face_attribute)
+ (Finternal_merge_in_global_face, Fface_font, face_attr_equal_p)
+ (lface_equal_p, Finternal_lisp_face_equal_p)
+ (Finternal_lisp_face_empty_p, lface_same_font_attributes_p)
+ (Fcolor_distance, lookup_named_face, lookup_basic_face)
+ (lookup_derived_face, Fface_attributes_as_vector)
+ (x_supports_face_attributes_p, tty_supports_face_attributes_p)
+ (Fdisplay_supports_face_attributes_p, realize_basic_faces)
+ (realize_default_face, realize_named_face)
+ (realize_non_ascii_face, realize_x_face, map_tty_color)
+ (realize_tty_face, compute_char_face, face_at_buffer_position)
+ (face_for_overlay_string, face_at_string_position):
+ Use bool for boolean.
+ * xfaces.c (set_lface_from_font):
+ Return void, since callers never use the result.
+
+2015-01-26 Andreas Schwab <address@hidden>
+
+ * image.c (lookup_pixel_color): Reorder conditions that are
+ written backwards.
+ (x_to_xcolors): Likewise.
+ (x_detect_edges): Likewise.
+ (png_load_body): Likewise.
+ (gif_close): Likewise.
+ (gif_load): Likewise.
+
2015-01-25 Eli Zaretskii <address@hidden>
Use bool for boolean in w32term.c
diff --git a/src/xdisp.c b/src/xdisp.c
index d974687..6fc3e2c 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -9649,7 +9649,7 @@ in_display_vector_p (struct it *it)
&& it->dpvec + it->current.dpvec_index != it->dpend);
}
-DEFUN ("window-text-pixel-size", Fwindow_text_pixel_size,
Swindow_text_pixel_size, 0, 6, 0,
+DEFUN ("window-text-pixel-size", Fwindow_text_pixel_size,
Swindow_text_pixel_size, 0, 7, 0,
doc: /* Return the size of the text of WINDOW's buffer in pixels.
WINDOW must be a live window and defaults to the selected one. The
return value is a cons of the maximum pixel-width of any text line and
@@ -9682,28 +9682,42 @@ Optional argument MODE-AND-HEADER-LINE nil or omitted
means do not
include the height of the mode- or header-line of WINDOW in the return
value. If it is either the symbol `mode-line' or `header-line', include
only the height of that line, if present, in the return value. If t,
-include the height of both, if present, in the return value. */)
- (Lisp_Object window, Lisp_Object from, Lisp_Object to, Lisp_Object x_limit,
Lisp_Object y_limit,
- Lisp_Object mode_and_header_line)
+include the height of both, if present, in the return value.
+
+Optional argument BUFFER nil means to return the size of the text of
+WINDOW's buffer. BUFFER t means to return the size of the text of the
+current buffer as if it were displayed in WINDOW. Else BUFFER has to
+specify a live buffer and this function returns the size of the text of
+BUFFER as if it were displayed in WINDOW. */)
+ (Lisp_Object window, Lisp_Object from, Lisp_Object to, Lisp_Object x_limit,
+ Lisp_Object y_limit, Lisp_Object mode_and_header_line, Lisp_Object buffer)
{
struct window *w = decode_live_window (window);
- Lisp_Object buf;
struct buffer *b;
struct it it;
- struct buffer *old_buffer = NULL;
+ struct buffer *old_b = NULL;
ptrdiff_t start, end, pos;
struct text_pos startp;
void *itdata = NULL;
int c, max_y = -1, x = 0, y = 0;
- buf = w->contents;
- CHECK_BUFFER (buf);
- b = XBUFFER (buf);
-
- if (b != current_buffer)
+ if (EQ (buffer, Qt))
+ b = current_buffer;
+ else
{
- old_buffer = current_buffer;
- set_buffer_internal (b);
+ if (NILP (buffer))
+ buffer = w->contents;
+
+ CHECK_BUFFER (buffer);
+ if (!BUFFER_LIVE_P (XBUFFER (buffer)))
+ error ("Not a live buffer");
+
+ b = XBUFFER (buffer);
+ if (b != current_buffer)
+ {
+ old_b = current_buffer;
+ set_buffer_internal (b);
+ }
}
if (NILP (from))
@@ -9779,8 +9793,8 @@ include the height of both, if present, in the return
value. */)
bidi_unshelve_cache (itdata, 0);
- if (old_buffer)
- set_buffer_internal (old_buffer);
+ if (old_b)
+ set_buffer_internal (old_b);
return Fcons (make_number (x), make_number (y));
}