1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289
|
#!/usr/bin/awk -f
#
# CAUTION: Only works with GNU awk (gawk)
# If /usr/bin/awk doesn't work, you can call this script by:
# gawk -f typcombine
#
# Typist v2.2 - improved typing tutor program for UNIX systems
# Copyright (C) 1998 Simon Baldwin (simonb@sco.com)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#
# awk script to combine several typ files into a single large one
# modified by Felix Natter <fnatter@gmx.net> on Thu Aug 30 20:49:26 2001:
# - add two menu-items: "more lessons" (Fkey10) and "help"/"manual" (Fkey 11)
# - add ';' after each command to make emacs indentation work
# - add the "(function-key) help" and series descriptions
# Felix Natter on Sun Apr 6 13:28:09 2003:
# - replace "M: UP=_EXIT" with "M: UP=MAINMENU"
# - MORE_LESSONS: add the new kt*.typ lessons
# - generate the M: __SERIESMENU
# Felix Natter on 2011-09-11:
# - update the T: commands for the "more lessons" menu item with the new
# lesson files
BEGIN {
# some initializations
scount = 0;
type = "I";
# use "-" here since that's what you get when you run
# awk against stdin, at least on Linux
cur_filename = "-";
cur_series = "";
# start as always by going to the menu we'll try to build later
printf( "#" );
for ( i = 0; i < 78; i++ )
printf( "=" );
printf( "\n# Combined series file (generated by tools/typcombine!!)\n#" );
for ( i = 0; i < 78; i++ )
printf( "=" );
printf( "\n" );
printf( "G:__SERIESMENU\n" );
printf( "*:__NO_SERIESMENU\n" );
}
#
# look for change of input file on each record
#
FILENAME != cur_filename {
# wrap up the previous series if there is one
if ( cur_filename != "-" ) {
printf( "# End of file %s\n", cur_filename );
printf( "G:__SERIESMENU\n", cur_series );
printf( "#" );
for ( i = 0; i < 78; i++ )
printf( "=" );
printf( "\n" );
}
# find the new series name, and store it
cur_filename = FILENAME;
cur_series = FILENAME;
gsub( /\..*/, "", cur_series );
# we like the series names to be uppercase - I can't help
# but feel that there must be a better way to accomplish
# this, but I can't find it
# TODO: can we use toupper ?
split( "q,w,e,r,t,y,u,i,o,p,a,s,d,f,g,h,j,k,l,z,x,c,v,b,n,m", lc,/,/ );
split( "Q,W,E,R,T,Y,U,I,O,P,A,S,D,F,G,H,J,K,L,Z,X,C,V,B,N,M", uc,/,/ );
for ( i = 1; i <= 26; i++ )
gsub( lc[i], uc[i], cur_series );
# stash the series name
scount++;
series[scount] = cur_series;
# output the header for this series
printf( "#" );
for ( i = 0; i < 78; i++ )
printf( "=" );
printf( "\n" );
printf( "*:__S_%s_SERIES\n", cur_series );
printf( "# Start of file %s\n", cur_filename );
}
#
# print out every line read in
#
{
# print $0;
# in the input-files the menus are top-level (UP=_EXIT); in gtypist.typ
# there is a parent menu (MAINMENU) generated by this script
sub( "M: UP=_EXIT", "M: UP=__SERIESMENU", $0 );
print $0;
}
#
# end of file processing
#
END {
# first finish up the last file's output if there was one
if ( cur_filename != "-" ) {
printf( "# End of file %s\n", cur_filename );
printf( "G:__SERIESMENU\n" );
printf( "#" );
for ( i = 0; i < 78; i++ )
printf( "=" );
printf( "\n" );
}
# TODO:
# - ttde.typ before kt*.de.typ
# - kt*.typ sorted alphabetically, look at manual, look at comment on top for source info
# - about 20 lines per T:
# - if you want to write lessons, see the manual, it's simple!
# -
# build the T: commands for the "more lessons" and "help"/"manual" menu items
printf("*:__MORE_LESSONS\n");
printf("B: More lessons\n");
printf("T:\n");
printf(" :... there are more lessons which can be accessed by starting\n");
printf(" : gtypist with an argument, the name of the file:\n");
printf(" :\n");
printf(" : cs.typ - Czech lessons\n");
printf(" : esp.typ - Spanish lessons\n");
printf(" : ru.typ - Russian lessons\n");
printf(" : ttde.typ - German lessons from tipptrainer 0.6.0\n");
printf(" : ktbg.typ - Bulgarian lessons from KTouch 1.6\n");
printf(" : ktbg_long.typ - Bulgarian lessons (longer) from KTouch 1.6\n");
printf(" : ktde.typ - German lessons I from KTouch 1.6\n");
printf(" : ktde2.typ - German lessons II from KTouch 1.6\n");
printf(" : ktde_neo.typ - German lessons with NEO layout from KTouch 1.6\n");
printf(" : (see http://pebbles.schattenlauf.de/layout.php?language=de\n");
printf(" : ktde_number.typ - German number keypad lessons from KTouch 1.6\n");
printf(" : ktdk.typ - Danish lessons I from KTouch 1.6\n");
printf(" : ktdk2.typ - Danish lessons II from KTouch 1.6\n");
printf(" : ktdvorak.typ - Dvorak lessons from KTouch 1.6\n");
printf(" : (see http://en.wikipedia.org/wiki/Dvorak_Simplified_Keyboard)\n");
printf(" : ktdvorak_es.typ - Spanish Dvorak lessons from KTouch 1.6\n");
printf(" : ktdvorak_abcd.typ - Dvorak lessons (basic) from KTouch 1.6\n");
printf("T:\n");
printf(" :... and even more lessons:\n");
printf(" :\n");
printf(" : kten.typ - English lessons from KTouch 1.6\n");
printf(" : ktes.typ - Spanish lessons from KTouch 1.6\n");
printf(" : ktes_cat.typ - Catalan lessons from KTouch 1.6\n");
printf(" : ktfi.typ - Finnish lessons from KTouch 1.6\n");
printf(" : ktfi_kids.typ - Finnish lessons for kids from KTouch 1.6\n");
printf(" : ktfr.typ - French lessons I from KTouch 1.6\n");
printf(" : ktfr2.typ - French lessons II from KTouch 1.6\n");
printf(" : kthu.typ - Hungarian lessons I from KTouch 1.6\n");
printf(" : kthu_expert.typ - Hungarian lessons II from KTouch 1.6\n");
printf(" : ktit.typ - Italian lessons from KTouch 1.6\n");
printf(" : ktnl.typ - Dutch lessons from KTouch 1.6\n");
printf(" : ktnl_junior.typ - Dutch lessons for kids from KTouch 1.6\n");
printf(" : ktno.typ - Norwegian lessons from KTouch 1.6\n");
printf(" : ktpl.typ - Polish lessons from KTouch 1.6\n");
printf(" : ktru.typ - Russian lessons from KTouch 1.6\n");
printf(" : ktru_long.typ - Russian lessons (longer) from KTouch 1.6\n");
printf(" : ktru_slava.typ - Russian lessons (hand-made) from KTouch 1.6\n");
printf(" : ktsi.typ - Slovenian lessons from KTouch 1.6\n");
printf(" : kttr.typ - Turkish lessons from KTouch 1.6\n");
printf("T:\n");
printf(" :\n");
printf(" : See the comments at the top of each .typ file for more information\n");
printf(" : about the source and the author of the lessons.\n");
printf(" :\n");
printf(" : If you want to write your own lessons, look at the gtypist manual,\n");
printf(" : it's really simple! If you have any question, write to the\n");
printf(" : gtypist mailing list: bug-gtypist@gnu.org\n");
printf(" :\n");
printf("G:__SERIESMENU\n");
printf("*:__HELP\n");
printf("B: Help screen\n");
printf("T:\n");
printf(" :Use the arrow-keys to navigate through the menus.\n");
printf(" :\n");
printf(" :Press ESC to exit, repeat or skip a lesson. If you are half way through a\n");
printf(" :drill, pressing ESC will first reset it (so you will have to press it twice).\n");
printf(" :\n");
printf(" :You can access gtypist's manual either by running \"info gtypist\", or by\n");
printf(" :loading \"gtypist.html\" in your browser. The most recent version of the\n");
printf(" :manual can also be found here:\n");
printf(" : http://www.gnu.org/software/gtypist/doc/\n");
printf(" :\n");
printf(" :If you have comments, questons, suggestions or bug-reports,\n");
printf(" :please write to bug-gtypist@gnu.org.\n");
printf("G:__SERIESMENU\n");
# this limitation is eliminated by the use of M:
# if ( scount > 9)
# exit 1;
# now build a selection menu to get to each series
if ( scount > 0 )
{
printf( "#" );
for ( i = 0; i < 78; i++ )
printf( "=" );
printf( "\n# Series menu\n#" );
for ( i = 0; i < 78; i++ )
printf( "=" );
printf( "\n" );
printf( "*:__SERIESMENU\n" );
# output the menu screen
banner = "Series selection menu";
printf( "B:" );
for ( i = 0; i < ( 66 - length( banner )) / 2; i++ )
printf( " " );
printf( "%s\n", banner );
printf( "M: \"The following %d lesson series ", scount );
if ( scount > 1 )
printf( "are" );
else
printf( "is" );
printf( " available\"\n" );
for ( i = 1; i <= scount; i++ )
{
if (series[i] == "Q")
series_description = "Quick QWERTY course (Q1 - Q5)";
else if (series[i] == "R")
series_description = "Long QWERTY course (R1 - R14)";
else if (series[i] == "T")
series_description = "QWERTY touch typing (T1 - T16)";
else if (series[i] == "V")
series_description = "Yet more QWERTY (V1 - V19)";
else if (series[i] == "U")
series_description = "QWERTY Review (U1 - U13)";
else if (series[i] == "D")
series_description = "Dvorak touch typing (D1 - D14)";
else if (series[i] == "C")
series_description = "Colemak touch typing (C1 - C17)";
else if (series[i] == "M")
series_description = "Typing drills (M1 - M11)";
else if (series[i] == "S")
series_description = "Speed drills (S1 - S4)";
else if (series[i] == "N")
series_description = "Calculator keypad (N1 - N3)";
else # TODO: find sth like "abort"
exit 1;
# output 1 menu-item
printf( " :__S_%s_SERIES \"Series %s %s\"\n",
series[i], series[i], series_description);
# printf( " : Fkey%2d - Series %s %s\n", i,
# series[i], series_description );
}
printf( " :__MORE_LESSONS \"More lessons...\"\n");
printf( " :__HELP \"Help...\"\n");
}
else {
# saw no series; oh well...
printf( "! WARNING: didn't find any series\n" );
printf( "G:__SERIESEXIT\n" );
printf( "*:__SERIESMENU\n" );
printf( "G:__NO_SERIESMENU\n" );
}
# printf( "*:__SERIESEXIT\n" );
printf( "#" );
for ( i = 0; i < 78; i++ )
printf( "=" );
printf( "\n" );
}
# Local Variables:
# compile-command: "(cd ../lessons && gawk -f ../tools/typcombine q.typ r.typ t.typ v.typ u.typ d.typ c.typ m.typ s.typ n.typ > gtypist.typ)"
# truncate-lines: t
# End:
|