@@ -85,12 +85,12 @@ static void setdefaults(void);
85
85
static int pup_paths (const char * s );
86
86
static bool filter (const char * s );
87
87
static int custom_exec_n = 0 ;
88
- static unsigned char * space ;
88
+ static unsigned char space [] = " " ;
89
89
static unsigned char sep [] = " || " ;
90
90
static unsigned short spacew ;
91
91
static char deadsignum = -1 ;
92
92
static unsigned long deadsig , uportsig ;
93
- static struct Task * maintask = NULL ;
93
+ static struct Task * tabexectask = NULL ;
94
94
static unsigned short winh = 0 ;
95
95
static char * paths [TT_MAX_LENGTH ];
96
96
static char * freepaths , * ppath ;
@@ -129,7 +129,7 @@ int main(void)
129
129
}
130
130
131
131
deadsig = 1UL << (unsigned long )deadsignum ;
132
- maintask = FindTask (NULL );
132
+ tabexectask = FindTask (NULL );
133
133
134
134
state = init_dawin ();
135
135
@@ -180,7 +180,7 @@ static int attachtooltypes(void)
180
180
static struct DiskObject * diskobj ;
181
181
static struct Library * iconbase ;
182
182
static unsigned char iconlib [] = "icon.library" ;
183
- static unsigned char diskobjname [] = "tabexec" ;
183
+ static unsigned char diskobjname [] = "PROGDIR: tabexec" ;
184
184
185
185
optarrsize = sizeof (defopts ) / sizeof (* defopts );
186
186
@@ -335,7 +335,8 @@ static int init_dawin(void)
335
335
return DONE ;
336
336
}
337
337
338
- vars = (struct Vars * )AllocMem (sizeof (struct Vars ), MEMF_CLEAR ); //-V2544
338
+ //vars = (struct Vars *)AllocMem(sizeof(struct Vars), MEMF_CLEAR); //-V2544
339
+ vars = (struct Vars * )malloc (sizeof (struct Vars )); //-V2544
339
340
if (vars != NULL ) {
340
341
vars -> sgg_Extend .Pens [0 ] = (unsigned char )drawinfo -> dri_Pens [FILLTEXTPEN ];
341
342
vars -> sgg_Extend .Pens [1 ] = (unsigned char )drawinfo -> dri_Pens [FILLPEN ];
@@ -388,7 +389,6 @@ static int init_dawin(void)
388
389
return DONE ;
389
390
}
390
391
391
- * space = (unsigned char )' ' ;
392
392
spacew = (unsigned short )textwidth (0 , space );
393
393
394
394
SetAPen (dawin -> RPort , colors .fpen [0 ]);
@@ -397,7 +397,7 @@ static int init_dawin(void)
397
397
SetRast (dawin -> RPort , colors .fpen [0 ]);
398
398
stext .LeftEdge = (short )((unsigned short )MYSTRGADWIDTH + spacew );
399
399
stext .IText = sep ;
400
- PrintIText (dawin -> RPort , & stext , 0 , 3 );
400
+ PrintIText (dawin -> RPort , & stext , LOFFS , TOFFS );
401
401
stext .LeftEdge = textwidth (stext .LeftEdge , sep );
402
402
403
403
ActivateWindow (dawin );
@@ -472,7 +472,6 @@ static int exec_match(unsigned char *em)
472
472
stags [3 ].ti_Tag = SYS_UserShell ; //-V2544 //-V2568
473
473
stags [3 ].ti_Data = TRUE; //-V2568
474
474
stags [4 ].ti_Tag = NP_StackSize ; //-V2544 //-V2568
475
- //stags[4].ti_Data = 32768; //-V2568
476
475
stags [4 ].ti_Data = pstack_size ; //-V2568
477
476
stags [5 ].ti_Tag = TAG_DONE ; //-V2568
478
477
@@ -503,17 +502,22 @@ static int match_to_win(unsigned char *strbuf)
503
502
504
503
for (item = matches ; item && item -> text ; ptext = (unsigned char * )item -> text , item ++ ) {
505
504
short spos = 0 ;
505
+ struct item * tmpitem = item ;
506
506
if (item -> text != matches -> text ) {
507
507
pos = (short )(textwidth (pos , ptext ) + (short )spacew );
508
508
}
509
509
510
510
mtext .IText = (unsigned char * )item -> text ;
511
511
mtext .LeftEdge = pos ;
512
- PrintIText (dawin -> RPort , & mtext , 0 , 3 );
512
+ PrintIText (dawin -> RPort , & mtext , LOFFS , TOFFS );
513
513
spos = textwidth (pos , (unsigned char * )item -> text );
514
+ tmpitem ++ ;
515
+ if (dawin -> Width < (textwidth (spos , (unsigned char * )tmpitem -> text ))) {
516
+ break ;
517
+ }
514
518
mtext .IText = space ;
515
519
mtext .LeftEdge = spos ;
516
- PrintIText (dawin -> RPort , & mtext , 0 , 3 );
520
+ PrintIText (dawin -> RPort , & mtext , LOFFS , TOFFS );
517
521
}
518
522
mtext .LeftEdge = 0 ;
519
523
return RUNNING ;
@@ -565,7 +569,7 @@ static unsigned long hook_routine(__attribute__((unused)) struct Hook *hook, str
565
569
if ((sgw -> EditOp == REPLACE_C ) || (sgw -> EditOp == INSERT_C )) {
566
570
if (custom_exec_n == 0 ) {
567
571
if ((match_to_win (sgw -> WorkBuffer ) == DONE )) {
568
- Signal (maintask , deadsig );
572
+ Signal (tabexectask , deadsig );
569
573
}
570
574
sel = matches ;
571
575
}
@@ -575,7 +579,7 @@ static unsigned long hook_routine(__attribute__((unused)) struct Hook *hook, str
575
579
576
580
switch (sgw -> Code ) {
577
581
case ESCAPE_C :
578
- Signal (maintask , deadsig );
582
+ Signal (tabexectask , deadsig );
579
583
break ;
580
584
case SPACE_C :
581
585
if (custom_exec_n == 0 ) {
@@ -634,16 +638,14 @@ static unsigned long hook_routine(__attribute__((unused)) struct Hook *hook, str
634
638
tabc = 0 ;
635
639
if (custom_exec_n < sgw -> BufferPos ) {
636
640
custom_exec_n = 0 ;
637
- } else {
638
- break ;
639
641
}
640
642
641
643
if (sgw -> BufferPos == 0 ) {
642
644
RectFill (dawin -> RPort , stext .LeftEdge , 0 , screen -> Width , winh );
643
645
sel = NULL ;
644
646
} else {
645
647
if ((match_to_win (sgw -> WorkBuffer ) == DONE )) {
646
- Signal (maintask , deadsig );
648
+ Signal (tabexectask , deadsig );
647
649
}
648
650
sel = matches ;
649
651
}
@@ -772,6 +774,6 @@ static void cleanup(void)
772
774
freetext ();
773
775
CloseWindow (dawin );
774
776
FreeSignal ((long )deadsignum );
775
- FreeMem (vars , sizeof ( struct Vars ) );
777
+ free (vars );
776
778
FreeScreenDrawInfo (screen , drawinfo );
777
779
}
0 commit comments