Changeset 337
- Timestamp:
- 07/13/07 19:39:56 (1 year ago)
- Files:
-
- trunk/src/cmd4.c (modified) (8 diffs)
- trunk/src/files.c (modified) (2 diffs)
- trunk/src/z-util.c (modified) (1 diff)
- trunk/src/z-util.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/cmd4.c
r293 r337 1958 1958 int wid, hgt; 1959 1959 1960 char shower[80]; 1961 char finder[80]; 1962 1963 1964 /* Wipe finder */ 1965 my_strcpy(finder, "", sizeof(shower)); 1966 1967 /* Wipe shower */ 1968 my_strcpy(shower, "", sizeof(finder)); 1960 char shower[80] = ""; 1961 1969 1962 1970 1963 … … 2008 2001 2009 2002 /* Display matches */ 2010 while ((str = strstr(str, shower)) != NULL)2003 while ((str = my_stristr(str, shower)) != NULL) 2011 2004 { 2012 2005 int len = strlen(shower); 2013 2006 2014 2007 /* Display the match */ 2015 Term_putstr(str-msg, hgt - 3 - j, len, TERM_YELLOW, s hower);2008 Term_putstr(str-msg, hgt - 3 - j, len, TERM_YELLOW, str); 2016 2009 2017 2010 /* Advance */ … … 2021 2014 } 2022 2015 2023 /* Display header XXX XXX XXX */ 2024 prt(format("Message Recall (%d-%d of %d), Offset %d", 2025 i, i + j - 1, n, q), 0, 0); 2016 /* Display header */ 2017 prt(format("Message recall (%d-%d of %d), offset %d", i, i + j - 1, n, q), 0, 0); 2026 2018 2027 2019 /* Display prompt (not very informative) */ 2028 prt("[Press 'p' for older, 'n' for newer, ..., or ESCAPE]", hgt - 1, 0); 2020 if (shower[0]) 2021 prt("[Movement keys to navigate, '-' for next, '=' to find]", hgt - 1, 0); 2022 else 2023 prt("[Movement keys to navigate, '=' to find, or ESCAPE to exit]", hgt - 1, 0); 2024 2029 2025 2030 2026 /* Get a command */ 2031 2027 ke = inkey_ex(); 2032 2028 2029 2033 2030 /* Exit on Escape */ 2034 if (ke.key == ESCAPE) break; 2035 2036 /* Hack -- Save the old index */ 2037 j = i; 2031 if (ke.key == ESCAPE) 2032 { 2033 break; 2034 } 2035 2036 /* Find text */ 2037 else if (ke.key == '=') 2038 { 2039 /* Get the string to find */ 2040 prt("Find: ", hgt - 1, 0); 2041 if (!askfor_aux(shower, sizeof shower, NULL)) continue; 2042 2043 /* Set to find */ 2044 ke.key = '-'; 2045 } 2038 2046 2039 2047 /* Horizontal scroll */ 2040 if (ke.key == '4')2048 else if (ke.key == '4' || ke.key == ARROW_LEFT) 2041 2049 { 2042 2050 /* Scroll left */ … … 2048 2056 2049 2057 /* Horizontal scroll */ 2050 if (ke.key == '6')2058 else if (ke.key == '6'|| ke.key == ARROW_RIGHT) 2051 2059 { 2052 2060 /* Scroll right */ … … 2057 2065 } 2058 2066 2059 /* Hack -- handle show */ 2060 if (ke.key == '=') 2061 { 2062 /* Prompt */ 2063 prt("Show: ", hgt - 1, 0); 2064 2065 /* Get a "shower" string, or continue */ 2066 if (!askfor_aux(shower, sizeof shower, NULL)) continue; 2067 2068 /* Okay */ 2069 continue; 2070 } 2071 2072 /* Hack -- handle find */ 2073 if (ke.key == '/') 2074 { 2075 s16b z; 2076 2077 /* Prompt */ 2078 prt("Find: ", hgt - 1, 0); 2079 2080 /* Get a "finder" string, or continue */ 2081 if (!askfor_aux(finder, sizeof finder, NULL)) continue; 2082 2083 /* Show it */ 2084 my_strcpy(shower, finder, sizeof(shower)); 2085 2086 /* Scan messages */ 2087 for (z = i + 1; z < n; z++) 2088 { 2089 cptr msg = message_str(z); 2090 2091 /* Search for it */ 2092 if (strstr(msg, finder)) 2093 { 2094 /* New location */ 2095 i = z; 2096 2097 /* Done */ 2098 break; 2099 } 2100 } 2067 /* Recall 1 older message */ 2068 else if (ke.key == '8' || ke.key == ARROW_UP) 2069 { 2070 /* Go older if legal */ 2071 if (i + 1 < n) i += 1; 2072 } 2073 2074 /* Recall 1 newer messages */ 2075 else if (ke.key == '2' || ke.key == ARROW_DOWN || ke.key == '\r' || ke.key == '\n') 2076 { 2077 /* Go newer (if able) */ 2078 i = (i >= 1) ? (i - 1) : 0; 2101 2079 } 2102 2080 2103 2081 /* Recall 20 older messages */ 2104 if ((ke.key == 'p') || (ke.key == KTRL('P')) || (ke.key == ' '))2082 else if ((ke.key == 'p') || (ke.key == KTRL('P')) || (ke.key == ' ')) 2105 2083 { 2106 2084 /* Go older if legal */ … … 2108 2086 } 2109 2087 2110 /* Recall 10 older messages */2111 if (ke.key == '+')2112 {2113 /* Go older if legal */2114 if (i + 10 < n) i += 10;2115 }2116 2117 /* Recall 1 older message */2118 if ((ke.key == '8') || (ke.key == '\n') || (ke.key == '\r'))2119 {2120 /* Go older if legal */2121 if (i + 1 < n) i += 1;2122 }2123 2124 2088 /* Recall 20 newer messages */ 2125 if ((ke.key == 'n') || (ke.key == KTRL('N')))2089 else if ((ke.key == 'n') || (ke.key == KTRL('N'))) 2126 2090 { 2127 2091 /* Go newer (if able) */ … … 2129 2093 } 2130 2094 2131 /* Recall 10 newer messages */2132 if (ke.key == '-')2133 {2134 /* Go newer (if able) */2135 i = (i >= 10) ? (i - 10) : 0;2136 }2137 2138 /* Recall 1 newer messages */2139 if (ke.key == '2')2140 {2141 /* Go newer (if able) */2142 i = (i >= 1) ? (i - 1) : 0;2143 }2144 2145 2095 /* Scroll forwards or backwards using mouse clicks */ 2146 if (ke.key == '\xff')2096 else if (ke.key == '\xff') 2147 2097 { 2148 2098 if (ke.index) … … 2161 2111 } 2162 2112 2163 /* Hack -- Error of some kind */ 2164 if (i == j) bell(NULL); 2113 /* Error time */ 2114 else 2115 { 2116 bell(NULL); 2117 } 2118 2119 2120 /* Find the next item */ 2121 if (ke.key == '-' && shower[0]) 2122 { 2123 s16b z; 2124 2125 /* Scan messages */ 2126 for (z = i + 1; z < n; z++) 2127 { 2128 /* Search for it */ 2129 if (my_stristr(message_str(z), shower)) 2130 { 2131 /* New location */ 2132 i = z; 2133 2134 /* Done */ 2135 break; 2136 } 2137 } 2138 } 2165 2139 } 2166 2140 trunk/src/files.c
r288 r337 2375 2375 2376 2376 /* Back up one line */ 2377 if ( (ch == '8') || (ch == '='))2377 if (ch == ARROW_UP || ch == '8') 2378 2378 { 2379 2379 line = line - 1; 2380 }2381 2382 /* Back up one half page */2383 if (ch == '_')2384 {2385 line = line - ((hgt - 4) / 2);2386 2380 } 2387 2381 … … 2399 2393 2400 2394 /* Advance one line */ 2401 if ((ch == '2') || (ch == '\n') || (ch == '\r'))2395 if ((ch == ARROW_DOWN) || (ch == '2') || (ch == '\n') || (ch == '\r')) 2402 2396 { 2403 2397 line = line + 1; 2404 }2405 2406 /* Advance one half page */2407 if (ch == '+')2408 {2409 line = line + ((hgt - 4) / 2);2410 2398 } 2411 2399 trunk/src/z-util.c
r155 r337 82 82 } 83 83 84 /* 85 * An ANSI version of strstr() with case insensitivity. 86 * 87 * In the public domain; found at: 88 * http://c.snippets.org/code/stristr.c 89 */ 90 char *my_stristr(const char *string, const char *pattern) 91 { 92 char *pptr, *sptr, *start; 93 94 for (start = (char *)string; *start != 0; start++) 95 { 96 /* find start of pattern in string */ 97 for ( ; ((*start != 0) && 98 (toupper((unsigned char)*start) != toupper((unsigned char)*pattern))); start++) 99 ; 100 if (*start == 0) 101 return NULL; 102 103 pptr = (char *)pattern; 104 sptr = (char *)start; 105 106 while (toupper((unsigned char)*sptr) == toupper((unsigned char)*pptr)) 107 { 108 sptr++; 109 pptr++; 110 111 /* if end of pattern then pattern was found */ 112 if (*pptr == 0) 113 return (start); 114 } 115 } 116 117 return NULL; 118 } 119 84 120 85 121 /* trunk/src/z-util.h
r155 r337 39 39 extern int my_strnicmp(cptr a, cptr b, int n); 40 40 41 /* Case-insensitive strstr */ 42 extern char *my_stristr(const char *string, const char *pattern); 43 41 44 /* Copy a string */ 42 45 extern size_t my_strcpy(char *buf, const char *src, size_t bufsize);
