comparison src/redisplay.c @ 211:78478c60bfcd r20-4b4

Import from CVS: tag r20-4b4
author cvs
date Mon, 13 Aug 2007 10:05:51 +0200
parents 41ff10fd062f
children 78f53ef88e17
comparison
equal deleted inserted replaced
210:49f55ca3ba57 211:78478c60bfcd
54 #include "objects.h" 54 #include "objects.h"
55 #include "process.h" 55 #include "process.h"
56 #include "redisplay.h" 56 #include "redisplay.h"
57 #include "toolbar.h" 57 #include "toolbar.h"
58 #include "window.h" 58 #include "window.h"
59 #include "line-number.h"
59 60
60 #ifdef MULE 61 #ifdef MULE
61 #include "mule-coding.h" 62 #include "mule-coding.h"
62 #endif 63 #endif
63 64
5672 run_hook_trapping_errors ("Error in post-redisplay-hook", 5673 run_hook_trapping_errors ("Error in post-redisplay-hook",
5673 Qpost_redisplay_hook); 5674 Qpost_redisplay_hook);
5674 #endif /* INHIBIT_REDISPLAY_HOOKS */ 5675 #endif /* INHIBIT_REDISPLAY_HOOKS */
5675 } 5676 }
5676 5677
5677 /* Inefficiently determine the line number of the line point is on and 5678
5678 return it as a string. Always do this regardless of whether 5679 static char window_line_number_buf[16];
5679 line_number_mode is true. */ 5680
5680 5681 /* Efficiently determine the window line number, and return a pointer
5681 static char window_line_number_buf[100]; 5682 to its printed representation. Do this regardless of whether
5683 line-number-mode is on. The first line in the buffer is counted as
5684 1. If narrowing is in effect, the lines are counted from the
5685 beginning of the visible portion of the buffer. */
5682 static char * 5686 static char *
5683 window_line_number (struct window *w, int type) 5687 window_line_number (struct window *w, int type)
5684 { 5688 {
5685 struct device *d = XDEVICE (XFRAME (w->frame)->device); 5689 struct device *d = XDEVICE (XFRAME (w->frame)->device);
5686 struct buffer *b = XBUFFER (w->buffer); 5690 struct buffer *b = XBUFFER (w->buffer);
5687 Bufpos end = 5691 Bufpos pos =
5688 (((w == XWINDOW (FRAME_SELECTED_WINDOW (device_selected_frame (d)))) && 5692 (((w == XWINDOW (FRAME_SELECTED_WINDOW (device_selected_frame (d)))) &&
5689 EQ(DEVICE_CONSOLE(d), Vselected_console) && 5693 EQ(DEVICE_CONSOLE(d), Vselected_console) &&
5690 XDEVICE(CONSOLE_SELECTED_DEVICE(XCONSOLE(DEVICE_CONSOLE(d)))) == d && 5694 XDEVICE(CONSOLE_SELECTED_DEVICE(XCONSOLE(DEVICE_CONSOLE(d)))) == d &&
5691 EQ(DEVICE_SELECTED_FRAME(d), w->frame)) 5695 EQ(DEVICE_SELECTED_FRAME(d), w->frame))
5692 ? BUF_PT (b) 5696 ? BUF_PT (b)
5693 : marker_position (w->pointm[type])); 5697 : marker_position (w->pointm[type]));
5694 int lots = 999999999; 5698 EMACS_INT line;
5695 int shortage, line; 5699
5696 5700 line = buffer_line_number (b, pos, 1);
5697 scan_buffer (b, '\n', end, 0, -lots, &shortage, 0); 5701
5698 line = lots - shortage + 1; 5702 sprintf (window_line_number_buf, "%d", line + 1);
5699
5700 sprintf (window_line_number_buf, "%d", line);
5701 5703
5702 return window_line_number_buf; 5704 return window_line_number_buf;
5703 } 5705 }
5706
5704 5707
5705 /* Given a character representing an object in a modeline 5708 /* Given a character representing an object in a modeline
5706 specification, return a string (stored into the global array 5709 specification, return a string (stored into the global array
5707 `mode_spec_bufbyte_string') with the information that object 5710 `mode_spec_bufbyte_string') with the information that object
5708 represents. 5711 represents.