Index: src/window.c =================================================================== RCS file: /usr/CVSroot/XEmacs/xemacs-20/src/window.c,v retrieving revision 1.41.2.64 diff -c -r1.41.2.64 window.c *** window.c 2000/09/15 04:15:39 1.41.2.64 --- window.c 2000/09/22 22:00:11 *************** *** 5815,5840 **** return unbind_to (speccount, val); } ! DEFUN ("current-pixel-column", Fcurrent_pixel_column, 0, 2, 0, /* ! Return the horizontal pixel position of POS in window. ! Beginning of line is column 0. This is calculated using the redisplay ! display tables. If WINDOW is nil, the current window is assumed. ! If POS is nil, point is assumed. Note that POS must be visible for ! a non-nil result to be returned. ! */ ! (window, pos)) { ! struct window* w = decode_window (window); ! display_line_dynarr *dla = window_display_lines (w, CURRENT_DISP); ! ! struct display_line *dl = 0; ! struct display_block *db = 0; ! struct rune* rb = 0; ! int y = w->last_point_y[CURRENT_DISP]; ! int x = w->last_point_x[CURRENT_DISP]; ! ! if (MINI_WINDOW_P (w)) ! return Qnil; if (y<0 || x<0 || y >= Dynarr_length (dla) || !NILP (pos)) { --- 5815,5837 ---- return unbind_to (speccount, val); } ! static int ! get_current_pixel_pos (Lisp_Object window, Lisp_Object pos, ! struct window **w, ! struct rune **rb, struct display_line **dl) { ! display_line_dynarr *dla; ! struct display_block *db = NULL; ! int x, y; ! ! *rb = NULL; ! *dl = NULL; ! *w = decode_window (window); ! dla = window_display_lines (*w, CURRENT_DISP); ! x = (*w)->last_point_x[CURRENT_DISP]; ! y = (*w)->last_point_y[CURRENT_DISP]; ! if (MINI_WINDOW_P (*w)) ! return 0; if (y<0 || x<0 || y >= Dynarr_length (dla) || !NILP (pos)) { *************** *** 5854,5892 **** for (i = first_line; i < Dynarr_length (dla); i++) { ! dl = Dynarr_atp (dla, i); /* find the vertical location first */ ! if (point >= dl->bufpos && point <= dl->end_bufpos) { ! db = get_display_block_from_line (dl, TEXT); for (i = 0; i < Dynarr_length (db->runes); i++) { ! rb = Dynarr_atp (db->runes, i); ! if (point <= rb->bufpos) goto found_bufpos; } ! return Qnil; } } ! return Qnil; found_bufpos: ; } else { /* optimized case */ ! dl = Dynarr_atp (dla, y); ! db = get_display_block_from_line (dl, TEXT); if (x >= Dynarr_length (db->runes)) ! return Qnil; ! rb = Dynarr_atp (db->runes, x); } return make_int (rb->xpos - WINDOW_LEFT (w)); } #ifdef DEBUG_XEMACS /* This is short and simple in elisp, but... it was written to debug --- 5851,5931 ---- for (i = first_line; i < Dynarr_length (dla); i++) { ! *dl = Dynarr_atp (dla, i); /* find the vertical location first */ ! if (point >= (*dl)->bufpos && point <= (*dl)->end_bufpos) { ! db = get_display_block_from_line (*dl, TEXT); for (i = 0; i < Dynarr_length (db->runes); i++) { ! *rb = Dynarr_atp (db->runes, i); ! if (point <= (*rb)->bufpos) goto found_bufpos; } ! return 0; } } ! return 0; found_bufpos: ; } else { /* optimized case */ ! *dl = Dynarr_atp (dla, y); ! db = get_display_block_from_line (*dl, TEXT); if (x >= Dynarr_length (db->runes)) ! return NULL; ! *rb = Dynarr_atp (db->runes, x); } + return 1; + } + + DEFUN ("current-pixel-column", Fcurrent_pixel_column, 0, 2, 0, /* + Return the horizontal pixel position of POS in window. + Beginning of line is column 0. This is calculated using the redisplay + display tables; because of this, the returned value will only be + correct if the redisplay tables are up-to-date. Use \"(sit-for 0)\" + to insure that they are. If WINDOW is nil, the current window is + assumed. If POS is nil, point is assumed. Note that POS must be + visible for a non-nil result to be returned. + */ + (window, pos)) + { + struct window* w; + struct display_line *dl; + struct rune* rb; + + if (!get_current_pixel_pos(window, pos, &w, &rb, &dl)) + return Qnil; + return make_int (rb->xpos - WINDOW_LEFT (w)); } + DEFUN ("current-pixel-row", Fcurrent_pixel_row, 0, 2, 0, /* + Return the vertical pixel position of POS in window. + Top of window is row 0. This is calculated using the redisplay + display tables; because of this, the returned value will only be + correct if the redisplay tables are up-to-date. Use \"(sit-for 0)\" + to insure that they are. If WINDOW is nil, the current window is + assumed. If POS is nil, point is assumed. Note that POS must be + visible for a non-nil result to be returned. + */ + (window, pos)) + { + struct window* w; + struct display_line *dl; + struct rune* rb; + + if (!get_current_pixel_pos(window, pos, &w, &rb, &dl)) + return Qnil; + + return make_int (dl->ypos - dl->ascent - WINDOW_LEFT (w)); + } + #ifdef DEBUG_XEMACS /* This is short and simple in elisp, but... it was written to debug *************** *** 6039,6044 **** --- 6078,6084 ---- DEFSUBR (Fcurrent_window_configuration); DEFSUBR (Fsave_window_excursion); DEFSUBR (Fcurrent_pixel_column); + DEFSUBR (Fcurrent_pixel_row); } void