comparison src/fns.c @ 6057:b2cc63a56415

(Fy_or_n_p): Use a popup menu if reached via mouse command. (Fyes_or_no_p): Likewise.
author Richard M. Stallman <rms@gnu.org>
date Thu, 24 Feb 1994 08:02:10 +0000
parents e94f93aef529
children 1571be153f56
comparison
equal deleted inserted replaced
6056:afa75a0c15f8 6057:b2cc63a56415
1123 xprompt = prompt; 1123 xprompt = prompt;
1124 GCPRO2 (prompt, xprompt); 1124 GCPRO2 (prompt, xprompt);
1125 1125
1126 while (1) 1126 while (1)
1127 { 1127 {
1128 cursor_in_echo_area = 1; 1128 if (NILP (last_nonmenu_event) || CONSP (last_nonmenu_event))
1129 message ("%s(y or n) ", XSTRING (xprompt)->data); 1129 {
1130 1130 Lisp_Object pane, menu;
1131 obj = read_filtered_event (1, 0, 0); 1131 pane = Fcons (Fcons (build_string ("Yes"), Qt),
1132 cursor_in_echo_area = 0; 1132 Fcons (Fcons (build_string ("No"), Qnil),
1133 /* If we need to quit, quit with cursor_in_echo_area = 0. */ 1133 Qnil));
1134 QUIT; 1134 menu = Fcons (prompt, Fcons (Fcons (prompt, pane), Qnil));
1135 obj = Fx_popup_menu (Qt, menu);
1136 answer = !NILP (obj);
1137 break;
1138 }
1139 else
1140 {
1141 cursor_in_echo_area = 1;
1142 message ("%s(y or n) ", XSTRING (xprompt)->data);
1143
1144 obj = read_filtered_event (1, 0, 0);
1145 cursor_in_echo_area = 0;
1146 /* If we need to quit, quit with cursor_in_echo_area = 0. */
1147 QUIT;
1148 }
1135 1149
1136 key = Fmake_vector (make_number (1), obj); 1150 key = Fmake_vector (make_number (1), obj);
1137 def = Flookup_key (map, key); 1151 def = Flookup_key (map, key);
1138 answer_string = Fsingle_key_description (obj); 1152 answer_string = Fsingle_key_description (obj);
1139 1153
1207 Lisp_Object prompt; 1221 Lisp_Object prompt;
1208 { 1222 {
1209 register Lisp_Object ans; 1223 register Lisp_Object ans;
1210 Lisp_Object args[2]; 1224 Lisp_Object args[2];
1211 struct gcpro gcpro1; 1225 struct gcpro gcpro1;
1226 Lisp_Object menu;
1212 1227
1213 CHECK_STRING (prompt, 0); 1228 CHECK_STRING (prompt, 0);
1229
1230 if (NILP (last_nonmenu_event) || CONSP (last_nonmenu_event))
1231 {
1232 Lisp_Object pane, menu, obj;
1233 pane = Fcons (Fcons (build_string ("Yes"), Qt),
1234 Fcons (Fcons (build_string ("No"), Qnil),
1235 Qnil));
1236 GCPRO1 (pane);
1237 menu = Fcons (prompt, Fcons (Fcons (prompt, pane), Qnil));
1238 obj = Fx_popup_menu (Qt, menu);
1239 if (!NILP (obj))
1240 {
1241 prompt = build_string ("Confirm");
1242 menu = Fcons (prompt, Fcons (Fcons (prompt, pane), Qnil));
1243 obj = Fx_popup_menu (Qt, menu);
1244 }
1245 UNGCPRO;
1246 return obj;
1247 }
1214 1248
1215 args[0] = prompt; 1249 args[0] = prompt;
1216 args[1] = build_string ("(yes or no) "); 1250 args[1] = build_string ("(yes or no) ");
1217 prompt = Fconcat (2, args); 1251 prompt = Fconcat (2, args);
1218 1252
1219 GCPRO1 (prompt); 1253 GCPRO1 (prompt);
1254
1220 while (1) 1255 while (1)
1221 { 1256 {
1222 ans = Fdowncase (Fread_from_minibuffer (prompt, Qnil, Qnil, Qnil, 1257 ans = Fdowncase (Fread_from_minibuffer (prompt, Qnil, Qnil, Qnil,
1223 Qyes_or_no_p_history)); 1258 Qyes_or_no_p_history));
1224 if (XSTRING (ans)->size == 3 && !strcmp (XSTRING (ans)->data, "yes")) 1259 if (XSTRING (ans)->size == 3 && !strcmp (XSTRING (ans)->data, "yes"))