diff options
Diffstat (limited to 'src/msdos.c')
| -rw-r--r-- | src/msdos.c | 596 |
1 files changed, 61 insertions, 535 deletions
diff --git a/src/msdos.c b/src/msdos.c index 0957221f597..c676ed91a64 100644 --- a/src/msdos.c +++ b/src/msdos.c | |||
| @@ -941,551 +941,78 @@ static Lisp_Object last_mouse_window; | |||
| 941 | 941 | ||
| 942 | static int mouse_preempted = 0; /* non-zero when XMenu gobbles mouse events */ | 942 | static int mouse_preempted = 0; /* non-zero when XMenu gobbles mouse events */ |
| 943 | 943 | ||
| 944 | /* Set the mouse pointer shape according to whether it is in the | 944 | int |
| 945 | area where the mouse highlight is in effect. */ | 945 | popup_activated (void) |
| 946 | static void | ||
| 947 | IT_set_mouse_pointer (int mode) | ||
| 948 | { | 946 | { |
| 949 | /* A no-op for now. DOS text-mode mouse pointer doesn't offer too | 947 | return mouse_preempted; |
| 950 | many possibilities to change its shape, and the available | ||
| 951 | functionality pretty much sucks (e.g., almost every reasonable | ||
| 952 | shape will conceal the character it is on). Since the color of | ||
| 953 | the pointer changes in the highlighted area, it is not clear to | ||
| 954 | me whether anything else is required, anyway. */ | ||
| 955 | } | 948 | } |
| 956 | 949 | ||
| 957 | /* Display the active region described by mouse_face_* | 950 | /* Draw TEXT_AREA glyphs between START and END of glyph row ROW on |
| 958 | in its mouse-face if HL > 0, in its normal face if HL = 0. */ | 951 | window W, starting at x-position X. X is relative to TEXT_AREA |
| 959 | static void | 952 | in W. HL is a face override for drawing the glyphs. */ |
| 960 | show_mouse_face (struct tty_display_info *dpyinfo, int hl) | 953 | void |
| 954 | draw_row_with_mouse_face (struct window *w, int x, struct glyph_row *row, | ||
| 955 | int start_hpos, int end_hpos, | ||
| 956 | enum draw_glyphs_face hl) | ||
| 961 | { | 957 | { |
| 962 | struct window *w = XWINDOW (dpyinfo->mouse_face_window); | ||
| 963 | struct frame *f = XFRAME (WINDOW_FRAME (w)); | 958 | struct frame *f = XFRAME (WINDOW_FRAME (w)); |
| 964 | int i; | ||
| 965 | struct face *fp; | ||
| 966 | struct tty_display_info *tty = FRAME_TTY (f); | 959 | struct tty_display_info *tty = FRAME_TTY (f); |
| 967 | 960 | ||
| 968 | 961 | if (hl == DRAW_MOUSE_FACE) | |
| 969 | /* If window is in the process of being destroyed, don't bother | ||
| 970 | doing anything. */ | ||
| 971 | if (w->current_matrix == NULL) | ||
| 972 | goto set_cursor_shape; | ||
| 973 | |||
| 974 | /* Recognize when we are called to operate on rows that don't exist | ||
| 975 | anymore. This can happen when a window is split. */ | ||
| 976 | if (dpyinfo->mouse_face_end_row >= w->current_matrix->nrows) | ||
| 977 | goto set_cursor_shape; | ||
| 978 | |||
| 979 | /* There's no sense to do anything if the mouse face isn't realized. */ | ||
| 980 | if (hl > 0) | ||
| 981 | { | ||
| 982 | if (dpyinfo->mouse_face_hidden) | ||
| 983 | goto set_cursor_shape; | ||
| 984 | |||
| 985 | fp = FACE_FROM_ID (SELECTED_FRAME(), dpyinfo->mouse_face_face_id); | ||
| 986 | if (!fp) | ||
| 987 | goto set_cursor_shape; | ||
| 988 | } | ||
| 989 | |||
| 990 | /* Note that mouse_face_beg_row etc. are window relative. */ | ||
| 991 | for (i = dpyinfo->mouse_face_beg_row; | ||
| 992 | i <= dpyinfo->mouse_face_end_row; | ||
| 993 | i++) | ||
| 994 | { | 962 | { |
| 995 | int start_hpos, end_hpos; | 963 | int vpos = row->y + WINDOW_TOP_EDGE_Y (w); |
| 996 | struct glyph_row *row = MATRIX_ROW (w->current_matrix, i); | 964 | int kstart = start_hpos + WINDOW_LEFT_EDGE_X (w); |
| 997 | 965 | int nglyphs = end_hpos - start_hpos; | |
| 998 | /* Don't do anything if row doesn't have valid contents. */ | 966 | int offset = ScreenPrimary + 2*(vpos*screen_size_X + kstart) + 1; |
| 999 | if (!row->enabled_p) | 967 | int start_offset = offset; |
| 1000 | continue; | ||
| 1001 | 968 | ||
| 1002 | /* For all but the first row, the highlight starts at column 0. */ | 969 | if (tty->termscript) |
| 1003 | if (i == dpyinfo->mouse_face_beg_row) | 970 | fprintf (tty->termscript, "\n<MH+ %d-%d:%d>", |
| 1004 | start_hpos = dpyinfo->mouse_face_beg_col; | 971 | kstart, kstart + nglyphs - 1, vpos); |
| 1005 | else | ||
| 1006 | start_hpos = 0; | ||
| 1007 | |||
| 1008 | if (i == dpyinfo->mouse_face_end_row) | ||
| 1009 | end_hpos = dpyinfo->mouse_face_end_col; | ||
| 1010 | else | ||
| 1011 | end_hpos = row->used[TEXT_AREA]; | ||
| 1012 | |||
| 1013 | if (end_hpos <= start_hpos) | ||
| 1014 | continue; | ||
| 1015 | /* Record that some glyphs of this row are displayed in | ||
| 1016 | mouse-face. */ | ||
| 1017 | row->mouse_face_p = hl > 0; | ||
| 1018 | if (hl > 0) | ||
| 1019 | { | ||
| 1020 | int vpos = row->y + WINDOW_TOP_EDGE_Y (w); | ||
| 1021 | int kstart = start_hpos + WINDOW_LEFT_EDGE_X (w); | ||
| 1022 | int nglyphs = end_hpos - start_hpos; | ||
| 1023 | int offset = ScreenPrimary + 2*(vpos*screen_size_X + kstart) + 1; | ||
| 1024 | int start_offset = offset; | ||
| 1025 | |||
| 1026 | if (tty->termscript) | ||
| 1027 | fprintf (tty->termscript, "\n<MH+ %d-%d:%d>", | ||
| 1028 | kstart, kstart + nglyphs - 1, vpos); | ||
| 1029 | |||
| 1030 | mouse_off (); | ||
| 1031 | IT_set_face (dpyinfo->mouse_face_face_id); | ||
| 1032 | /* Since we are going to change only the _colors_ of the | ||
| 1033 | displayed text, there's no need to go through all the | ||
| 1034 | pain of generating and encoding the text from the glyphs. | ||
| 1035 | Instead, we simply poke the attribute byte of each | ||
| 1036 | affected position in video memory with the colors | ||
| 1037 | computed by IT_set_face! */ | ||
| 1038 | _farsetsel (_dos_ds); | ||
| 1039 | while (nglyphs--) | ||
| 1040 | { | ||
| 1041 | _farnspokeb (offset, ScreenAttrib); | ||
| 1042 | offset += 2; | ||
| 1043 | } | ||
| 1044 | if (screen_virtual_segment) | ||
| 1045 | dosv_refresh_virtual_screen (start_offset, end_hpos - start_hpos); | ||
| 1046 | mouse_on (); | ||
| 1047 | } | ||
| 1048 | else | ||
| 1049 | { | ||
| 1050 | /* We are removing a previously-drawn mouse highlight. The | ||
| 1051 | safest way to do so is to redraw the glyphs anew, since | ||
| 1052 | all kinds of faces and display tables could have changed | ||
| 1053 | behind our back. */ | ||
| 1054 | int nglyphs = end_hpos - start_hpos; | ||
| 1055 | int save_x = new_pos_X, save_y = new_pos_Y; | ||
| 1056 | |||
| 1057 | if (end_hpos >= row->used[TEXT_AREA]) | ||
| 1058 | nglyphs = row->used[TEXT_AREA] - start_hpos; | ||
| 1059 | |||
| 1060 | /* IT_write_glyphs writes at cursor position, so we need to | ||
| 1061 | temporarily move cursor coordinates to the beginning of | ||
| 1062 | the highlight region. */ | ||
| 1063 | new_pos_X = start_hpos + WINDOW_LEFT_EDGE_X (w); | ||
| 1064 | new_pos_Y = row->y + WINDOW_TOP_EDGE_Y (w); | ||
| 1065 | |||
| 1066 | if (tty->termscript) | ||
| 1067 | fprintf (tty->termscript, "<MH- %d-%d:%d>", | ||
| 1068 | new_pos_X, new_pos_X + nglyphs - 1, new_pos_Y); | ||
| 1069 | IT_write_glyphs (f, row->glyphs[TEXT_AREA] + start_hpos, nglyphs); | ||
| 1070 | if (tty->termscript) | ||
| 1071 | fputs ("\n", tty->termscript); | ||
| 1072 | new_pos_X = save_x; | ||
| 1073 | new_pos_Y = save_y; | ||
| 1074 | } | ||
| 1075 | } | ||
| 1076 | |||
| 1077 | set_cursor_shape: | ||
| 1078 | /* Change the mouse pointer shape. */ | ||
| 1079 | IT_set_mouse_pointer (hl); | ||
| 1080 | } | ||
| 1081 | |||
| 1082 | /* Clear out the mouse-highlighted active region. | ||
| 1083 | Redraw it un-highlighted first. */ | ||
| 1084 | static void | ||
| 1085 | clear_mouse_face (struct tty_display_info *dpyinfo) | ||
| 1086 | { | ||
| 1087 | if (!dpyinfo->mouse_face_hidden && ! NILP (dpyinfo->mouse_face_window)) | ||
| 1088 | show_mouse_face (dpyinfo, 0); | ||
| 1089 | |||
| 1090 | dpyinfo->mouse_face_beg_row = dpyinfo->mouse_face_beg_col = -1; | ||
| 1091 | dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_end_col = -1; | ||
| 1092 | dpyinfo->mouse_face_window = Qnil; | ||
| 1093 | } | ||
| 1094 | |||
| 1095 | /* Find the glyph matrix position of buffer position POS in window W. | ||
| 1096 | *HPOS and *VPOS are set to the positions found. W's current glyphs | ||
| 1097 | must be up to date. If POS is above window start return (0, 0). | ||
| 1098 | If POS is after end of W, return end of last line in W. */ | ||
| 1099 | static int | ||
| 1100 | fast_find_position (struct window *w, int pos, int *hpos, int *vpos) | ||
| 1101 | { | ||
| 1102 | int i, lastcol, line_start_position, maybe_next_line_p = 0; | ||
| 1103 | int yb = window_text_bottom_y (w); | ||
| 1104 | struct glyph_row *row = MATRIX_ROW (w->current_matrix, 0), *best_row = row; | ||
| 1105 | |||
| 1106 | while (row->y < yb) | ||
| 1107 | { | ||
| 1108 | if (row->used[TEXT_AREA]) | ||
| 1109 | line_start_position = row->glyphs[TEXT_AREA]->charpos; | ||
| 1110 | else | ||
| 1111 | line_start_position = 0; | ||
| 1112 | |||
| 1113 | if (line_start_position > pos) | ||
| 1114 | break; | ||
| 1115 | /* If the position sought is the end of the buffer, | ||
| 1116 | don't include the blank lines at the bottom of the window. */ | ||
| 1117 | else if (line_start_position == pos | ||
| 1118 | && pos == BUF_ZV (XBUFFER (w->buffer))) | ||
| 1119 | { | ||
| 1120 | maybe_next_line_p = 1; | ||
| 1121 | break; | ||
| 1122 | } | ||
| 1123 | else if (line_start_position > 0) | ||
| 1124 | best_row = row; | ||
| 1125 | |||
| 1126 | /* Don't overstep the last matrix row, lest we get into the | ||
| 1127 | never-never land... */ | ||
| 1128 | if (row->y + 1 >= yb) | ||
| 1129 | break; | ||
| 1130 | |||
| 1131 | ++row; | ||
| 1132 | } | ||
| 1133 | |||
| 1134 | /* Find the right column within BEST_ROW. */ | ||
| 1135 | lastcol = 0; | ||
| 1136 | row = best_row; | ||
| 1137 | for (i = 0; i < row->used[TEXT_AREA]; i++) | ||
| 1138 | { | ||
| 1139 | struct glyph *glyph = row->glyphs[TEXT_AREA] + i; | ||
| 1140 | int charpos; | ||
| 1141 | |||
| 1142 | charpos = glyph->charpos; | ||
| 1143 | if (charpos == pos) | ||
| 1144 | { | ||
| 1145 | *hpos = i; | ||
| 1146 | *vpos = row->y; | ||
| 1147 | return 1; | ||
| 1148 | } | ||
| 1149 | else if (charpos > pos) | ||
| 1150 | break; | ||
| 1151 | else if (charpos > 0) | ||
| 1152 | lastcol = i; | ||
| 1153 | } | ||
| 1154 | |||
| 1155 | /* If we're looking for the end of the buffer, | ||
| 1156 | and we didn't find it in the line we scanned, | ||
| 1157 | use the start of the following line. */ | ||
| 1158 | if (maybe_next_line_p) | ||
| 1159 | { | ||
| 1160 | ++row; | ||
| 1161 | lastcol = 0; | ||
| 1162 | } | ||
| 1163 | |||
| 1164 | *vpos = row->y; | ||
| 1165 | *hpos = lastcol + 1; | ||
| 1166 | return 0; | ||
| 1167 | } | ||
| 1168 | |||
| 1169 | /* Take proper action when mouse has moved to the mode or top line of | ||
| 1170 | window W, x-position X. MODE_LINE_P non-zero means mouse is on the | ||
| 1171 | mode line. X is relative to the start of the text display area of | ||
| 1172 | W, so the width of fringes and scroll bars must be subtracted | ||
| 1173 | to get a position relative to the start of the mode line. */ | ||
| 1174 | static void | ||
| 1175 | IT_note_mode_line_highlight (struct window *w, int x, int mode_line_p) | ||
| 1176 | { | ||
| 1177 | struct glyph_row *row; | ||
| 1178 | |||
| 1179 | if (mode_line_p) | ||
| 1180 | row = MATRIX_MODE_LINE_ROW (w->current_matrix); | ||
| 1181 | else | ||
| 1182 | row = MATRIX_HEADER_LINE_ROW (w->current_matrix); | ||
| 1183 | 972 | ||
| 1184 | if (row->enabled_p) | 973 | mouse_off (); |
| 1185 | { | 974 | IT_set_face (tty->mouse_face_face_id); |
| 1186 | struct glyph *glyph, *end; | 975 | /* Since we are going to change only the _colors_ of already |
| 1187 | Lisp_Object help; | 976 | displayed text, there's no need to go through all the pain of |
| 1188 | 977 | generating and encoding the text from the glyphs. Instead, | |
| 1189 | /* Find the glyph under X. */ | 978 | we simply poke the attribute byte of each affected position |
| 1190 | glyph = (row->glyphs[TEXT_AREA] | 979 | in video memory with the colors computed by IT_set_face! */ |
| 1191 | + x | 980 | _farsetsel (_dos_ds); |
| 1192 | /* in case someone implements scroll bars some day... */ | 981 | while (nglyphs--) |
| 1193 | - WINDOW_LEFT_SCROLL_BAR_AREA_WIDTH (w)); | ||
| 1194 | end = glyph + row->used[TEXT_AREA]; | ||
| 1195 | if (glyph < end | ||
| 1196 | && STRINGP (glyph->object) | ||
| 1197 | && STRING_INTERVALS (glyph->object) | ||
| 1198 | && glyph->charpos >= 0 | ||
| 1199 | && glyph->charpos < SCHARS (glyph->object)) | ||
| 1200 | { | 982 | { |
| 1201 | /* If we're on a string with `help-echo' text property, | 983 | _farnspokeb (offset, ScreenAttrib); |
| 1202 | arrange for the help to be displayed. This is done by | 984 | offset += 2; |
| 1203 | setting the global variable help_echo to the help string. */ | ||
| 1204 | help = Fget_text_property (make_number (glyph->charpos), | ||
| 1205 | Qhelp_echo, glyph->object); | ||
| 1206 | if (!NILP (help)) | ||
| 1207 | { | ||
| 1208 | help_echo_string = help; | ||
| 1209 | XSETWINDOW (help_echo_window, w); | ||
| 1210 | help_echo_object = glyph->object; | ||
| 1211 | help_echo_pos = glyph->charpos; | ||
| 1212 | } | ||
| 1213 | } | 985 | } |
| 986 | if (screen_virtual_segment) | ||
| 987 | dosv_refresh_virtual_screen (start_offset, end_hpos - start_hpos); | ||
| 988 | mouse_on (); | ||
| 1214 | } | 989 | } |
| 1215 | } | 990 | else if (hl == DRAW_NORMAL_TEXT) |
| 1216 | |||
| 1217 | /* Take proper action when the mouse has moved to position X, Y on | ||
| 1218 | frame F as regards highlighting characters that have mouse-face | ||
| 1219 | properties. Also de-highlighting chars where the mouse was before. | ||
| 1220 | X and Y can be negative or out of range. */ | ||
| 1221 | static void | ||
| 1222 | IT_note_mouse_highlight (struct frame *f, int x, int y) | ||
| 1223 | { | ||
| 1224 | struct tty_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f); | ||
| 1225 | enum window_part part = ON_NOTHING; | ||
| 1226 | Lisp_Object window; | ||
| 1227 | struct window *w; | ||
| 1228 | |||
| 1229 | /* When a menu is active, don't highlight because this looks odd. */ | ||
| 1230 | if (mouse_preempted) | ||
| 1231 | return; | ||
| 1232 | |||
| 1233 | if (NILP (Vmouse_highlight) | ||
| 1234 | || !f->glyphs_initialized_p) | ||
| 1235 | return; | ||
| 1236 | |||
| 1237 | dpyinfo->mouse_face_mouse_x = x; | ||
| 1238 | dpyinfo->mouse_face_mouse_y = y; | ||
| 1239 | dpyinfo->mouse_face_mouse_frame = f; | ||
| 1240 | |||
| 1241 | if (dpyinfo->mouse_face_defer) | ||
| 1242 | return; | ||
| 1243 | |||
| 1244 | if (gc_in_progress) | ||
| 1245 | { | ||
| 1246 | dpyinfo->mouse_face_deferred_gc = 1; | ||
| 1247 | return; | ||
| 1248 | } | ||
| 1249 | |||
| 1250 | /* Which window is that in? */ | ||
| 1251 | window = window_from_coordinates (f, x, y, &part, &x, &y, 0); | ||
| 1252 | |||
| 1253 | /* If we were displaying active text in another window, clear that. */ | ||
| 1254 | if (! EQ (window, dpyinfo->mouse_face_window)) | ||
| 1255 | clear_mouse_face (dpyinfo); | ||
| 1256 | |||
| 1257 | /* Not on a window -> return. */ | ||
| 1258 | if (!WINDOWP (window)) | ||
| 1259 | return; | ||
| 1260 | |||
| 1261 | /* Convert to window-relative coordinates. */ | ||
| 1262 | w = XWINDOW (window); | ||
| 1263 | |||
| 1264 | if (part == ON_MODE_LINE || part == ON_HEADER_LINE) | ||
| 1265 | { | ||
| 1266 | /* Mouse is on the mode or top line. */ | ||
| 1267 | IT_note_mode_line_highlight (w, x, part == ON_MODE_LINE); | ||
| 1268 | return; | ||
| 1269 | } | ||
| 1270 | |||
| 1271 | IT_set_mouse_pointer (0); | ||
| 1272 | |||
| 1273 | /* Are we in a window whose display is up to date? | ||
| 1274 | And verify the buffer's text has not changed. */ | ||
| 1275 | if (part == ON_TEXT | ||
| 1276 | && EQ (w->window_end_valid, w->buffer) | ||
| 1277 | && XFASTINT (w->last_modified) == BUF_MODIFF (XBUFFER (w->buffer)) | ||
| 1278 | && (XFASTINT (w->last_overlay_modified) | ||
| 1279 | == BUF_OVERLAY_MODIFF (XBUFFER (w->buffer)))) | ||
| 1280 | { | 991 | { |
| 1281 | int pos, i, nrows = w->current_matrix->nrows; | 992 | /* We are removing a previously-drawn mouse highlight. The |
| 1282 | struct glyph_row *row; | 993 | safest way to do so is to redraw the glyphs anew, since all |
| 1283 | struct glyph *glyph; | 994 | kinds of faces and display tables could have changed behind |
| 995 | our back. */ | ||
| 996 | int nglyphs = end_hpos - start_hpos; | ||
| 997 | int save_x = new_pos_X, save_y = new_pos_Y; | ||
| 998 | |||
| 999 | if (end_hpos >= row->used[TEXT_AREA]) | ||
| 1000 | nglyphs = row->used[TEXT_AREA] - start_hpos; | ||
| 1001 | |||
| 1002 | /* IT_write_glyphs writes at cursor position, so we need to | ||
| 1003 | temporarily move cursor coordinates to the beginning of | ||
| 1004 | the highlight region. */ | ||
| 1005 | new_pos_X = start_hpos + WINDOW_LEFT_EDGE_X (w); | ||
| 1006 | new_pos_Y = row->y + WINDOW_TOP_EDGE_Y (w); | ||
| 1284 | 1007 | ||
| 1285 | /* Find the glyph under X/Y. */ | 1008 | if (tty->termscript) |
| 1286 | glyph = NULL; | 1009 | fprintf (tty->termscript, "<MH- %d-%d:%d>", |
| 1287 | if (y >= 0 && y < nrows) | 1010 | new_pos_X, new_pos_X + nglyphs - 1, new_pos_Y); |
| 1288 | { | 1011 | IT_write_glyphs (f, row->glyphs[TEXT_AREA] + start_hpos, nglyphs); |
| 1289 | row = MATRIX_ROW (w->current_matrix, y); | 1012 | if (tty->termscript) |
| 1290 | /* Give up if some row before the one we are looking for is | 1013 | fputs ("\n", tty->termscript); |
| 1291 | not enabled. */ | 1014 | new_pos_X = save_x; |
| 1292 | for (i = 0; i <= y; i++) | 1015 | new_pos_Y = save_y; |
| 1293 | if (!MATRIX_ROW (w->current_matrix, i)->enabled_p) | ||
| 1294 | break; | ||
| 1295 | if (i > y /* all rows upto and including the one at Y are enabled */ | ||
| 1296 | && row->displays_text_p | ||
| 1297 | && x < window_box_width (w, TEXT_AREA)) | ||
| 1298 | { | ||
| 1299 | glyph = row->glyphs[TEXT_AREA]; | ||
| 1300 | if (x >= row->used[TEXT_AREA]) | ||
| 1301 | glyph = NULL; | ||
| 1302 | else | ||
| 1303 | { | ||
| 1304 | glyph += x; | ||
| 1305 | if (!BUFFERP (glyph->object)) | ||
| 1306 | glyph = NULL; | ||
| 1307 | } | ||
| 1308 | } | ||
| 1309 | } | ||
| 1310 | |||
| 1311 | /* Clear mouse face if X/Y not over text. */ | ||
| 1312 | if (glyph == NULL) | ||
| 1313 | { | ||
| 1314 | clear_mouse_face (dpyinfo); | ||
| 1315 | return; | ||
| 1316 | } | ||
| 1317 | |||
| 1318 | if (!BUFFERP (glyph->object)) | ||
| 1319 | abort (); | ||
| 1320 | pos = glyph->charpos; | ||
| 1321 | |||
| 1322 | /* Check for mouse-face and help-echo. */ | ||
| 1323 | { | ||
| 1324 | Lisp_Object mouse_face, overlay, position, *overlay_vec; | ||
| 1325 | int noverlays, obegv, ozv; | ||
| 1326 | struct buffer *obuf; | ||
| 1327 | |||
| 1328 | /* If we get an out-of-range value, return now; avoid an error. */ | ||
| 1329 | if (pos > BUF_Z (XBUFFER (w->buffer))) | ||
| 1330 | return; | ||
| 1331 | |||
| 1332 | /* Make the window's buffer temporarily current for | ||
| 1333 | overlays_at and compute_char_face. */ | ||
| 1334 | obuf = current_buffer; | ||
| 1335 | current_buffer = XBUFFER (w->buffer); | ||
| 1336 | obegv = BEGV; | ||
| 1337 | ozv = ZV; | ||
| 1338 | BEGV = BEG; | ||
| 1339 | ZV = Z; | ||
| 1340 | |||
| 1341 | /* Is this char mouse-active or does it have help-echo? */ | ||
| 1342 | XSETINT (position, pos); | ||
| 1343 | |||
| 1344 | /* Put all the overlays we want in a vector in overlay_vec. */ | ||
| 1345 | GET_OVERLAYS_AT (pos, overlay_vec, noverlays, NULL, 0); | ||
| 1346 | /* Sort overlays into increasing priority order. */ | ||
| 1347 | noverlays = sort_overlays (overlay_vec, noverlays, w); | ||
| 1348 | |||
| 1349 | /* Check mouse-face highlighting. */ | ||
| 1350 | if (! (EQ (window, dpyinfo->mouse_face_window) | ||
| 1351 | && y >= dpyinfo->mouse_face_beg_row | ||
| 1352 | && y <= dpyinfo->mouse_face_end_row | ||
| 1353 | && (y > dpyinfo->mouse_face_beg_row | ||
| 1354 | || x >= dpyinfo->mouse_face_beg_col) | ||
| 1355 | && (y < dpyinfo->mouse_face_end_row | ||
| 1356 | || x < dpyinfo->mouse_face_end_col | ||
| 1357 | || dpyinfo->mouse_face_past_end))) | ||
| 1358 | { | ||
| 1359 | /* Clear the display of the old active region, if any. */ | ||
| 1360 | clear_mouse_face (dpyinfo); | ||
| 1361 | |||
| 1362 | /* Find highest priority overlay that has a mouse-face prop. */ | ||
| 1363 | overlay = Qnil; | ||
| 1364 | for (i = noverlays - 1; i >= 0; --i) | ||
| 1365 | { | ||
| 1366 | mouse_face = Foverlay_get (overlay_vec[i], Qmouse_face); | ||
| 1367 | if (!NILP (mouse_face)) | ||
| 1368 | { | ||
| 1369 | overlay = overlay_vec[i]; | ||
| 1370 | break; | ||
| 1371 | } | ||
| 1372 | } | ||
| 1373 | |||
| 1374 | /* If no overlay applies, get a text property. */ | ||
| 1375 | if (NILP (overlay)) | ||
| 1376 | mouse_face = Fget_text_property (position, Qmouse_face, | ||
| 1377 | w->buffer); | ||
| 1378 | |||
| 1379 | /* Handle the overlay case. */ | ||
| 1380 | if (! NILP (overlay)) | ||
| 1381 | { | ||
| 1382 | /* Find the range of text around this char that | ||
| 1383 | should be active. */ | ||
| 1384 | Lisp_Object before, after; | ||
| 1385 | EMACS_INT ignore; | ||
| 1386 | |||
| 1387 | before = Foverlay_start (overlay); | ||
| 1388 | after = Foverlay_end (overlay); | ||
| 1389 | /* Record this as the current active region. */ | ||
| 1390 | fast_find_position (w, XFASTINT (before), | ||
| 1391 | &dpyinfo->mouse_face_beg_col, | ||
| 1392 | &dpyinfo->mouse_face_beg_row); | ||
| 1393 | dpyinfo->mouse_face_past_end | ||
| 1394 | = !fast_find_position (w, XFASTINT (after), | ||
| 1395 | &dpyinfo->mouse_face_end_col, | ||
| 1396 | &dpyinfo->mouse_face_end_row); | ||
| 1397 | dpyinfo->mouse_face_window = window; | ||
| 1398 | dpyinfo->mouse_face_face_id | ||
| 1399 | = face_at_buffer_position (w, pos, 0, 0, | ||
| 1400 | &ignore, pos + 1, | ||
| 1401 | !dpyinfo->mouse_face_hidden, | ||
| 1402 | -1); | ||
| 1403 | |||
| 1404 | /* Display it as active. */ | ||
| 1405 | show_mouse_face (dpyinfo, 1); | ||
| 1406 | } | ||
| 1407 | /* Handle the text property case. */ | ||
| 1408 | else if (! NILP (mouse_face)) | ||
| 1409 | { | ||
| 1410 | /* Find the range of text around this char that | ||
| 1411 | should be active. */ | ||
| 1412 | Lisp_Object before, after, beginning, end; | ||
| 1413 | EMACS_INT ignore; | ||
| 1414 | |||
| 1415 | beginning = Fmarker_position (w->start); | ||
| 1416 | XSETINT (end, (BUF_Z (XBUFFER (w->buffer)) | ||
| 1417 | - XFASTINT (w->window_end_pos))); | ||
| 1418 | before | ||
| 1419 | = Fprevious_single_property_change (make_number (pos + 1), | ||
| 1420 | Qmouse_face, | ||
| 1421 | w->buffer, beginning); | ||
| 1422 | after | ||
| 1423 | = Fnext_single_property_change (position, Qmouse_face, | ||
| 1424 | w->buffer, end); | ||
| 1425 | /* Record this as the current active region. */ | ||
| 1426 | fast_find_position (w, XFASTINT (before), | ||
| 1427 | &dpyinfo->mouse_face_beg_col, | ||
| 1428 | &dpyinfo->mouse_face_beg_row); | ||
| 1429 | dpyinfo->mouse_face_past_end | ||
| 1430 | = !fast_find_position (w, XFASTINT (after), | ||
| 1431 | &dpyinfo->mouse_face_end_col, | ||
| 1432 | &dpyinfo->mouse_face_end_row); | ||
| 1433 | dpyinfo->mouse_face_window = window; | ||
| 1434 | dpyinfo->mouse_face_face_id | ||
| 1435 | = face_at_buffer_position (w, pos, 0, 0, | ||
| 1436 | &ignore, pos + 1, | ||
| 1437 | !dpyinfo->mouse_face_hidden, | ||
| 1438 | -1); | ||
| 1439 | |||
| 1440 | /* Display it as active. */ | ||
| 1441 | show_mouse_face (dpyinfo, 1); | ||
| 1442 | } | ||
| 1443 | } | ||
| 1444 | |||
| 1445 | /* Look for a `help-echo' property. */ | ||
| 1446 | { | ||
| 1447 | Lisp_Object help; | ||
| 1448 | |||
| 1449 | /* Check overlays first. */ | ||
| 1450 | help = Qnil; | ||
| 1451 | for (i = noverlays - 1; i >= 0 && NILP (help); --i) | ||
| 1452 | { | ||
| 1453 | overlay = overlay_vec[i]; | ||
| 1454 | help = Foverlay_get (overlay, Qhelp_echo); | ||
| 1455 | } | ||
| 1456 | |||
| 1457 | if (!NILP (help)) | ||
| 1458 | { | ||
| 1459 | help_echo_string = help; | ||
| 1460 | help_echo_window = window; | ||
| 1461 | help_echo_object = overlay; | ||
| 1462 | help_echo_pos = pos; | ||
| 1463 | } | ||
| 1464 | /* Try text properties. */ | ||
| 1465 | else if (NILP (help) | ||
| 1466 | && ((STRINGP (glyph->object) | ||
| 1467 | && glyph->charpos >= 0 | ||
| 1468 | && glyph->charpos < SCHARS (glyph->object)) | ||
| 1469 | || (BUFFERP (glyph->object) | ||
| 1470 | && glyph->charpos >= BEGV | ||
| 1471 | && glyph->charpos < ZV))) | ||
| 1472 | { | ||
| 1473 | help = Fget_text_property (make_number (glyph->charpos), | ||
| 1474 | Qhelp_echo, glyph->object); | ||
| 1475 | if (!NILP (help)) | ||
| 1476 | { | ||
| 1477 | help_echo_string = help; | ||
| 1478 | help_echo_window = window; | ||
| 1479 | help_echo_object = glyph->object; | ||
| 1480 | help_echo_pos = glyph->charpos; | ||
| 1481 | } | ||
| 1482 | } | ||
| 1483 | } | ||
| 1484 | |||
| 1485 | BEGV = obegv; | ||
| 1486 | ZV = ozv; | ||
| 1487 | current_buffer = obuf; | ||
| 1488 | } | ||
| 1489 | } | 1016 | } |
| 1490 | } | 1017 | } |
| 1491 | 1018 | ||
| @@ -1769,9 +1296,9 @@ IT_frame_up_to_date (struct frame *f) | |||
| 1769 | { | 1296 | { |
| 1770 | BLOCK_INPUT; | 1297 | BLOCK_INPUT; |
| 1771 | if (dpyinfo->mouse_face_mouse_frame) | 1298 | if (dpyinfo->mouse_face_mouse_frame) |
| 1772 | IT_note_mouse_highlight (dpyinfo->mouse_face_mouse_frame, | 1299 | note_mouse_highlight (dpyinfo->mouse_face_mouse_frame, |
| 1773 | dpyinfo->mouse_face_mouse_x, | 1300 | dpyinfo->mouse_face_mouse_x, |
| 1774 | dpyinfo->mouse_face_mouse_y); | 1301 | dpyinfo->mouse_face_mouse_y); |
| 1775 | dpyinfo->mouse_face_deferred_gc = 0; | 1302 | dpyinfo->mouse_face_deferred_gc = 0; |
| 1776 | UNBLOCK_INPUT; | 1303 | UNBLOCK_INPUT; |
| 1777 | } | 1304 | } |
| @@ -3192,8 +2719,7 @@ dos_rawgetc (void) | |||
| 3192 | previous_help_echo_string = help_echo_string; | 2719 | previous_help_echo_string = help_echo_string; |
| 3193 | help_echo_string = help_echo_object = help_echo_window = Qnil; | 2720 | help_echo_string = help_echo_object = help_echo_window = Qnil; |
| 3194 | help_echo_pos = -1; | 2721 | help_echo_pos = -1; |
| 3195 | IT_note_mouse_highlight (SELECTED_FRAME(), | 2722 | note_mouse_highlight (SELECTED_FRAME(), mouse_last_x, mouse_last_y); |
| 3196 | mouse_last_x, mouse_last_y); | ||
| 3197 | /* If the contents of the global variable help_echo has | 2723 | /* If the contents of the global variable help_echo has |
| 3198 | changed, generate a HELP_EVENT. */ | 2724 | changed, generate a HELP_EVENT. */ |
| 3199 | if (!NILP (help_echo_string) || !NILP (previous_help_echo_string)) | 2725 | if (!NILP (help_echo_string) || !NILP (previous_help_echo_string)) |