diff options
author | Thomas E. Dickey <dickey@invisible-island.net> | 1999-08-13 13:40:41 -0400 |
---|---|---|
committer | Thomas E. Dickey <dickey@invisible-island.net> | 1999-08-13 13:40:41 -0400 |
commit | fde43024bd6579b609526faf94dcdbcb6f2bc5e1 (patch) | |
tree | 1d4accd9602108b3cc2693d6c0093469274cc332 /src | |
parent | 9c512bbadc47a7de000f53f11a7620d83ca0ddba (diff) | |
download | lynx-snapshots-fde43024bd6579b609526faf94dcdbcb6f2bc5e1.tar.gz |
snapshot of project "lynx", label v2-8-3dev_6
Diffstat (limited to 'src')
-rw-r--r-- | src/GridText.c | 209 | ||||
-rw-r--r-- | src/HTAlert.c | 4 | ||||
-rw-r--r-- | src/HTFWriter.c | 5 | ||||
-rw-r--r-- | src/LYCookie.c | 10 | ||||
-rw-r--r-- | src/LYCookie.h | 4 | ||||
-rw-r--r-- | src/LYDownload.c | 2 | ||||
-rw-r--r-- | src/LYGlobalDefs.h | 8 | ||||
-rw-r--r-- | src/LYHash.h | 3 | ||||
-rw-r--r-- | src/LYMain.c | 70 | ||||
-rw-r--r-- | src/LYMainLoop.c | 308 | ||||
-rw-r--r-- | src/LYReadCFG.c | 4 | ||||
-rw-r--r-- | src/LYStrings.c | 20 | ||||
-rw-r--r-- | src/LYStyle.c | 12 | ||||
-rw-r--r-- | src/LYUtils.c | 12 |
14 files changed, 467 insertions, 204 deletions
diff --git a/src/GridText.c b/src/GridText.c index 54631f8a..1d4092a1 100644 --- a/src/GridText.c +++ b/src/GridText.c @@ -137,6 +137,13 @@ PUBLIC int LYCacheSource = SOURCE_CACHE_NONE; PUBLIC BOOLEAN from_source_cache = FALSE; /* mutable */ #endif +#ifdef USE_SCROLLBAR +PUBLIC int LYsb = FALSE; +PUBLIC int LYsb_arrow = TRUE; +PUBLIC int LYsb_begin = -1; +PUBLIC int LYsb_end = -1; +#endif + #if defined(USE_COLOR_STYLE) #define MAX_STYLES_ON_LINE 64 @@ -298,6 +305,7 @@ static int justified_text_map[MAX_LINE]; /* this is a map - for each index i it tells to which position j=justified_text_map[i] in justified text i-th character is mapped - it's used for anchor positions fixup and for color style's positions adjustment. */ +static BOOL have_raw_nbsps = FALSE; PUBLIC void ht_justify_cleanup NOARGS { @@ -313,6 +321,7 @@ PUBLIC void ht_justify_cleanup NOARGS last_anchor_of_previous_line = NULL; this_line_was_splitted = FALSE; in_DT = FALSE; + have_raw_nbsps = FALSE; } PUBLIC void mark_justify_start_position ARGS1(void*,text) @@ -1239,6 +1248,139 @@ PRIVATE void display_title ARGS1( return; } +/* Output the scrollbar +** --------------------- +*/ +#ifdef USE_SCROLLBAR +PRIVATE void display_scrollbar ARGS1( + HText *, text) +{ + int i; + int h = display_lines - 2 * (LYsb_arrow!=0); /* Height of the scrollbar */ + int off = (LYsb_arrow != 0); /* Start of the scrollbar */ + int top_skip, bot_skip, sh; + + LYsb_begin = LYsb_end = -1; + if (!LYsb || !text || h <= 2 + || (text->Lines + 1) <= display_lines) + return; + + /* Each cell of scrollbar represents text->Lines/h lines of text. */ + /* Always smaller than h */ + sh = (display_lines*h + text->Lines/2)/(text->Lines + 1); + if (sh <= 0) + sh = 1; + if (sh >= h) + sh = h - 1; + + /* Always non-zero if not top, which is text->top_of_screen != 0 . */ + top_skip = (text->top_of_screen * h + text->Lines)/(text->Lines + 1); + if (top_skip >= h) + top_skip = h - 1; + + /* End happens when + (text->Lines + 1 - (text->top_of_screen + display_lines - 1)) + is either 0 or 1. */ + bot_skip = + (text->Lines + 1 - (text->top_of_screen + display_lines - 1) - 1); + if (bot_skip < 0) + bot_skip = 0; + bot_skip = (bot_skip * h + text->Lines)/(text->Lines + 1); + + /* Now make sure the height is always sh unless top_skip==bot_skip==1 */ + if (top_skip + bot_skip + sh != h && !(top_skip == 1 && bot_skip == 1)) { + /* One which is smaller takes precedence. */ + if (top_skip < bot_skip) { + int t = h - top_skip - sh; + + if (t < top_skip) + bot_skip = top_skip; + else + bot_skip = t; + } else { + int t = h - bot_skip - sh; + + if (t < bot_skip) + top_skip = bot_skip; + else + top_skip = t; + } + } + /* Ensure the bar is visible if h >= 3 */ + if (top_skip + bot_skip >= h) + bot_skip = h - top_skip; + if (top_skip + bot_skip == h && h >= 3) { + if (bot_skip > 1) + bot_skip--; + else + top_skip--; + } + LYsb_begin = top_skip; + LYsb_end = h - bot_skip; + + if (LYsb_arrow) { +#ifdef USE_COLOR_STYLE + int s = top_skip ? s_sb_aa : s_sb_naa; + + if (last_colorattr_ptr > 0) { + LynxChangeStyle(s, STACK_ON, 0); + } else { + LynxChangeStyle(s, ABS_ON, 0); + } +#endif /* USE_COLOR_STYLE */ + move(1, LYcols - 1); + addch(ACS_UARROW); +#ifdef USE_COLOR_STYLE + LynxChangeStyle(s, STACK_OFF, 0); +#endif /* USE_COLOR_STYLE */ + } +#ifdef USE_COLOR_STYLE + if (last_colorattr_ptr > 0) { + LynxChangeStyle(s_sb_bg, STACK_ON, 0); + } else { + LynxChangeStyle(s_sb_bg, ABS_ON, 0); + } +#endif /* USE_COLOR_STYLE */ + + for (i=1; i <= h; i++) { +#ifdef USE_COLOR_STYLE + if (i-1 <= top_skip && i > top_skip) + LynxChangeStyle(s_sb_bar, STACK_ON, 0); + if (i-1 <= h - bot_skip && i > h - bot_skip) + LynxChangeStyle(s_sb_bar, STACK_OFF, 0); +#endif /* USE_COLOR_STYLE */ + move(i + off, LYcols - 1); + if (i > top_skip && i <= h - bot_skip) + addch(ACS_BLOCK); + else + addch(ACS_CKBOARD); + } +#ifdef USE_COLOR_STYLE + LynxChangeStyle(s_sb_bg, STACK_OFF, 0); +#endif /* USE_COLOR_STYLE */ + + if (LYsb_arrow) { +#ifdef USE_COLOR_STYLE + int s = bot_skip ? s_sb_aa : s_sb_naa; + + if (last_colorattr_ptr > 0) { + LynxChangeStyle(s, STACK_ON, 0); + } else { + LynxChangeStyle(s, ABS_ON, 0); + } +#endif /* USE_COLOR_STYLE */ + move(h + 2, LYcols - 1); + addch(ACS_DARROW); +#ifdef USE_COLOR_STYLE + LynxChangeStyle(s, STACK_OFF, 0); +#endif /* USE_COLOR_STYLE */ + } + return; +} +#else +#define display_scrollbar(text) /*nothing*/ +#endif /* USE_SCROLLBAR */ + /* Output a page ** ------------- */ @@ -1811,6 +1953,7 @@ PRIVATE void display_page ARGS3( */ addstr("\n Document is empty"); } + display_scrollbar(text); #ifdef DISP_PARTIAL if (display_partial && display_flag && @@ -1825,7 +1968,7 @@ PRIVATE void display_page ARGS3( } #endif /* DISP_PARTIAL */ - if (HTCJK != NOCJK || text->T.output_utf8) { + if (HTCJK != NOCJK) { /* * For non-multibyte curses. */ @@ -2536,23 +2679,23 @@ PRIVATE void split_line ARGS2( continue; } if (text->T.output_utf8 && !isascii(c)) { - int utf_extra = 0; - if ((c & 0xe0) == 0xc0) { - utf_extra = 1; - } else if ((c & 0xf0) == 0xe0) { - utf_extra = 2; - } else if ((c & 0xf8) == 0xf0) { - utf_extra = 3; - } else if ((c & 0xfc) == 0xf8) { - utf_extra = 4; - } else if ((c & 0xfe) == 0xfc) { - utf_extra = 5; - } else - utf_extra = 0; - if ( (int) strlen(jp+1) < utf_extra) - utf_extra = 0; - r->byte_len += utf_extra; - jp += utf_extra; + int utf_extra = 0; + if ((c & 0xe0) == 0xc0) { + utf_extra = 1; + } else if ((c & 0xf0) == 0xe0) { + utf_extra = 2; + } else if ((c & 0xf8) == 0xf0) { + utf_extra = 3; + } else if ((c & 0xfc) == 0xf8) { + utf_extra = 4; + } else if ((c & 0xfe) == 0xfc) { + utf_extra = 5; + } else + utf_extra = 0; + if ( (int) strlen(jp+1) < utf_extra) + utf_extra = 0; + r->byte_len += utf_extra; + jp += utf_extra; } } total_byte_len += r->byte_len; @@ -2577,7 +2720,7 @@ PRIVATE void split_line ARGS2( r_ = spare % (ht_num_runs-1); m = justified_text_map; - for(jp=previous->data,i=0;i<justify_start_position;++i) { + for(jp = previous->data, i = 0; i < justify_start_position; ++i) { *m++ = i; *jdata++ = ( *prevdata == HT_NON_BREAK_SPACE ? ' ' : *prevdata); ++prevdata; @@ -2640,7 +2783,7 @@ PRIVATE void split_line ARGS2( #endif /* we have to fix anchors*/ { - /*a2 is the last anchor on the line preceeding 'previous'*/ + /*a2 is the last anchor on the line preceding 'previous'*/ TextAnchor* a2 = last_anchor_of_previous_line; if (!a2) @@ -2750,7 +2893,7 @@ PRIVATE void split_line ARGS2( char* p; /* it was permitted to justify line, but this function was called - * to end paragraph - we must subsitute HT_NON_BREAK_SPACEs with + * to end paragraph - we must substitute HT_NON_BREAK_SPACEs with * spaces in previous line */ if (line->size) { @@ -2760,9 +2903,22 @@ PRIVATE void split_line ARGS2( for (p=previous->data;*p;++p) if (*p == HT_NON_BREAK_SPACE) *p = ' '; + } else if (have_raw_nbsps) { + /* this is very rare case, that can happen in forms placed in + table cells*/ + int i; + + for (i = 0; i< previous->size; ++i) + if (previous->data[i] == HT_NON_BREAK_SPACE) + previous->data[i] = ' '; + + /*next line won't be justified, so substitute nbsps in it too */ + for (i = 0; i< line->size; ++i) + if (line->data[i] == HT_NON_BREAK_SPACE) + line->data[i] = ' '; } - /* HT_NON_BREAK_SPACEs were subsituted with spaces in + /* else HT_NON_BREAK_SPACEs were substituted with spaces in HText_appendCharacter */ { /* keep maintaining 'last_anchor_of_previous_line' */ @@ -2779,12 +2935,12 @@ PRIVATE void split_line ARGS2( last_anchor_of_previous_line = a2, a2 = a2->next); } } - /* cleanup */ can_justify_this_line = TRUE; justify_start_position = 0; this_line_was_splitted = FALSE; -#endif + have_raw_nbsps = FALSE; +#endif /* EXP_JUSTIFY_ELTS */ } /* split_line */ @@ -3434,6 +3590,11 @@ check_IgnoreExcess: #endif ) ch = ' '; +#ifdef EXP_JUSTIFY_ELTS + else + have_raw_nbsps = TRUE; +#endif + /* we leave raw HT_NON_BREAK_SPACE otherwise (we'll substitute it later) */ if (ch & 0x80) diff --git a/src/HTAlert.c b/src/HTAlert.c index 2200a58a..908e52c5 100644 --- a/src/HTAlert.c +++ b/src/HTAlert.c @@ -22,7 +22,7 @@ #include <LYLeaks.h> -#if _WIN_CC +#if defined(WIN_EX) && defined(UNUSED_CODE) #include <HTParse.h> #endif @@ -110,7 +110,7 @@ PUBLIC void HTUserMsg2 ARGS2( } } -#ifdef WIN_EX /* 1997/10/28 (Tue) 17:19:43 */ +#if defined(WIN_EX) && defined(UNUSED_CODE) /* 1997/10/28 (Tue) 17:19:43 */ #define MAX_LEN 512 diff --git a/src/HTFWriter.c b/src/HTFWriter.c index 68d4b1de..14edbb2a 100644 --- a/src/HTFWriter.c +++ b/src/HTFWriter.c @@ -13,8 +13,11 @@ #include <HTFWriter.h> #include <HTSaveToFile.h> -#if _WIN_CC +#if WIN_EX #include <HTParse.h> +#endif + +#if _WIN_CC extern int exec_command(char * cmd, int wait_flag); /* xsystem.c */ #endif diff --git a/src/LYCookie.c b/src/LYCookie.c index ea5bd4d3..d1717004 100644 --- a/src/LYCookie.c +++ b/src/LYCookie.c @@ -611,8 +611,8 @@ PRIVATE void store_cookie ARGS3( ** include in a Cookie: request header. - AK & FM */ PRIVATE char * scan_cookie_sublist ARGS6( - CONST char *, hostname, - CONST char *, path, + char *, hostname, + char *, path, int, port, HTList *, sublist, char *, header, @@ -630,7 +630,7 @@ PRIVATE char * scan_cookie_sublist ARGS6( next = hl->next; if ((co) && /* speed-up host_matches() and limit trace output */ - (LYstrstr((char *)hostname, co->domain) != NULL)) + (LYstrstr(hostname, co->domain) != NULL)) { CTRACE(tfp, "Checking cookie %p %s=%s\n", hl, @@ -1952,8 +1952,8 @@ PUBLIC void LYSetCookie ARGS3( ** if needed. - AK & FM */ PUBLIC char * LYCookie ARGS4( - CONST char *, hostname, - CONST char *, path, + char *, hostname, + char *, path, int, port, BOOL, secure) { diff --git a/src/LYCookie.h b/src/LYCookie.h index 5e599191..7767003a 100644 --- a/src/LYCookie.h +++ b/src/LYCookie.h @@ -32,8 +32,8 @@ extern void LYSetCookie PARAMS(( CONST char * SetCookie2, CONST char * address)); extern char *LYCookie PARAMS(( - CONST char * hostname, - CONST char * partialpath, + char * hostname, + char * partialpath, int port, BOOL secure)); extern void LYStoreCookies PARAMS(( diff --git a/src/LYDownload.c b/src/LYDownload.c index 78b1a4cb..7501d886 100644 --- a/src/LYDownload.c +++ b/src/LYDownload.c @@ -248,7 +248,7 @@ check_recall: /* * See if we can write to it. */ - CTRACE(tfp, "LYDownload: filename is %s", buffer); + CTRACE(tfp, "LYDownload: filename is %s\n", buffer); if ((fp = fopen(buffer, "w")) != NULL) { fclose(fp); diff --git a/src/LYGlobalDefs.h b/src/LYGlobalDefs.h index 5f3c0da9..22a828dd 100644 --- a/src/LYGlobalDefs.h +++ b/src/LYGlobalDefs.h @@ -442,4 +442,12 @@ extern void cygwin_conv_to_full_posix_path(char *dos, char *posix); extern int setmode(int handle, int amode); #endif +#ifdef USE_SCROLLBAR +/* GridText.c */ +extern int LYsb; +extern int LYsb_arrow; +extern int LYsb_begin; +extern int LYsb_end; +#endif + #endif /* LYGLOBALDEFS_H */ diff --git a/src/LYHash.h b/src/LYHash.h index 7945051c..793eebbe 100644 --- a/src/LYHash.h +++ b/src/LYHash.h @@ -45,6 +45,9 @@ extern int hash_table[CSHASHSIZE]; /* 32K should be big enough */ extern int s_alink, s_a, s_status, s_label, s_value, s_high, s_normal, s_alert, s_title, +#ifdef USE_SCROLLBAR + s_sb_bar, s_sb_bg, s_sb_aa, s_sb_naa, +#endif s_whereis; #define CACHEW 128 #define CACHEH 64 diff --git a/src/LYMain.c b/src/LYMain.c index b2a82c6b..83e3cbcf 100644 --- a/src/LYMain.c +++ b/src/LYMain.c @@ -92,6 +92,10 @@ PUBLIC char *syslog_txt = NULL; /* syslog arb text for session */ PUBLIC char *LYCSwingPath = NULL; #endif /* VMS */ +#if HAVE_CUSERID && !defined(_XOPEN_SOURCE) +extern char *cuserid(); /* workaround for Redhat 6.0 */ +#endif + #ifdef DIRED_SUPPORT PUBLIC BOOLEAN lynx_edit_mode = FALSE; PUBLIC BOOLEAN no_dired_support = FALSE; @@ -197,7 +201,7 @@ PUBLIC BOOLEAN telnet_ok = TRUE; PUBLIC BOOLEAN news_ok = TRUE; #endif PUBLIC BOOLEAN rlogin_ok = TRUE; -PUBLIC BOOLEAN long_url_ok = TRUE; +PUBLIC BOOLEAN long_url_ok = FALSE; PUBLIC BOOLEAN ftp_ok = TRUE; PUBLIC BOOLEAN system_editor = FALSE; @@ -276,6 +280,9 @@ PUBLIC BOOLEAN local_host_only = FALSE; PUBLIC BOOLEAN override_no_download = FALSE; PUBLIC BOOLEAN show_dotfiles = FALSE; /* From rcfile if no_dotfiles is false */ PUBLIC BOOLEAN LYforce_HTML_mode = FALSE; +#ifdef __DJGPP__ +PUBLIC BOOLEAN watt_debug = FALSE; /* WATT-32 debugging */ +#endif /* __DJGPP__ */ #ifdef WIN_EX #undef SYSTEM_MAIL @@ -728,7 +735,7 @@ PRIVATE int argcmp ARGS2( { if (str[0] == '-' && str[1] == '-' ) ++str; #if !OPTNAME_ALLOW_DASHES - return strcmp(str,what); + return strcmp(str, what); #else ++str; ++what; /*skip leading dash in both strings*/ { @@ -779,7 +786,7 @@ PUBLIC int main ARGS2( int err; WORD wVerReq; - wVerReq = MAKEWORD(1,1); + wVerReq = MAKEWORD(1, 1); err = WSAStartup(wVerReq, &WSAData); if (err != 0) @@ -823,10 +830,7 @@ PUBLIC int main ARGS2( init_ctrl_break[0] = 1; } atexit(reset_break); - dbug_init(); - sock_init(); - __system_flags = 0x501D; -#endif +#endif /* __DJGPP__ */ /* * To prevent corrupting binary data on DOS, MS-WINDOWS or OS/2 @@ -1078,7 +1082,8 @@ PUBLIC int main ARGS2( socks_flag = FALSE; #endif /* SOCKS */ } else if (argncmp(argv[i], "-cfg") == 0) { - if ((cp=strchr(argv[i],'=')) != NULL) + if (((cp = strchr(argv[i], '=')) != NULL) + || ((cp = strchr(argv[i], ':')) != NULL)) StrAllocCopy(lynx_cfg_file, cp+1); else { StrAllocCopy(lynx_cfg_file, argv[i+1]); @@ -1087,7 +1092,7 @@ PUBLIC int main ARGS2( #if defined(USE_HASH) } else if (argncmp(argv[i], "-lss") == 0) { - if ((cp=strchr(argv[i],'=')) != NULL) + if ((cp=strchr(argv[i], '=')) != NULL) StrAllocCopy(lynx_lss_file, cp+1); else { StrAllocCopy(lynx_lss_file, argv[i+1]); @@ -1152,7 +1157,7 @@ PUBLIC int main ARGS2( socks_flag = FALSE; #endif /* SOCKS */ } else if (argncmp(buf, "-cfg") == 0) { - if ((cp = strchr(buf,'=')) != NULL) { + if ((cp = strchr(buf, '=')) != NULL) { StrAllocCopy(lynx_cfg_file, cp+1); } else { cp = LYSkipNonBlanks(buf); @@ -1162,7 +1167,7 @@ PUBLIC int main ARGS2( } #if defined(USE_HASH) } else if (argncmp(buf, "-lss") == 0) { - if ((cp = strchr(buf,'=')) != NULL) { + if ((cp = strchr(buf, '=')) != NULL) { StrAllocCopy(lynx_lss_file, cp+1); } else { cp = LYSkipNonBlanks(buf); @@ -1287,7 +1292,7 @@ PUBLIC int main ARGS2( * a TRACE log NOW. - FM */ if (!LYValidate && !LYRestricted && - strlen((char *)ANONYMOUS_USER) > 0 && + strlen(ANONYMOUS_USER) > 0 && #if defined (VMS) || defined (NOUSERS) !strcasecomp(((char *)getenv("USER")==NULL ? " " : getenv("USER")), ANONYMOUS_USER) @@ -1817,7 +1822,7 @@ PUBLIC int main ARGS2( * Block Control-Z suspending if requested. - FM */ if (no_suspend) - (void) signal(SIGTSTP,SIG_IGN); + (void) signal(SIGTSTP, SIG_IGN); #endif /* SIGTSTP */ /* @@ -1904,7 +1909,7 @@ PUBLIC int main ARGS2( ftp_ok = !no_inside_ftp && !no_outside_ftp && ftp_ok; rlogin_ok = !no_inside_rlogin && !no_outside_rlogin && rlogin_ok; #else - CTRACE(tfp,"LYMain: User in Local domain\n"); + CTRACE(tfp, "LYMain: User in Local domain\n"); telnet_ok = !no_inside_telnet && telnet_ok; #ifndef DISABLE_NEWS news_ok = !no_inside_news && news_ok; @@ -1913,7 +1918,7 @@ PUBLIC int main ARGS2( rlogin_ok = !no_inside_rlogin && rlogin_ok; #endif /* !HAVE_UTMP || VMS */ } else { - CTRACE(tfp,"LYMain: User in REMOTE domain\n"); + CTRACE(tfp, "LYMain: User in REMOTE domain\n"); telnet_ok = !no_outside_telnet && telnet_ok; #ifndef DISABLE_NEWS news_ok = !no_outside_news && news_ok; @@ -1939,6 +1944,20 @@ PUBLIC int main ARGS2( StrAllocCopy(MBM_A_subdescript[0], MULTIBOOKMARKS_DEFAULT); } +#if defined (__DJGPP__) + if (watt_debug) + dbug_init(); + sock_init(); + + __system_flags = + __system_emulate_chdir | /* handle `cd' internally */ + __system_handle_null_commands | /* ignore cmds with no effect */ + __system_allow_long_cmds | /* handle commands > 126 chars */ + __system_use_shell | /* use $SHELL if set */ + __system_allow_multiple_cmds | /* allow `cmd1; cmd2; ...' */ + __system_redirect; /* redirect internally */ +#endif /* __DJGPP__ */ + /* * Here's where we do all the work. */ @@ -1964,7 +1983,7 @@ PUBLIC int main ARGS2( !crawl && /* For -crawl it has already been done! */ (keypad_mode == LINKS_ARE_NUMBERED || keypad_mode == LINKS_AND_FIELDS_ARE_NUMBERED)) - printlist(stdout,FALSE); + printlist(stdout, FALSE); #ifdef EXP_PERSISTENT_COOKIES /* * We want to save cookies picked up when in immediate dump @@ -3242,12 +3261,22 @@ with the PREV_DOC command or from the History List" "rlogin", UNSET_ARG, &rlogin_ok, "disable rlogins" ), +#ifdef USE_SCROLLBAR + PARSE_SET( + "scrollbar", TOGGLE_ARG, &LYsb, + "toggles showing scrollbar (requires color styles)" + ), + PARSE_SET( + "scrollbar_arrow", TOGGLE_ARG, &LYsb_arrow, + "toggles showing arrows at ends of the scrollbar" + ), +#endif PARSE_FUN( "selective", FUNCTION_ARG, selective_fun, "require .www_browsable files to browse directories" ), PARSE_SET( - "short_url", UNSET_ARG, &long_url_ok, + "short_url", SET_ARG, &long_url_ok, "enables examination of beginning and end of long URL in status line" ), #ifdef SH_EX @@ -3351,6 +3380,12 @@ treated '>' as a co-terminator for double-quotes and tags" "vikeys", SET_ARG, &vi_keys, "enable vi-like key movement" ), +#ifdef __DJGPP__ + PARSE_SET( + "wdebug", TOGGLE_ARG, &watt_debug, + "enables Waterloo tcp/ip packet debug. Prints to watt debugfile" + ), +#endif /* __DJGPP__ */ PARSE_FUN( "width", NEED_FUNCTION_ARG, width_fun, "=NUMBER\nscreen width for formatting of dumps (default is 80)" @@ -3485,6 +3520,7 @@ static int arg_eqs_parse ARGS3( if (*a == 0) { switch (*b) { case '=': + case ':': *c = b + 1; return 1; case '-': /* FALLTHRU */ diff --git a/src/LYMainLoop.c b/src/LYMainLoop.c index 3de3a451..040159a7 100644 --- a/src/LYMainLoop.c +++ b/src/LYMainLoop.c @@ -68,32 +68,30 @@ PUBLIC char *str_kcode(HTkcode code) static char buff[8]; if (current_char_set == CHARSET_TRANS) { - p = "THRU"; + p = "THRU"; + } else if (!LYRawMode) { + p = "RAW"; } else { - if (!LYRawMode) { - p = "RAW"; - } else { - switch (code) { - case NOKANJI: - p = "AUTO"; - break; + switch (code) { + case NOKANJI: + p = "AUTO"; + break; - case EUC: - p = "EUC+"; - break; + case EUC: + p = "EUC+"; + break; - case SJIS: - p = "SJIS"; - break; + case SJIS: + p = "SJIS"; + break; - case JIS: - p = " JIS"; - break; + case JIS: + p = " JIS"; + break; - default: - p = " ???"; - break; - } + default: + p = " ???"; + break; } } @@ -121,7 +119,10 @@ PRIVATE void set_ws_title(char * str) } #endif -/* 1998/10/30 (Fri) 10:06:47 */ +#endif /* CJK_EX */ + + +#ifdef SH_EX /* 1998/10/30 (Fri) 10:06:47 */ #define NOT_EQU 1 @@ -400,6 +401,93 @@ PRIVATE int find_link_near_col ARGS2( } /* + * This is a special feature to traverse every http link derived from startfile + * and check for errors or create crawl output files. Only URL's that begin + * with "traversal_host" are searched - this keeps the search from crossing to + * other servers (a feature, not a bug!). + */ +PRIVATE int DoTraversal ARGS2( + int, c, + BOOLEAN *, crawl_ok) +{ + BOOLEAN rlink_rejected = FALSE; + BOOLEAN rlink_exists; + BOOLEAN rlink_allowed; + + rlink_exists = (nlinks > 0 && + links[curdoc.link].type != WWW_FORM_LINK_TYPE && + links[curdoc.link].lname != NULL); + + if (rlink_exists) { + rlink_rejected = lookup_reject(links[curdoc.link].lname); + if (!rlink_rejected && + traversal_host && + links[curdoc.link].lname) { + if (strncmp(links[curdoc.link].lname, "LYNXIMGMAP:", 11)) { + rlink_allowed = !strncmp(traversal_host, + links[curdoc.link].lname, + strlen(traversal_host)); + } else { + rlink_allowed = !strncmp(traversal_host, + links[curdoc.link].lname + 11, + strlen(traversal_host)); + } + } else { + rlink_allowed = FALSE; + } + } else { + rlink_allowed = FALSE; + } + if (rlink_exists && rlink_allowed) { + if (lookup(links[curdoc.link].lname)) { + if (more_links || + (curdoc.link > -1 && curdoc.link < nlinks -1)) + c= DNARROW; + else { + if (STREQ(curdoc.title,"Entry into main screen") || + (nhist <= 0 )) { + if (!dump_output_immediately) { + cleanup(); + exit_immediately(-1); + } + return(-1); + } + c = LTARROW; + } + } else { + StrAllocCopy(traversal_link_to_add, + links[curdoc.link].lname); + if (strncmp(traversal_link_to_add, "LYNXIMGMAP:", 11)) + *crawl_ok = TRUE; + c = RTARROW; + } + } else { /* no good right link, so only down and left arrow ok*/ + if (rlink_exists /* && !rlink_rejected */) + /* uncomment in previous line to avoid duplicates - kw */ + add_to_reject_list(links[curdoc.link].lname); + if (more_links || + (curdoc.link > -1 && curdoc.link < nlinks-1)) + c = DNARROW; + else { + /* + * curdoc.title doesn't always work, so + * bail out if the history list is empty. + */ + if (STREQ(curdoc.title,"Entry into main screen") || + (nhist <= 0 )) { + if (!dump_output_immediately) { + cleanup(); + exit_immediately(-1); + } + return(-1); + } + c = LTARROW; + } + } /* right link not NULL or link to another site*/ + return c; +} + +/* * Here's where we do all the work. * mainloop is basically just a big switch dependent on the users input. * I have tried to offload most of the work done here to procedures to @@ -434,8 +522,6 @@ int mainloop NOARGS BOOLEAN force_load = FALSE; BOOLEAN try_internal = FALSE; BOOLEAN crawl_ok = FALSE; - BOOLEAN rlink_exists; - BOOLEAN rlink_allowed; BOOLEAN vi_keys_flag = vi_keys; BOOLEAN emacs_keys_flag = emacs_keys; BOOLEAN trace_mode_flag = FALSE; @@ -826,11 +912,11 @@ try_again: mail_owner = owner_address + 7; } /* - * Email a bad link message to the owner of - * the document, or to ALERTMAIL if defined, - * but NOT to lynx-dev (it is rejected in - * mailmsg). - FM, kw - */ + * Email a bad link message to the owner of + * the document, or to ALERTMAIL if defined, + * but NOT to lynx-dev (it is rejected in + * mailmsg). - FM, kw + */ #ifndef ALERTMAIL if (mail_owner) #endif @@ -1604,7 +1690,7 @@ try_again: } -#if defined(SH_EX) /* 1997/10/08 (Wed) 14:52:06 */ +#if defined(CJK_EX) /* 1997/10/08 (Wed) 14:52:06 */ if (nlinks > 0) { char *p = "LYNX (unknown link type)"; @@ -1670,7 +1756,7 @@ try_again: set_ws_title(HTUnEscape(temp_buff)); } } -#endif /* SH_EX */ +#endif /* CJK_EX */ /* * Report unread or new mail, if appropriate. @@ -1934,77 +2020,8 @@ new_keyboard_input: * back through the getch() loop. */ if (traversal) { - /* - * This is a special feature to traverse every http link - * derived from startfile and check for errors or create - * crawl output files. Only URL's that begin with - * "traversal_host" are searched - this keeps the search - * from crossing to other servers (a feature, not a bug!). - */ - BOOLEAN rlink_rejected = FALSE; - rlink_exists = (nlinks > 0 && - links[curdoc.link].type != WWW_FORM_LINK_TYPE && - links[curdoc.link].lname != NULL); - if (rlink_exists) { - rlink_rejected = lookup_reject(links[curdoc.link].lname); - rlink_allowed = - (!rlink_rejected && - traversal_host && links[curdoc.link].lname && - !strncmp(traversal_host, - (strncmp(links[curdoc.link].lname, - "LYNXIMGMAP:", 11) - ? - links[curdoc.link].lname : (links[curdoc.link].lname + 11)), - strlen(traversal_host))); - } else { - rlink_allowed = FALSE; - } - if (rlink_exists && rlink_allowed) { - if (lookup(links[curdoc.link].lname)) { - if (more_links || - (curdoc.link > -1 && curdoc.link < nlinks -1)) - c= DNARROW; - else { - if (STREQ(curdoc.title,"Entry into main screen") || - (nhist <= 0 )) { - if (!dump_output_immediately) { - cleanup(); - exit_immediately(-1); - } - return(-1); - } - c = LTARROW; - } - } else { - StrAllocCopy(traversal_link_to_add, - links[curdoc.link].lname); - if (strncmp(traversal_link_to_add, "LYNXIMGMAP:", 11)) - crawl_ok = TRUE; - c = RTARROW; - } - } else { /* no good right link, so only down and left arrow ok*/ - if (rlink_exists /* && !rlink_rejected */) - /* uncomment in previous line to avoid duplicates - kw */ - add_to_reject_list(links[curdoc.link].lname); - if (more_links || - (curdoc.link > -1 && curdoc.link < nlinks-1)) - c = DNARROW; - else { - /* - * curdoc.title doesn't always work, so - * bail out if the history list is empty. - */ - if (STREQ(curdoc.title,"Entry into main screen") || - (nhist <= 0 )) { - if (!dump_output_immediately) { - cleanup(); - exit_immediately(-1); - } - return(-1); - } - c = LTARROW; - } - } /* right link not NULL or link to another site*/ + if ((c = DoTraversal(c, &crawl_ok)) < 0) + return (-1); } /* traversal */ #ifdef WIN_EX @@ -2314,22 +2331,22 @@ new_cmd: /* #ifdef SOURCE_CACHE if (HTreparse_document()) { - /* - * These normally get cleaned up after getfile() returns; - * since we're not calling getfile(), we have to clean them - * up ourselves. -dsb - */ - HTOutputFormat = WWW_PRESENT; + /* + * These normally get cleaned up after getfile() returns; + * since we're not calling getfile(), we have to clean them + * up ourselves. -dsb + */ + HTOutputFormat = WWW_PRESENT; #ifdef USE_PSRC - if (psrc_view) - HTMark_asSource(); - psrc_view = FALSE; + if (psrc_view) + HTMark_asSource(); + psrc_view = FALSE; #endif - FREE(ownerS_address); /* not used with source_cache */ - LYUCPopAssumed(); /* probably a right place here */ - HTMLSetCharacterHandling(current_char_set); /* restore now */ + FREE(ownerS_address); /* not used with source_cache */ + LYUCPopAssumed(); /* probably a right place here */ + HTMLSetCharacterHandling(current_char_set); /* restore now */ - break; + break; } #endif @@ -2726,7 +2743,7 @@ new_cmd: /* } break; -#if defined(SH_EX) && defined(DOSPATH) /*1997/12/22 (Mon) 09:28:56 */ +#if defined(WIN_EX) && defined(SH_EX) /*1997/12/22 (Mon) 09:28:56 */ case LYK_TO_CLIPBOARD: /* ^S */ { if (put_clip(links[curdoc.link].lname) == 0) { @@ -6883,7 +6900,7 @@ PRIVATE void status_link ARGS3( BOOLEAN, show_indx) { #define MAX_STATUS (LYcols - 2) -#define MIN_STATUS MAX_STATUS / 2 +#define MIN_STATUS 0 char format[MAX_LINE]; int prefix; int length; @@ -6903,41 +6920,40 @@ PRIVATE void status_link ARGS3( if ((length + prefix > MAX_STATUS) && long_url_ok) { char *buf = NULL; - int j; - int k; - int cut_position; - int link_position; + int cut_from_pos; + int cut_to_pos; + int n; StrAllocCopy(buf, curlink_name); - - /* Scan to find the final leaf of the url, put it in 'k'. - * Ignore trailing '/'. + /* + * Scan to find the final leaf of the URL. + * Ignore trailing '/'. */ - for (j = length; (j > 0) && buf[j] != '/'; --j) - ; - if (j >= (length - 3)) { - for (k = j - 1; (k > 0) && buf[k] != '/'; --k) - ; - } else { - k = j; - } - - /* We assume that one can recognize the link from at least - * MIN_STATUS characters. + for (cut_to_pos = length - 2; + (cut_to_pos > 0) && (buf[cut_to_pos] != '/'); + cut_to_pos--) + ; + /* + * Jump back to the next leaf to remove. */ - cut_position = MAX_STATUS - prefix - (length - k); - if (cut_position < MIN_STATUS){ - cut_position = MIN_STATUS; - link_position = length - MIN_STATUS + 3; - } else { - link_position = k; + for (cut_from_pos = cut_to_pos - 4; + (cut_from_pos > 0) && ((buf[cut_from_pos] != '/') + || (prefix + cut_from_pos + 4 + (length - cut_to_pos) >= MAX_STATUS)); + cut_from_pos--) + ; + /* + * Replace some leaves to '...', if possible, and put the + * final leaf at the end. We assume that one can recognize + * the link from at least MIN_STATUS characters. + */ + if (cut_from_pos > MIN_STATUS) { + for (n = 1; n <= 3; n++) + buf[cut_from_pos + n] = '.'; + for (n = 0; cut_to_pos + n <= length; n++) + buf[cut_from_pos + 4 + n] = buf[cut_to_pos + n]; } - for (j = 0; j < 3; j++) - buf[cut_position++] = '_'; - if (cut_position < link_position) - while ((buf[cut_position++] = buf[link_position++]) != 0) - ; _user_message(format, buf); + CTRACE(tfp,"lastline = %s\n",buf); /* don't forget to erase me */ FREE(buf); } else { /* show (possibly truncated) url */ _user_message(format, curlink_name); diff --git a/src/LYReadCFG.c b/src/LYReadCFG.c index 3a765e6c..53784dae 100644 --- a/src/LYReadCFG.c +++ b/src/LYReadCFG.c @@ -1211,6 +1211,10 @@ static Config_Type Config_Table [] = #endif /* NO_RULES */ PARSE_STR("save_space", CONF_STR, &lynx_save_space), PARSE_SET("scan_for_buried_news_refs", CONF_BOOL, &scan_for_buried_news_references), +#ifdef USE_SCROLLBAR + PARSE_SET("scrollbar", CONF_BOOL, &LYsb), + PARSE_SET("scrollbar_arrow", CONF_BOOL, &LYsb_arrow), +#endif PARSE_SET("seek_frag_area_in_cur", CONF_BOOL, &LYSeekFragAREAinCur), PARSE_SET("seek_frag_map_in_cur", CONF_BOOL, &LYSeekFragMAPinCur), PARSE_SET("set_cookies", CONF_BOOL, &LYSetCookies), diff --git a/src/LYStrings.c b/src/LYStrings.c index db33de8f..1d7976bf 100644 --- a/src/LYStrings.c +++ b/src/LYStrings.c @@ -305,6 +305,22 @@ PRIVATE int set_clicked_link ARGS4( if (x < left) c = LTARROW; else if (x > right) c = '\b'; else c = PGUP; +#ifdef USE_SCROLLBAR + } else if (x == LYcols - 1 && LYsb && LYsb_begin >= 0) { + int h = display_lines - 2*(LYsb_arrow != 0); + + mouse_link = -2; + y -= 1 + (LYsb_arrow != 0); + if (y < 0) + return INSERT_KEY; + if (y >= h) + return REMOVE_KEY; + if (y < LYsb_begin) + return PGUP; + if (y >= LYsb_end) + return PGDOWN; + mouse_link = -1; /* No action in edit fields */ +#endif } else { int mouse_err = 4, /* subjctv-dist better than this for approx stuff */ cur_err; @@ -1837,6 +1853,10 @@ re_read: c = END_KEY; else if (c == PGUP) c = HOME; + else if (c == REMOVE_KEY) + c = END_KEY; + else if (c == INSERT_KEY) + c = HOME; else if (c == RTARROW) c = END_KEY; else if (c == LTARROW && code == FOR_PROMPT) diff --git a/src/LYStyle.c b/src/LYStyle.c index 75bfeccb..4943ca7f 100644 --- a/src/LYStyle.c +++ b/src/LYStyle.c @@ -1,6 +1,6 @@ /* character level styles for Lynx * (c) 1996 Rob Partington -- donated to the Lyncei (if they want it :-) - * $Id: LYStyle.c,v 1.23 1999/07/30 16:06:54 tom Exp $ + * @Id: LYStyle.c 1.31 Fri, 13 Aug 1999 07:27:27 -0600 dickey @ */ #include <HTUtils.h> #include <HTML.h> @@ -64,6 +64,10 @@ static char *Mono_Strings[7] = PUBLIC int s_alink = NOSTYLE, s_a = NOSTYLE, s_status = NOSTYLE, s_label = NOSTYLE, s_value = NOSTYLE, s_high = NOSTYLE, s_normal = NOSTYLE, s_alert = NOSTYLE, s_title = NOSTYLE, +#ifdef USE_SCROLLBAR + s_sb_bar = NOSTYLE, s_sb_bg = NOSTYLE, + s_sb_aa = NOSTYLE, s_sb_naa = NOSTYLE, +#endif s_whereis= NOSTYLE; /* start somewhere safe */ @@ -360,6 +364,12 @@ PUBLIC void style_initialiseHashTable NOARGS s_status = hash_code("status"); s_alert = hash_code("alert"); s_title = hash_code("title"); +#ifdef USE_SCROLLBAR + s_sb_bar = hash_code("scroll.bar"); + s_sb_bg = hash_code("scroll.back"); + s_sb_aa = hash_code("scroll.arrow"); + s_sb_naa = hash_code("scroll.noarrow"); +#endif } /* because curses isn't started when we parse the config file, we diff --git a/src/LYUtils.c b/src/LYUtils.c index 9e5b4548..f15839a3 100644 --- a/src/LYUtils.c +++ b/src/LYUtils.c @@ -3159,7 +3159,7 @@ PUBLIC void LYExtSignal ARGS2( * much state as possible. * Second arg is where to save or restore from. * Third arg to_dfl specifies what to do: - * 1 Save current state in where, set handling to SIG_DFL + * 1 Save current state in where, set handling to SIG_DFL * 0 Restore current state to previously saved one in where * * Currently only used for SIGTSTP without SLANG, to prevent (n)curses @@ -7052,7 +7052,7 @@ PUBLIC int LYCopyFile ARGS2( char *, src, char *, dst) { -#ifdef SH_EX +#if defined(DOSPATH) /* thanks to Hiroyuki Senshu */ #define BUF_SIZE 1024 @@ -7065,8 +7065,10 @@ PUBLIC int LYCopyFile ARGS2( return EOF; fout = fopen(dst, "wb"); - if (fout == NULL) + if (fout == NULL) { + fclose(fin); /* it was opened, yes? */ return EOF; + } while ((len = fread(buff, 1, BUF_SIZE, fin)) > 0) { fwrite(buff, 1, len, fout); @@ -7281,7 +7283,7 @@ PUBLIC char *LYSysShell NOARGS { char *shell = 0; #ifdef DOSPATH -#ifdef SH_EX +#ifdef WIN_EX shell = getenv("SHELL"); if (shell) { if (access(shell, 0) != 0) @@ -7301,7 +7303,7 @@ PUBLIC char *LYSysShell NOARGS if (shell == NULL) { shell = "command.com"; } -#endif /* SH_EX */ +#endif /* WIN_EX */ #else #ifdef __EMX__ if (getenv("SHELL") != NULL) { |