Add support for tab-completion when selecting by rule
[alpine.git] / alpine / newuser.c
blob5ab897a5ce60e3bfd05c33f94de978f9221aa2f2
1 /*
2 * ========================================================================
3 * Copyright 2013-2022 Eduardo Chappa
4 * Copyright 2006-2008 University of Washington
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * ========================================================================
16 #include "headers.h"
17 #include "newuser.h"
18 #include "mailview.h"
19 #include "help.h"
20 #include "keymenu.h"
21 #include "osdep/print.h"
22 #include "../pith/state.h"
23 #include "../pith/conf.h"
24 #include "../pith/msgno.h"
25 #include "../pith/filter.h"
26 #include "../pith/init.h"
27 #include "../pith/margin.h"
31 * Internal prototypes
33 int nuov_processor(int, MSGNO_S *, SCROLL_S *);
37 * Display a new user or new version message.
39 void
40 new_user_or_version(struct pine *ps)
42 char **shown_text;
43 int cmd = MC_NONE;
44 int first_time_alpine_user = 0;
45 char *error = NULL;
46 HelpType text;
47 SCROLL_S sargs;
48 STORE_S *store;
49 HANDLE_S *handles = NULL, *htmp;
50 gf_io_t pc;
51 char *vers = ps->vers_internal;
53 first_time_alpine_user = (ps->first_time_user
54 || (ps->pine_pre_vers
55 && isdigit((unsigned char) ps->pine_pre_vers[0])
56 && ps->pine_pre_vers[1] == '.'
57 && isdigit((unsigned char) vers[0])
58 && vers[1] == '.'
59 && ps->pine_pre_vers[0] < '5' /* it was Pine */
60 && vers[0] >= '5')); /* Alpine */
62 text = ps->first_time_user ? new_user_greeting :
63 first_time_alpine_user ? new_alpine_user_greeting : new_version_greeting;
65 shown_text = text;
68 * At this point, shown_text is a charstarstar with html
69 * Turn it into a charstar with digested html
71 do{
72 init_helper_getc(shown_text);
73 init_handles(&handles);
75 if((store = so_get(CharStar, NULL, EDIT_ACCESS)) != NULL){
76 gf_set_so_writec(&pc, store);
77 gf_filter_init();
79 gf_link_filter(gf_html2plain,
80 gf_html2plain_opt("x-alpine-help:",
81 ps->ttyo->screen_cols, non_messageview_margin(),
82 &handles, NULL, GFHP_LOCAL_HANDLES));
84 error = gf_pipe(helper_getc, pc);
86 gf_clear_so_writec(store);
88 if(!error){
89 struct key_menu km;
90 struct key keys[24];
92 for(htmp = handles; htmp; htmp = htmp->next)
93 if(htmp->type == URL
94 && htmp->h.url.path
95 && (htmp->h.url.path[0] == 'x'
96 || htmp->h.url.path[0] == '#'))
97 htmp->force_display = 1;
99 /* This is mostly here to get the curses variables
100 * for line and column in sync with where the
101 * cursor is on the screen. This gets warped when
102 * the composer is called because it does it's own
103 * stuff
105 ClearScreen();
107 memset(&sargs, 0, sizeof(SCROLL_S));
108 sargs.text.text = so_text(store);
109 sargs.text.src = CharStar;
110 sargs.text.desc = "greeting text";
111 sargs.text.handles = handles;
112 sargs.bar.title = "GREETING TEXT";
113 sargs.bar.style = TextPercent;
114 sargs.proc.tool = nuov_processor;
115 sargs.help.text = main_menu_tx;
116 sargs.help.title = "MAIN PINE HELP";
117 sargs.resize_exit = 1;
118 sargs.keys.menu = &km;
119 km = nuov_keymenu;
120 km.keys = keys;
121 memcpy(&keys[0], nuov_keymenu.keys,
122 (nuov_keymenu.how_many * 12) * sizeof(struct key));
123 setbitmap(sargs.keys.bitmap);
125 km.keys[NUOV_EXIT].label = "Exit this greeting";
127 if(ps->first_time_user)
128 clrbitn(NUOV_RELNOTES, sargs.keys.bitmap);
130 cmd = scrolltool(&sargs);
132 flush_input();
134 if(F_ON(F_BLANK_KEYMENU,ps_global))
135 FOOTER_ROWS(ps_global) = 1;
137 ClearScreen();
140 so_give(&store);
143 free_handles(&handles);
145 while(cmd == MC_RESIZE);
150 nuov_processor(int cmd, MSGNO_S *msgmap, SCROLL_S *sparms)
152 int rv = 0;
154 switch(cmd){
155 /*----------- Print all the help ------------*/
156 case MC_PRINTMSG :
157 if(open_printer(sparms->text.desc) == 0){
158 print_help(sparms->proc.data.p);
159 close_printer();
162 break;
164 case MC_RELNOTES :
165 helper(h_news, "ALPINE RELEASE NOTES", 0);
166 ps_global->mangled_screen = 1;
167 break;
169 case MC_EXIT :
170 rv = 1;
171 break;
173 default :
174 alpine_panic("Unhandled case");
177 return(rv);