1shell_patterns=0    # expression type
2
3# The macros are:
4#
5# %c The cursor column position number. For edit menu only.
6# %i The indent of blank space, equal the cursor column
7#    position. For edit menu only.
8# %y The syntax type of current file. For edit menu only.
9# %b The block file name.
10# %f The current file name.
11# %n Only the current file name without extension.
12# %x The extension of current file name.
13# %d The current directory name.
14# %F The current file in the unselected panel.
15# %D The directory name of the unselected panel.
16# %t The currently tagged files.
17# %T The tagged files in the unselected panel.
18# %u and %U Similar to the %t and %T macros, but in
19#    addition the files are untagged. You can use this macro
20#    only once per menu file entry or extension file entry,
21#    because next time there will be no tagged files.
22# %s and %S The selected files: The tagged files if
23#    there are any. Otherwise the current file.
24#
25# %% The % character
26#
27# %{some text} Prompt for the substitution. An input box
28#    is shown and the text inside the braces is used as a
29#    prompt. The macro is substituted by the text typed by the
30#    user. The user can press ESC or F10 to cancel. This macro
31#    doesn't work on the command line yet.
32
33#----------------------- Begin [perl] language template -----------------------
34+ y Perl\ Program | f \.pl$
351       Author description header
36        unset LANG
37        unset LANGUAGE
38        LC_ALL=
39        MY_UID="`id | sed 's/^.*uid=\([^(]*\).*$/\1/'`"
40        AUTHOR="`awk -F: '$3 == '$MY_UID' {print $5}' /etc/passwd`"
41        cat >>%b <<EOF
42        #----------------------------------------------------------------------
43        # Description:
44        # Author: $AUTHOR <$REPLYTO>
45        # Created at: `date`
46        # Computer: `uname -n`
47        # System: `uname -sr` on `uname -m`
48        #
49        # Copyright (c) `date +%%Y` $AUTHOR  All rights reserved.
50        #
51        #----------------------------------------------------------------------
52        # Configure section:
53
54        #----------------------------------------------------------------------
55        #
56        # main()
57
58        EOF
59
60+ y Perl\ Program | f \.pl$
612       while ()
62        cat <<EOF > %b
63        %iwhile() {
64        %i}
65        EOF
66
67+ y Perl\ Program | f \.pl$
683       for ()
69        cat <<EOF > %b
70        %ifor ($i =  ; $i <  ; $i++) {
71        %i}
72        EOF
73
74+ y Perl\ Program | f \.pl$
754       foreach ()
76        cat <<EOF > %b
77        %iforeach ($ ) {
78        %i}
79        EOF
80
81+ y Perl\ Program | f \.pl$
825       if ()
83        cat <<EOF > %b
84        %iif () {
85        %i}
86        EOF
87
88+ y Perl\ Program | f \.pl$
896       if () else
90        cat <<EOF > %b
91        %iif () {
92        %i} else {
93        %i}
94        EOF
95
96+ y Perl\ Program | f \.pl$
977       if () elsif ()
98        cat <<EOF > %b
99        %iif () {
100        %i} elsif () {
101        %i}
102        EOF
103
104+ y Perl\ Program | f \.pl$
1058       substr ()
106        echo "%i$ = substr(\$str, \$off, \$cnt);" >%b
107
108+ y Perl\ Program | f \.pl$
1099       opendir ()
110        cat <<EOF > %b
111        %iopendir(DIR, \$dir) || die("\$0: can't open \$dir\n");
112        EOF
113
114+ y Perl\ Program | f \.pl$
115a       sub ()
116        NAME=%{ Enter name of subroutine: }
117        cat <<EOF > %b
118        sub
119        $NAME ()
120        {
121        } # end of $NAME()
122        EOF
123#----------------------- End [perl] language template -------------------------
124
125#---------------------- Begin [shell] language template -----------------------
126+ y Shell\ Script | f \.sh$
1271       Author description header
128        unset LANG
129        unset LANGUAGE
130        LC_ALL=
131        MY_UID="`id | sed 's/^.*uid=\([^(]*\).*$/\1/'`"
132        AUTHOR="`awk -F: '$3 == '$MY_UID' {print $5}' /etc/passwd`"
133        cat >>%b <<EOF
134        #----------------------------------------------------------------------
135        # Description:
136        # Author: $AUTHOR <$REPLYTO>
137        # Created at: `date`
138        # Computer: `uname -n`
139        # System: `uname -sr` on `uname -m`
140        #
141        # Copyright (c) `date +%%Y` $AUTHOR  All rights reserved.
142        #
143        #----------------------------------------------------------------------
144        # Configure section:
145
146        #----------------------------------------------------------------------
147        #
148        # main()
149
150        EOF
151
152+ y Shell\ Script | f \.sh$
1533       for
154        cat <<EOF > %b
155        %ifor i in \$
156        %ido
157        %idone
158        EOF
159
160+ y Shell\ Script | f \.sh$
1614       while
162        cat <<EOF > %b
163        %iwhile
164        %ido
165        %idone
166        EOF
167
168+ y Shell\ Script | f \.sh$
1695       if [] then else
170        cat <<EOF >> %b
171        %iif [ ];then
172        %ielse
173        %ifi
174        EOF
175
176+ y Shell\ Script | f \.sh$
1776       case
178        NUMBER=%{ Enter number elements of case:}
179        cat <<EOF > %b
180        %icase "\$" in
181        EOF
182        while [ "$NUMBER" -gt 0 ]
183        do
184        cat <<EOF >> %b
185        %i)
186        %i    ;;
187        EOF
188        let NUMBER=$NUMBER-1
189        done
190        cat <<EOF >> %b
191        %i*)
192        %iesac
193        EOF
194
195+ y Shell\ Script | f \.sh$
1967       function
197        NAME=%{ Enter name of function:}
198        cat <<EOF >> %b
199        $NAME() {
200        } # end of $NAME()
201        EOF
202
203+ y Shell\ Script | f \.sh$
2048       select of bash
205        cat <<EOF >> %b
206        %iselect i in \$l
207        %ido
208        %i    if [ -n "\$i" ];then
209        %i       break
210        %i    else
211        %i       continue
212        %i    fi
213        %idone
214        EOF
215
216#----------------------- End [shell] language template ------------------------
217
218#------------------------- Begin [c] language template ------------------------
219+ f \.h$ | f \.c$ | f \.cc$
2201       Author description header
221        unset LANG
222        unset LANGUAGE
223        LC_ALL=
224        MY_UID="`id | sed 's/^.*uid=\([^(]*\).*$/\1/'`"
225        AUTHOR="`awk -F: '$3 == '$MY_UID' {print $5}' /etc/passwd`"
226        cat >> %b <<EOF
227        /********************************************************************
228        * Description:
229        * Author: $AUTHOR <$REPLYTO>
230        * Created at: `date`
231        * Computer: `uname -n`
232        * System: `uname -sr` on `uname -m`
233        *
234        * Copyright (c) `date +%%Y` $AUTHOR  All rights reserved.
235        *
236        ********************************************************************/
237        EOF
238
239+ f \.h$ | f \.c$ | f \.cc$
2402       GPL description header
241        cat >>%b <<EOF
242        /*
243        *  This program is free software: you can redistribute it and/or modify
244        *  it under the terms of the GNU General Public License as published by
245        *  the Free Software Foundation, either version 3 of the License, or
246        *  (at your option) any later version.
247        *
248        *  This program is distributed in the hope that it will be useful,
249        *  but WITHOUT ANY WARRANTY; without even the implied warranty of
250        *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
251        *  GNU General Public License for more details.
252        *
253        *  You should have received a copy of the GNU General Public License
254        *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
255        */
256        EOF
257
258+ f \.c$ | f \.cc$
2593       if ()
260        cat <<EOF > %b
261        %iif () {
262        %i}
263        EOF
264
265+ f \.c$ | f \.cc$
2664       if () else
267        cat <<EOF > %b
268        %iif () {
269        %i} else {
270        %i}
271        EOF
272
273+ f \.c$ | f \.cc$
2745       if () else if ()
275        cat <<EOF > %b
276        %iif ( ) {
277        %i} else if ( ) {
278        %i}
279        EOF
280
281+ f \.c$ | f \.cc$
2826       switch ()
283        NUMBER=%{ Enter number elements of switch:}
284        echo "%iswitch () {" >%b
285        while [ "$NUMBER" -gt 0 ]
286        do
287            echo "%icase '':" >>%b
288            echo "%i      break;" >>%b
289            let NUMBER=$NUMBER-1
290        done
291        echo "%i      default:" >>%b
292        echo "%i}" >>%b
293
294+ f \.c$ | f \.cc$
2957       for ()
296        cat <<EOF > %b
297        %ifor (i =  ; i <  ; i++) {
298        %i}
299        EOF
300
301+ f \.c$ | f \.cc$
3028       while ()
303        cat <<EOF > %b
304        %iwhile () {
305        %i}
306        EOF
307
308+ f \.c$ | f \.cc$
3099       do {} while ()
310        cat <<EOF > %b
311        %ido {
312        %i} while ()
313        EOF
314
315+ f \.c$ | f \.cc$
316a       array
317        cat <<EOF > %b
318        %ichar const x[] = {
319        %i, ,
320        %i};
321        EOF
322
323+ f \.c$ | f \.cc$
324b       enum
325        cat <<EOF > %b
326        %ienum x {
327        %i, ,
328        %i};
329        EOF
330
331+ f \.c$ | f \.cc$
332c       struct
333        cat <<EOF > %b
334        %istruct ? {
335        %i;
336        %i};
337        EOF
338
339+ f \.c$ | f \.cc$
340d       union
341        cat <<EOF > %b
342        %iunion ? {
343        %i;
344        %i};
345        EOF
346
347+ f \.c$ | f \.cc$
348e       typedef struct
349        cat <<EOF > %b
350        %itypedef struct {
351        %i;
352        %i} ?;
353        EOF
354
355+ f \.c$ | f \.cc$
356f       function
357        NAME=%{ Enter name of function:}
358        cat <<EOF >> %b
359        $NAME()
360        {
361        } /* end of $NAME() */
362        EOF
363
364+ f \.c$ | f \.h$ | f \.cc$
365g       #include
366        INC=%{ Enter include name: }
367        if [ -r "$INC" ];then
368            echo \#include \"$INC\" >%b
369        else
370            echo \#include \<$INC\> >%b
371        fi
372
373+ f \.c$ | f \.h$ | f \.cc$
374d       #define
375        echo "#define " >%b
376
377+ f \.c$ | f \.h$ | f \.cc$
378d       #ifdef
379        cat <<EOF > %b
380        #ifdef
381        #else
382        #endif
383        EOF
384
385+ f \.c$ | f \.h$ | f \.cc$
386...............................................................................
387
388+ f \.c$ | f \.h$ | f \.cc$
389h       View all *.h into current directory
390        cat *.h |less
391
392+ f \.c$ | f \.cc$
393d       Run gdb for current file
394        [ -x "./%n" ] && gdb ./%n
395
396= f \.c$ | f \.cc$
397+ f \.c$ | f \.cc$
398c       Compile, link and run the current .c file
399        export CFLAGS="-g -Wall -O2"
400        make || make %n || cc $CFLAGS -o %n %f
401        [ -r "%n" ] && (echo "*** press any key for run... ***"; read)
402        [ -x "%n" ] && ./%n
403        (echo -ne "\n--- Press any key for return to edit. ---"; read)
404
405+ f \.c$ | f \.h$
406t       Indent `C' formatter
407        indent -kr -pcs %b 1>/dev/null 2> %e
408
409#--------------------- End [c/c++] language template --------------------------
410
411#------------------------- Begin unknown template -----------------------------
412+ y unknown & t r
413s       #! /bin/sh
414        echo "#! /bin/sh" >%b
415
416+ y unknown & t r
417p       #! /usr/bin/perl
418        echo "#! /usr/bin/perl" >%b
419
420+ y unknown & t r
421a       Author description header
422        unset LANG
423        unset LANGUAGE
424        LC_ALL=
425        MY_UID="`id | sed 's/^.*uid=\([^(]*\).*$/\1/'`"
426        AUTHOR="`awk -F: '$3 == '$MY_UID' {print $5}' /etc/passwd`"
427        cat >>%b <<EOF
428        ----------------------------------------------------------------------
429        Description:
430        Author: $AUTHOR <$REPLYTO>
431        Created at: `date`
432        Computer: `uname -n`
433        System: `uname -sr` on `uname -m`
434
435        Copyright (c) `date +%%Y` $AUTHOR  All rights reserved.
436        ----------------------------------------------------------------------
437
438        EOF
439#--------------------------- End unknown template -----------------------------
440
441-------------------------------------------------------------------------------
442
443#----------------------- Begin common section ---------------------------------
444S       Sort selection
445        TMPFILE=`mktemp ${MC_TMPDIR:-/tmp}/up.XXXXXX` || exit 1
446        cat %b > $TMPFILE
447        cat $TMPFILE| sort >%b
448        rm -f $TMPFILE
449
450I       Insert `Changelog' string
451        DATE="`date +%%Y-%%m-%%d`"
452        MY_UID="`id | sed 's/^.*uid=\([^(]*\).*$/\1/'`"
453        AUTHOR="`awk -F: '$3 == '$MY_UID' {print $5}' /etc/passwd`"
454        EMAIL="<$REPLYTO>"
455        echo "$DATE  $AUTHOR  $EMAIL" >%b
456
457s       Invoke `shell'
458        sh
459
460m       view `man'
461        MAN=%{Enter name of man:}
462        %view{ascii,nroff} MANROFFOPT='@MAN_FLAGS@' MAN_KEEP_FORMATTING=1 man -P cat $MAN
463
464i       Insert output of command to cursor
465        CMD=%{ Enter command: }
466        eval $CMD > %b
467
468o       Open bash to next free console
469        open -s -- /bin/bash
470
471u       Upper case selection
472        TMPFILE=`mktemp ${MC_TMPDIR:-/tmp}/up.XXXXXX` || exit 1
473        cat %b > $TMPFILE
474        sed 's/\(.*\)/\U\1/' $TMPFILE >%b
475        rm -f $TMPFILE
476
477l       Lower case selection
478        TMPFILE=`mktemp ${MC_TMPDIR:-/tmp}/up.XXXXXX` || exit 1
479        cat %b > $TMPFILE
480        sed 's/\(.*\)/\L\1/' $TMPFILE >%b
481        rm -f $TMPFILE
482
483#-------------------------- End of common section -----------------------------
484