summaryrefslogtreecommitdiff
path: root/news/tin/patches/patch-aj
blob: d1df7c1f793226ebc4eecd62e36fe3c153603efd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
$NetBSD: patch-aj,v 1.1 2009/10/22 22:01:26 wiz Exp $

--- src/prompt.c.orig	2009-01-23 16:10:39.000000000 +0100
+++ src/prompt.c
@@ -44,6 +44,7 @@
 
 
 static char *prompt_slk_message;	/* prompt message for prompt_slk_redraw */
+static char *prompt_yn_message;
 
 /*
  * Local prototypes
@@ -163,7 +164,7 @@ prompt_yn(
 {
 	char *keyprompt;
 	char keyno[MAXKEYLEN], keyyes[MAXKEYLEN];
-	int keyyes_len = 0, keyno_len = 0, maxlen;
+	int keyyes_len = 0, keyno_len = 0, maxlen, prompt_len;
 	t_function func;
 #if defined (MULTIBYTE_ABLE) && !defined(NO_LOCALE)
 	wint_t yes, no, prompt_ch, ch;
@@ -194,21 +195,17 @@ prompt_yn(
 	keyno_len = (int) strlen(keyno);
 #endif /* MULTIBYTE_ABLE && !NO_LOCALE */
 	maxlen = MAX(keyyes_len, keyno_len);
+	prompt_len = (int) strlen(prompt) + keyyes_len + keyno_len + maxlen + 6;
+	prompt_yn_message = my_malloc(prompt_len + 1);
+
+	input_context = cPromptYN;
 
 	do {
 		prompt_ch = (default_answer ? yes : no);
 		keyprompt = (default_answer ? keyyes : keyno);
 
-		if (!cmd_line) {
-			MoveCursor(cLINES, 0);
-			CleartoEOLN();
-		}
-		my_printf("%s (%s/%s) %-*s", prompt, keyyes, keyno, maxlen, keyprompt);
-		if (!cmd_line)
-			cursoron();
-		my_flush();
-		if (!cmd_line)
-			MoveCursor(cLINES, (int) strlen(prompt) + keyyes_len + keyno_len + 5);
+		snprintf(prompt_yn_message, prompt_len, "%s (%s/%s) %-*s", prompt, keyyes, keyno, maxlen, keyprompt);
+		prompt_yn_redraw();
 
 #if defined (MULTIBYTE_ABLE) && !defined(NO_LOCALE)
 		if (((ch = ReadWch()) == '\n') || (ch == '\r'))
@@ -248,6 +245,9 @@ prompt_yn(
 		func = key_to_func(ch, prompt_keys);
 	} while (func == NOT_ASSIGNED);
 
+	input_context = cNone;
+	FreeAndNull(prompt_yn_message);
+
 	if (!cmd_line) {
 		clear_message();
 		my_flush();
@@ -256,6 +256,24 @@ prompt_yn(
 }
 
 
+/* (Re)draws the prompt message for prompt_yn() */
+void
+prompt_yn_redraw(
+	void)
+{
+	if (!cmd_line) {
+		MoveCursor(cLINES, 0);
+		CleartoEOLN();
+	}
+	my_printf("%s", prompt_yn_message);
+	if (!cmd_line)
+		cursoron();
+	my_flush();
+	if (!cmd_line)
+		MoveCursor(cLINES, (int) strlen(prompt_yn_message) -1);
+}
+
+
 /*
  * help_text is displayed near the bottom of the screen.
  * var is an index into a list containing size elements.
@@ -745,11 +763,14 @@ prompt_continue(
 	void)
 {
 	int ch;
+	int save_signal_context = signal_context;
 
 #ifdef USE_CURSES
 	cmd_line = TRUE;
 #endif /* USE_CURSES */
 	info_message(_(txt_return_key));
+	signal_context = cMain;
+	input_context = cPromptCONT;
 
 	switch ((ch = ReadCh())) {
 		case ESC:
@@ -763,6 +784,10 @@ prompt_continue(
 			break;
 	}
 
+	input_context = cNone;
+	signal_context = save_signal_context;
+	my_fputc('\n', stdout);
+
 #ifdef USE_CURSES
 	cmd_line = FALSE;
 	my_retouch();