~ubuntu-branches/ubuntu/lucid/newt/lucid

« back to all changes in this revision

Viewing changes to debian/patches/45_textbox.patch

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson
  • Date: 2005-03-22 12:44:37 UTC
  • mfrom: (2.1.1 sarge)
  • Revision ID: james.westby@ubuntu.com-20050322124437-nuhl0pqjcijjno9z
Tags: 0.51.6-20ubuntu3
Add Xhosa translation (thanks, Adi Attar).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
diff -ruN newt-0.51.6-old/whiptail.c newt-0.51.6/whiptail.c
 
2
--- newt-0.51.6-old/whiptail.c  2004-02-23 11:25:08.000000000 +0000
 
3
+++ newt-0.51.6/whiptail.c      2004-02-23 11:40:15.000000000 +0000
 
4
@@ -15,7 +15,7 @@
 
5
 
 
6
 enum mode { MODE_NONE, MODE_INFOBOX, MODE_MSGBOX, MODE_YESNO, MODE_CHECKLIST,
 
7
                MODE_INPUTBOX, MODE_RADIOLIST, MODE_MENU, MODE_GAUGE ,
 
8
-               MODE_PASSWORDBOX};
 
9
+               MODE_TEXTBOX, MODE_PASSWORDBOX};
 
10
 
 
11
 #define OPT_MSGBOX             1000
 
12
 #define OPT_CHECKLIST          1001
 
13
@@ -26,6 +26,7 @@
 
14
 #define OPT_RADIOLIST          1006
 
15
 #define OPT_GAUGE              1007
 
16
 #define OPT_INFOBOX            1008
 
17
+#define OPT_TEXTBOX            1009
 
18
 #define OPT_PASSWORDBOX                1010
 
19
 
 
20
 static void usage(void) {
 
21
@@ -33,6 +34,29 @@
 
22
     exit(1);
 
23
 }
 
24
 
 
25
+char *
 
26
+readTextFile(const char * filename)
 
27
+{
 
28
+    int fd = open(filename, O_RDONLY, 0);
 
29
+    struct stat s;
 
30
+    char * buf;
 
31
+
 
32
+    if ( fd < 0 || fstat(fd, &s) != 0 ) {
 
33
+       perror(filename);
 
34
+       exit(DLG_ERROR);
 
35
+     }
 
36
+
 
37
+    if ( (buf = malloc(s.st_size)) == 0 )
 
38
+       fprintf(stderr, "%s: too large to display.\n", filename);
 
39
+
 
40
+    if ( read(fd, buf, s.st_size) != s.st_size ) {
 
41
+        perror(filename);
 
42
+        exit(DLG_ERROR);
 
43
+    }
 
44
+   close(fd);
 
45
+   return buf;
 
46
+}
 
47
+
 
48
 int main(int argc, const char ** argv) {
 
49
     enum mode mode = MODE_NONE;
 
50
     poptContext optCon;
 
51
@@ -75,6 +99,7 @@
 
52
            { "scrolltext", '\0', 0, &scrollText, 0 },
 
53
            { "separate-output", '\0', 0, &separateOutput, 0 },
 
54
            { "title", '\0', POPT_ARG_STRING, &title, 0 },
 
55
+           { "textbox", '\0', 0, 0, OPT_TEXTBOX },
 
56
            { "yesno", '\0', 0, 0, OPT_YESNO },
 
57
            { "passwordbox", '\0', 0, 0, OPT_PASSWORDBOX },
 
58
            { 0, 0, 0, 0, 0 } 
 
59
@@ -105,6 +130,11 @@
 
60
            mode = MODE_MSGBOX;
 
61
            break;
 
62
 
 
63
+         case OPT_TEXTBOX:
 
64
+           if (mode != MODE_NONE) usage();
 
65
+           mode = MODE_TEXTBOX;
 
66
+           break;
 
67
+
 
68
          case OPT_PASSWORDBOX:
 
69
            if (mode != MODE_NONE) usage();
 
70
            mode = MODE_PASSWORDBOX;
 
71
@@ -152,6 +182,8 @@
 
72
 
 
73
     if (!(text = poptGetArg(optCon))) usage();
 
74
 
 
75
+    if ( mode == MODE_TEXTBOX ) text = readTextFile(text);
 
76
+
 
77
     if (!(nextArg = poptGetArg(optCon))) usage();
 
78
     height = strtoul(nextArg, &end, 10);
 
79
     if (*end) usage();
 
80
@@ -182,6 +214,7 @@
 
81
 
 
82
     switch (mode) {
 
83
       case MODE_MSGBOX:
 
84
+      case MODE_TEXTBOX:
 
85
        rc = messageBox(text, height, width, MSGBOX_MSG, flags);
 
86
        break;
 
87