-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgc3.key
2246 lines (2063 loc) · 50.4 KB
/
gc3.key
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
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
##################################################################
# #
# MS-DOS/UNIX key definition file for Gram's Commander v3.3 #
# #
# Written by Graham Wheeler. Last modified 30-6-94 #
# #
##################################################################
IF_ANY
# Dummy function that just effectively declares some global variables
DeclareGlobals
{
# no globals to declare
}
# Things to do at the end before exiting.
Terminate
{
# We make sure debugging isn't on, otherwise lots of debug
# info will be written upon startup.
$debug = "n"
# unlock the file view
$lock = "0"
# Clear some big vars that we don't need to save
$message = ""
$nameacts = ""
$typeacts = ""
$linebuff = ""
if (access $mytemp "0")
unlink $mytemp
quit
}
# Issue a warning message
warn($msg)
{
write "WARNING: $msg"
beep
}
# Prompt for and get a key press
GetKeyPress
{
local $key;
write "Press a key to return to Gram's Commander..."
read $key 0
}
# Prompt for a response with a message $msg, saving the response in $rsp
# Returns 1 if the response was in the set of characters given by $set,
# or 0 if any other key was pressed.
getAnswer($msg,$rsp,$set)
{
local $myprompt = $msg;
expand $myprompt # we mustn't expand $msg as it is not always
# a variable but sometimes a string literal
write $myprompt
$rsp = ""
if (read $rsp 1 and $rsp in $set) return 1
else return 0
}
getYNanswer($msg,$rsp)
{
local $prompt = "$msg ? (y/n) ";
return getAnswer($prompt,$rsp,"yYnN");
}
# This function is used to check and report that the viewer is on
# for functions that can't be used at such a time.
ViewCheck
{
if ($viewer)
{
warn("Can't do this when file viewer is in use!")
return 0
}
}
# Prompt for and read a command $cmd of up to 80 chars, expand any variables,
# add a pager if the command ends with a pipe, clear the screen if $clear
# is yes, exec the command, get a keypress if $prompt is yes, and
# reread the directories if $rescan is yes.
#
# ExecCmd is used for actions, and for commands after they have been
# processed by ExpandCommand. DoCommand prompts for a command and
# then calls ExpandCommand. The description above thus applies specifically
# to a call to DoCommand, but most of the work is done by the other
# two routines.
ExecCmd($cmd,$rescan,$clear)
{
if ($clear) clear
exec $cmd
if ($rescan) rescan "3"
}
# ExpandCommand
ExpandCommand($com,$reread)
{
local $junk, $exceptions, $prog, $xnow, $cmd = $com, $len, $suf="";
# first expand any vars in the read command...
expand $cmd
$len = length $cmd
makepath $junk $cmd ""
if (matches $cmd "cd " 3)
{
# do it with our own internal cd command
tail -3 $cmd
makepath $junk $cmd ""
cd $junk
rescan "1"
IF_DOS
# if DOS drive descriptor, cd to it. This is a workaround
# for the fact that Borland's access() doesn't work for CD-ROMs, so
# the typeof check below fails...
} else if (matches $len "2" and matches $cmd ":" -1)
{
cd $junk
rescan "1"
IF_ANY
} else if (typeof $junk in {dir,container})
{
cd $junk
rescan "1"
} else {
# We really need arrays here!
if (matches $cmd $sufc1 -1)
{
head -1 $cmd
$cmd = "$pref1 $cmd $suf1"
$suf = $suf1
}
else if (matches $cmd $sufc2 -1)
{
head -1 $cmd
$cmd = "$pref2 $cmd $suf2"
$suf = $suf2
}
else if (matches $cmd $sufc3 -1)
{
head -1 $cmd
$cmd = "$pref3 $cmd $suf3"
$suf = $suf3
}
else if (matches $cmd $sufc4 -1)
{
head -1 $cmd
$cmd = "$pref4 $cmd $suf4"
$suf = $suf4
}
IF_UNIX
# if we are piping the output of commands via tee
# so that we can review the output afterwards, then there
# are some programs we don't want to do this with (essentially
# most interactive programs such as vi, elm, etc). We keep
# a list of these in the rule file. This part of the code
# checks if the current command matches an entry
if ($saveOutput and not "|" in $suf)
{
# Get the actual command
$exceptions = $except
$prog = $cmd
split 1 "#w" $prog $prog # truncate after first whitespc
# now work thru the exception list
while (not matches $exceptions "")
{
$xnow = $exceptions
if (not split 1 ":" $xnow $exceptions) break
strip $xnow
if (matches $prog $xnow) break
}
# if not an exception, add the "| tee" stuff
if (not matches $prog $xnow)
$cmd = "$cmd | tee $mytemp"
}
IF_ANY
ExecCmd($cmd,$reread,$clear)
}
}
DoCommand($start)
{
local $cmd=$start;
write "Command? "
if (read $cmd -80) ExpandCommand($cmd,"y")
}
#############################
# Load the rules file stuff #
#############################
fileErr($name)
{
beep
echo "Cannot open file $name!"
sleep 1
}
# Look for a pager, viewer or editor utility given an entry in the
# rule file. Saves the string to invoke the utility in $invoke.
findUtility($entry, $result, $dummy)
{
local $name, $invoke;
if (not matches $result "") return 0; # Don't use rules if already set
$expand = "n"
if ($entry in "$")
{
if (not matches $entry "")
{
$expand = "y"
$result = $entry
return 1
}
} else
{
$name = $entry
strip $name
$expand = "y"
split 1 "#w" $name $invoke
$expand = "n"
if (inpath $name)
{
if (matches $invoke "") $invoke = $name
$result = $invoke
$expand = "y"
return 1
}
}
$expand = "y"
return 0
}
# Parse a list of entry fields in a rule, applying a command
# to each component field in turn until the command returns
# true for one of them or they have al been done.
ParseAndApply($entry, $cmd, $arg1, $arg2)
{
local $list, $field = "";
# Go through the name pattern action list
$expand = "n"
$list = $entry
while (not matches $list "")
{
$expand = "n"
$field = $list
if (not split 1 $ruleSep $field $list) break
$expand = "y"
if ("$cmd"($field, $arg1, $arg2))
return 1
}
$expand = "y"
if (not matches $field "") # last field
if ("$cmd"($field, $arg1, $arg2))
return 1
return 0
}
loadArea($area, $item, $result) {
local $tmparea = $area;
expand $tmparea
if (findArea $actionfile $tmparea)
if (loadItem $item $result)
{
IF_DEBUG
echo "Set $item to $result"
sleep 1
IF_ANY
}
}
loadCommandArea($area,$cmd,$item,$result)
{
local $junk, $dummy;
$dummy = $item
expand $dummy
if (findArea $actionfile $area and
loadItem $dummy $junk and
ParseAndApply($junk,$cmd,$result,$dummy))
{
echo "Set $dummy to $result"
IF_DEBUG
sleep 1
IF_ANY
}
}
loadTables($fname)
{
local $file, $junk;
makepath $file $codepath $fname
if (not open $file)
{
if (not inpath $fname $file or not open $file)
{
fileErr($file)
return 0
}
}
$actionfile = $file
echo "Loading file $file"
IF_UNIX
loadArea("UNIXExcept", "CantTee", $except)
IF_ANY
loadCommandArea("$OS#Utils","findUtility","Editor",$editor)
loadCommandArea("$OS#Utils","findUtility","Pager",$pager)
loadCommandArea("$OS#Utils","findUtility","Viewer",$viewprog)
loadCommandArea("$OS#Utils","findUtility","Mailer",$mailread)
loadCommandArea("$OS#Utils","findUtility","NewsReader",$newsread)
loadArea("$OS#Actions", "NameActions", $nameacts)
loadArea("$OS#Actions", "TypeActions", $typeacts)
loadrules
}
ApplyProgram($prg, $caller)
{
local $cmd = $prg;
$expand = "n"
strip $prg
$expand = "y"
IF_DEBUG
echo "In applyProgram($prg,$caller)";sleep 1
IF_ANY
# If it ends with a !, we strip it and enter the
# command line editor
if (matches $cmd "!" -1)
{
head -1 $cmd
expand $cmd
DoCommand($cmd)
} else if (matches $cmd "@" -1)
{
# If it ends with a @ it is an internal command
head -1 $cmd
strip $cmd
"$cmd"
} else
{
expand $cmd
echo $cmd
if ($caller in "v") # view
{
execcatch $cmd
view $tempfile
} else if ($caller in "ion") # extract name, copy in/out
execcatch $cmd
else if ($caller in "a") # action
exec $cmd
}
}
# Apply the rules in the tables
ApplyRule($rule,$file,$caller)
{
local $cmd;
strip $rule
split 1 "#w" $rule $cmd # split at whitespace
if (matches $file /$rule/)
{
ApplyProgram($cmd,$caller)
return 1
}
else return 0
}
ApplyRules($namelist, $typelist, $file, $caller)
{
local $typeout;
# Set up the $base variable
$basename = $file
split 1 "." $basename $suffix
if (ParseAndApply($namelist,"ApplyRule",$file,$caller))
return 1
# Go through the `file' pattern action list
if (not matches $typelist "")
{
execcatch "file $file"
$typeout = $linebuff
if (not matches $typeout "")
if (ParseAndApply($typelist,"ApplyRule",$typeout,$caller))
return 1
}
return 0
}
#########################################################
# #
# File name/type-dependent commands #
# #
#########################################################
FileDep
{
local $parent, $child, $path;
if (matches $pFile "..")
{
# gc3 no longer positions the cursor at the
# old directory after a `cd ..';
# it would be messy to do it now, so we do it here...
$parent = $ppath
split -1 $sep $parent $child
makepath $path $ppath ".."
cd $path # don't do a cd .. as this is a relative
# path and has a working dir prepended
# instead of $ppath which may have a container name
paint # force a reread now so the search will work
search $child
return 1
}
makepath $path $ppath $pfile
if (typeof $path in {dir,container})
if (cd $path) return 1
if (not ApplyRules($nameacts, $typeacts, $pfile, "a"))
{
IF_UNIX
if (typeof $pFile in {exec})
{
DoCommand("$pfile ")
return 1
}
IF_ANY
warn("No action associated with this file!")
}
}
#################################################################
# #
# File selection commands #
# #
# Flip - Invert select state of file at cursor #
# InvertSelection - Invert set of selected files #
# SelectByPattern - Get a pattern and select matching files #
# DeselectByPattern - Get a pattern and deselect matching files #
# #
#################################################################
Flip
{
if (marked $pFile) unmark $pFile
else mark $pFile
down
}
InvertSelection
{
local $fname;
loop ($fname)
{
if (marked $fname) unmark $fname
else mark $fname
}
}
# we use a global $pat for the next two so that the value is persistent
SelectByPattern
{
write "Pattern? "
if (read $pat 60) mark /$pat/
}
DeselectByPattern
{
write "Pattern? "
if (read $pat 60) unmark /$pat/
}
##############################################################
# #
# File copying, moving and deleting #
# #
##############################################################
# Check if target exists and get overwrite confirmation
doCopy($src,$dest)
{
echo "Copying $src to $dest"
IF_DOS
# Special handling for copying directories under DOS
if (typeof $src in {dir}) # directory copy
{
# Make the destination directory, if necessary
if (not access $dest "0") execcatch "mkdir $dest"
# Do the copy using DOS' xcopy command
execcatch "xcopy $src $dest /s"
return 1
}
else
IF_ANY
if (copy $src $dest) return 1
else return 0
}
doDelete($file)
{
local $tmp, $prompt, $tf;
if (typeof $file in {dir}) # directory delete
{
execcatch "rmdir $file"
echo $linebuff
if (access $file "0") # delete failed => not empty
{
$prompt = "Directory $file not empty - confirm delete"
if (getYNAnswer($prompt $tmp) and $tmp)
{
IF_DOS
execcatch "deltree /Y $file"
echo $linebuff
IF_UNIX
# We don't do execcatch in case there
# are permissions problems needing interaction
exec "rm -r $file"
IF_ANY
}
}
} else
{
# if $usetrash is on, then we copy the file to the
# trash directory and update the trash index...
if ($usetrash)
{
# find an unused file name in the trash directory...
do
{
$tf = $random
head 4 $tf
$tmp = "$trashdir$sep$tf"
}
while (access $tmp "0")
# update the index
IF_DOS
append "$trashdir$sep#gc3trash.idx" "$tf $date $time $file#010#013"
IF_UNIX
append "$trashdir$sep#gc3trash.idx" "$tf $date $time $file#010"
IF_ANY
# move file to trash
move $file $tmp
}
else unlink $file
}
}
doMove($src,$dest)
{
local $path, $name;
echo "Moving $src to $dest"
IF_DOS
if (typeof $src in {dir})
{
# if the dest is just a name with no path, we can
# do a ren, else we must do a xcopy and deltree.
$path = $dest
split -1 $sep $path $name
if ((matches $path $ppath) and (not access $dest "0"))
execcatch "ren $src $dest" # rename directory
else
{
if (doCopy($src,$dest))
{
rescan "3"; paint
doDelete($src)
}
}
}
else
IF_ANY
move $src $dest
}
# generic handler for copy, move and delete
BasicFileOp($act)
{
local $tmp, $fname, $dest, $src, $prompt, $mustRescan = "n",
$rescanArg, $destpath;
$confirm = "y"
if ($act in "CM")
{
if ($act in "M") $rescanArg = "3"
else $rescanArg = "2";
if ( eval $pselcnt )
write "$act $pSelSize bytes in $pSelCnt file(s) to "
else if (typeof $pfile in {dir})
write "$act directory $pFile to "
else
write "$act $pSize bytes in $pFile to "
$dest = $spath
if (not read $dest 80) return 0
# the user may have entered a destination
# directory or a destination file
# We check for a directory...
IF_DOS
# handle drive specs such as "C:"
if (matches $dest /?:/)
{
$tmp = $ppath # remember where we are
cd $dest # change to the dest drive
$dest = $ppath # get the cwd on the drive
cd $tmp # and restore where we were
}
IF_ANY
if (not matches $dest $spath)
$rescanArg = "3"
if (eval $pselcnt)
{
if (not typeof $dest in {container,dir})
{
echo "Destination is not a directory or container!"
return 0
}
loop ($fname)
{
if ((not marked $fname) or matches $fname "..")
continue
makepath $src $ppath $fname
makepath $destpath $dest $fname
if ($act in "M")
{
if (doMove($src,$destpath))
$mustRescan = "y"
}
else if (doCopy($src,$destpath))
{
$mustRescan = "y"
if ($deselect)
unmark $fname
}
}
echo "$act finished"
}
else
{
if (typeof $dest in {container,dir})
makepath $destpath $dest $pFile
else makepath $destpath $dest ""
makepath $src $ppath $pfile
if ($act in "Mm")
{
if (doMove($src,$destpath))
$mustRescan = "y"
} else if (doCopy($src,$destpath))
{
$mustRescan = "y"
if ($deselect)
unmark $fname
}
}
} else
{
$rescanArg = "1"
if ( eval $pselcnt )
{
$prompt = "Deleting $pSelSize bytes in $pSelCnt file(s) - confirm y/n? ";
if (not getAnswer($prompt $tmp "yY")) return 0
loop ($fname)
{
if (matches $fname "..") continue
if (marked $fname and not matches $fname "..")
{
makepath $src $ppath $fname
if (doDelete($src)) $mustRescan = "y"
}
}
} else if (not matches $pfile "..") {
makepath $src $ppath $pfile
if (doDelete($src)) $mustRescan = "y"
}
}
if ($mustRescan)
{
if (matches $ppath $spath)
rescan "3"
else rescan "$rescanArg"
}
}
MoveFiles { BasicFileOp("Moving") }
CopyFiles { BasicFileOp("Copying") }
DeleteFiles { BasicFileOp("Deleting") }
RenameFile
{
local $dest, $prompt;
write "Rename $pFile to? "
$dest = ""
if (read $dest 40 and move $pFile $dest)
rescan "1"
}
MakeDir
{
local $tmp;
write "New directory name? "
if (read $tmp 40)
{
if (access $tmp "0")
{
echo "$tmp exists!"
return 1;
}
execcatch "mkdir $tmp"
echo $linebuff
rescan "1"
}
}
##############################################################
# #
# File viewing and editing #
# #
##############################################################
# CompareFiles is useful for making patches; I use it for creating
# the patches for gc3
CompareFiles
{
local $fname, $cdir = "";
write "Compare path? "
if (read $cdir 40)
{
loop ($fname)
if (marked $fname)
exec "diff -c $cdir$sep$fname $fname > $fname.dif"
rescan "1"
}
}
ApplyOpToFiles($op)
{
local $fname, $cmd;
if (eval $pselcnt)
{
$cmd = $op
loop ($fname)
if (marked $fname and typeof $fname in {reg,exec,link})
$cmd = "$cmd $fname"
if (not matches $op $cmd)
exec $cmd
else beep
} else
{
if (typeof $pFile in {reg, exec, link})
exec "$op $pFile"
else beep
}
}
EditFiles { ApplyOpToFiles($editor) }
# We used to view selected files, if any - now we just view the
# file at the cursor (like Norton), as this behaviour is preferable.
#PageFiles { ApplyOpToFiles($viewprog) }
PageFiles
{
if (typeof $pFile in {reg, exec, link}) exec "$viewprog $pFile"
else beep;
}
ProcFiles
{
local $cmd, $pref, $suf, $fname, $cmd2, $len, $front, $back;
write "Command (or placeholders; currently $basehold$extenshold)? "
if (read $cmd -80)
{
$len = length $cmd
if (matches $len "2" or matches $len "3")
{
$basehold = $cmd
$extenshold = $cmd
head 1 $basehold
tail 1 $extenshold
return 0
}
$pref = $cmd
loop ($fname)
{
if (marked $fname)
{
$front = $fname
split 1 "." $front $back
if (not matches $back "")
$back=".$back"
$cmd2 = ""
$pref = $cmd
while (split 1 $basehold $pref $suf)
{
$cmd2 = "$cmd2$pref$front"
$pref = $suf
}
$cmd2 = "$cmd2$pref"
$pref = $cmd2
$cmd2 = ""
while (split 1 $extenshold $pref $suf)
{
$cmd2 = "$cmd2$pref$back"
$pref = $suf
}
$cmd2 = "$cmd2$pref"
if (ExpandCommand($cmd2,"n") and $deselect)
unmark $fname
}
}
rescan "3"
}
}
# Edit files that contain a string match.
EditMatching
{
local $fname, $cmd = "$editor ";
write "Edit files matching? "
if (not read $pat 40) return 0
write "Edit files containing? "
if (not read $string 40) return 0
loop ($fname)
{
if (matches $fname /$pat/ and contains $fname $string)
$cmd = "$cmd $fname"
}
if (not matches $cmd "$editor ") exec $cmd
else echo "No matching files"
}
##############################################################
# #
# Bits and Pieces #
# #
##############################################################
# Position cursor on a filename that matches a pattern
PSearch
{
write "Pattern? "
if (read $pat 40)
search /$pat/
}
# Apply a simple command that produces one line of output to the
# selected files, or the current file if none are selected. The
# types of commands I mean are things like "file", "wc", "sum", etc.
DoSimpleOp
{
if ( eval $pselcnt )
exec "$op $psel | $pager"
else
{
execcatch "$op $pFile"
echo $linebuff
}
}
# Simple expression calculator
Calc
{
local $expr = "", $res;
write "Expression? "
if (read $expr 60)
{
expand $expr
$res = eval $expr
echo "$expr = $res"
}
}
# Toggle the size of the directory windows
ChangeItem($name, $var, $inc)
{
local $press, $cnt = "1";
loop
{
write "Press [a digit and] `+' to increase $name, `-' to decrease $name"
$press = ""
if (not read $press 1) break
if ($press in "0123456789")
{
$cnt = $press;
write "Press `+' to increase $name, `-' to decrease $name: "
if (not read $press -1) break
tail 1 $press
}
if ($press in "+") $var = eval "$var+$cnt"
else if ($press in "-") $var = eval "$var-$cnt"
else break
invalidate; paint; sync
}
}
ChangeWidth { ChangeItem("width",$width,"2") }
ChangeHeight { ChangeItem("height",$height,"2") }
ChangeLeft { ChangeItem("left margin",$leftmargin,"1") }
ChangeTop { ChangeItem("top margin",$topmargin,"1") }
WindowChange
{
local $opt = "";
write "Change w(idth), h(eight), t(op margin) or l(eft margin? "
if (read $opt 1)
{
if ($opt in "wW") ChangeWidth
else if ($opt in "hH") ChangeHeight
else if ($opt in "lL") ChangeLeft
else if ($opt in "tT") ChangeTop
}
}
# Search path for a file and print full pathname
# Currently this isn't bound to anything
whence
{
local $tmp2, $tmp;
write "File name?"
if (read $tmp 80)
{
if (not inpath $tmp $tmp2)
write "Not in path"
else
write "Found at $tmp2"
}
}
MarkAll
{
if ($DOSpatterns) mark /*.*/
else mark /./
}
UnmarkAll
{
if ($DOSpatterns) unmark /*.*/
else unmark /./
}
######################
# Directory Compares #
######################
markPair($f1,$f2)
{
mark $f1
swap
mark $f2
swap
}
MarkSingle($pri $sec $key)
{
local $pname, $sname;
makepath $pname $ppath $pri
makepath $sname $spath $sec
if (compare mtime $pname $sname)
{
# Mark the most recent
if (+ compare mtime $sname $pname)
{
if ($key in "mM")
{
swap; mark $sec; swap
}
else mark $pri
} else
{
if (not $key in "mM")
{
swap; mark $sec; swap
}
else mark $pri
}
}
}
# Compare directory with multiple criteria