* Deactivate some color code from Pico (as standalone editor) until
[alpine.git] / alpine / newuser.c
blob39f87008570a08a20c1c69cebf3da72df631a32e
1 #if !defined(lint) && !defined(DOS)
2 static char rcsid[] = "$Id: newuser.c 1266 2009-07-14 18:39:12Z hubert@u.washington.edu $";
3 #endif
5 /*
6 * ========================================================================
7 * Copyright 2013-2017 Eduardo Chappa
8 * Copyright 2006-2008 University of Washington
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
14 * http://www.apache.org/licenses/LICENSE-2.0
16 * ========================================================================
20 #include "headers.h"
21 #include "newuser.h"
22 #include "mailview.h"
23 #include "help.h"
24 #include "keymenu.h"
25 #include "osdep/print.h"
26 #include "../pith/state.h"
27 #include "../pith/conf.h"
28 #include "../pith/msgno.h"
29 #include "../pith/filter.h"
30 #include "../pith/init.h"
31 #include "../pith/margin.h"
35 * Internal prototypes
37 int nuov_processor(int, MSGNO_S *, SCROLL_S *);
41 * Display a new user or new version message.
43 void
44 new_user_or_version(struct pine *ps)
46 char **shown_text;
47 int cmd = MC_NONE;
48 int first_time_alpine_user = 0;
49 char *error = NULL;
50 HelpType text;
51 SCROLL_S sargs;
52 STORE_S *store;
53 HANDLE_S *handles = NULL, *htmp;
54 gf_io_t pc;
55 char *vers = ps->vers_internal;
57 first_time_alpine_user = (ps->first_time_user
58 || (ps->pine_pre_vers
59 && isdigit((unsigned char) ps->pine_pre_vers[0])
60 && ps->pine_pre_vers[1] == '.'
61 && isdigit((unsigned char) vers[0])
62 && vers[1] == '.'
63 && ps->pine_pre_vers[0] < '5' /* it was Pine */
64 && vers[0] >= '5')); /* Alpine */
66 text = ps->first_time_user ? new_user_greeting :
67 first_time_alpine_user ? new_alpine_user_greeting : new_version_greeting;
69 shown_text = text;
72 * Set this if the major revision number
73 * (the first after the dot) has changed.
75 ps->phone_home = (first_time_alpine_user
76 || (ps->pine_pre_vers
77 && isdigit((unsigned char) ps->pine_pre_vers[0])
78 && ps->pine_pre_vers[1] == '.'
79 && isdigit((unsigned char) ps->pine_pre_vers[2])
80 && isdigit((unsigned char) vers[0])
81 && vers[1] == '.'
82 && isdigit((unsigned char) vers[2])
83 && strncmp(ps->pine_pre_vers, vers, 3) < 0));
86 * At this point, shown_text is a charstarstar with html
87 * Turn it into a charstar with digested html
89 do{
90 init_helper_getc(shown_text);
91 init_handles(&handles);
93 if((store = so_get(CharStar, NULL, EDIT_ACCESS)) != NULL){
94 gf_set_so_writec(&pc, store);
95 gf_filter_init();
97 gf_link_filter(gf_html2plain,
98 gf_html2plain_opt("x-alpine-help:",
99 ps->ttyo->screen_cols, non_messageview_margin(),
100 &handles, NULL, GFHP_LOCAL_HANDLES));
102 error = gf_pipe(helper_getc, pc);
104 gf_clear_so_writec(store);
106 if(!error){
107 struct key_menu km;
108 struct key keys[24];
110 for(htmp = handles; htmp; htmp = htmp->next)
111 if(htmp->type == URL
112 && htmp->h.url.path
113 && (htmp->h.url.path[0] == 'x'
114 || htmp->h.url.path[0] == '#'))
115 htmp->force_display = 1;
117 /* This is mostly here to get the curses variables
118 * for line and column in sync with where the
119 * cursor is on the screen. This gets warped when
120 * the composer is called because it does it's own
121 * stuff
123 ClearScreen();
125 memset(&sargs, 0, sizeof(SCROLL_S));
126 sargs.text.text = so_text(store);
127 sargs.text.src = CharStar;
128 sargs.text.desc = "greeting text";
129 sargs.text.handles = handles;
130 sargs.bar.title = "GREETING TEXT";
131 sargs.bar.style = TextPercent;
132 sargs.proc.tool = nuov_processor;
133 sargs.help.text = main_menu_tx;
134 sargs.help.title = "MAIN PINE HELP";
135 sargs.resize_exit = 1;
136 sargs.keys.menu = &km;
137 km = nuov_keymenu;
138 km.keys = keys;
139 memcpy(&keys[0], nuov_keymenu.keys,
140 (nuov_keymenu.how_many * 12) * sizeof(struct key));
141 setbitmap(sargs.keys.bitmap);
143 if(ps->phone_home){
144 km.keys[NUOV_EXIT].label = "Exit this greeting";
145 km.keys[NUOV_EXIT].bind.nch = 1;
147 else{
148 km.keys[NUOV_EXIT].label = "[Exit this greeting]";
149 km.keys[NUOV_EXIT].bind.nch = 3;
150 clrbitn(NUOV_VIEW, sargs.keys.bitmap);
153 if(ps->first_time_user)
154 clrbitn(NUOV_RELNOTES, sargs.keys.bitmap);
156 cmd = scrolltool(&sargs);
158 flush_input();
160 if(F_ON(F_BLANK_KEYMENU,ps_global))
161 FOOTER_ROWS(ps_global) = 1;
163 ClearScreen();
166 so_give(&store);
169 free_handles(&handles);
171 while(cmd == MC_RESIZE);
176 nuov_processor(int cmd, MSGNO_S *msgmap, SCROLL_S *sparms)
178 int rv = 0;
180 switch(cmd){
181 /*----------- Print all the help ------------*/
182 case MC_PRINTMSG :
183 if(open_printer(sparms->text.desc) == 0){
184 print_help(sparms->proc.data.p);
185 close_printer();
188 break;
190 case MC_RELNOTES :
191 helper(h_news, "ALPINE RELEASE NOTES", 0);
192 ps_global->mangled_screen = 1;
193 break;
195 case MC_EXIT :
196 rv = 1;
197 break;
199 default :
200 alpine_panic("Unhandled case");
203 return(rv);