Skip to content

Commit dddefdb

Browse files
authored
Limit win print (#2)
* Print only to width of screen and others * Now with icon. Killed silly and hard to track bug concerning pointer corruption. * Fixed problem with finding info * README updated
1 parent cf3f567 commit dddefdb

File tree

4 files changed

+62
-23
lines changed

4 files changed

+62
-23
lines changed

README.md

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Tabexec is inspired by Dmenu by suckless.org.
1010

1111
Tabexec is configured through the AmigaOS ToolType system.
1212

13-
## Paths to scan
13+
### Paths to scan
1414

1515
Set paths with info ToolType PATHS, like so:
1616

@@ -20,7 +20,7 @@ PATHS=C:,System:System,System:Utilities
2020

2121
Default PATHS TT is set to: C:,System:Tools
2222

23-
## Stack size
23+
### Stack size
2424

2525
The stacksize for launched programs can be changed with the
2626
PSTACK TT.
@@ -32,17 +32,52 @@ PSTACK=8192
3232

3333
Default stack size is: 32768
3434

35-
## Usage
35+
### Colors
36+
37+
The colors of the tabexec window can be changed with the following TTs.
38+
39+
Change the front and backgrounbd coloris of the window:
40+
```
41+
FPEN=<integer>
42+
BPEN=<integer>
43+
```
44+
45+
Change the front and background color of the seperator:
46+
```
47+
FPEN_SEP=<integer>
48+
BPEN_SEP=<integer>
49+
```
50+
51+
## Installation
52+
53+
Copy tabexec and tabexec.info to somewhere in your path.
54+
55+
```
56+
copy tabexec C:
57+
copy tabexec.info C:
58+
```
3659

3760
The files tabexec and tabexec.info should be kept together.
3861

62+
## Usage
63+
64+
It is a good companion to dintwm (a tiling wm also found on aminet),
65+
but is perfectly usable a standalone launcher.
66+
67+
Bind it to a shortcut key, launch it with the mouse or dedicate a CMD entry
68+
to it in dintwm.
69+
3970
Tabexec makes most sense used as a shortcut launched app.
4071

72+
Tabexec gadget grabs input.
73+
74+
In short:
75+
4176
* Launch tabexec
4277
* Start typing command
4378
* Tab suggestions, continously tabbing will move through suggestions
4479
* Ctrl-j and Ctrl-l moves back and forth through suggestions
4580
* Return launches command
4681
* Esc exits
4782

48-
Info files are filtered out by default.
83+
Info files are filtered out of suggestions.

include/tabexec.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@
4040

4141
#define MYSTRGADWIDTH (215)
4242

43-
#define SG_STRLEN (44)
44-
#define INIT_LATER 0
43+
#define SG_STRLEN (214)
4544

4645
#define DONE 0
4746
#define RUNNING 1
@@ -74,7 +73,10 @@
7473
#define DEFAULT_FPEN 3U
7574
#define DEFAULT_BPEN 1U
7675

77-
#define DEFAULT_STACK (unsigned long)32768
76+
#define DEFAULT_STACK (unsigned long)16384
77+
78+
#define LOFFS 0
79+
#define TOFFS 3
7880

7981
struct ExecBase *SysBase;
8082
struct ExAllData *tead, *ead, *buffer;

src/tabexec.c

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,12 @@ static void setdefaults(void);
8585
static int pup_paths(const char * s);
8686
static bool filter(const char *s);
8787
static int custom_exec_n = 0;
88-
static unsigned char *space;
88+
static unsigned char space[] = " ";
8989
static unsigned char sep[] = " || ";
9090
static unsigned short spacew;
9191
static char deadsignum = -1;
9292
static unsigned long deadsig, uportsig;
93-
static struct Task *maintask = NULL;
93+
static struct Task *tabexectask = NULL;
9494
static unsigned short winh = 0;
9595
static char *paths[TT_MAX_LENGTH];
9696
static char *freepaths, *ppath;
@@ -129,7 +129,7 @@ int main(void)
129129
}
130130

131131
deadsig = 1UL << (unsigned long)deadsignum;
132-
maintask = FindTask(NULL);
132+
tabexectask = FindTask(NULL);
133133

134134
state = init_dawin();
135135

@@ -180,7 +180,7 @@ static int attachtooltypes(void)
180180
static struct DiskObject *diskobj;
181181
static struct Library *iconbase;
182182
static unsigned char iconlib[] = "icon.library";
183-
static unsigned char diskobjname[] = "tabexec";
183+
static unsigned char diskobjname[] = "PROGDIR:tabexec";
184184

185185
optarrsize = sizeof(defopts) / sizeof(*defopts);
186186

@@ -335,7 +335,8 @@ static int init_dawin(void)
335335
return DONE;
336336
}
337337

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
339340
if (vars != NULL) {
340341
vars->sgg_Extend.Pens[0] = (unsigned char)drawinfo->dri_Pens[FILLTEXTPEN];
341342
vars->sgg_Extend.Pens[1] = (unsigned char)drawinfo->dri_Pens[FILLPEN];
@@ -388,7 +389,6 @@ static int init_dawin(void)
388389
return DONE;
389390
}
390391

391-
*space = (unsigned char)' ';
392392
spacew = (unsigned short)textwidth(0, space);
393393

394394
SetAPen(dawin->RPort, colors.fpen[0]);
@@ -397,7 +397,7 @@ static int init_dawin(void)
397397
SetRast(dawin->RPort, colors.fpen[0]);
398398
stext.LeftEdge = (short)((unsigned short)MYSTRGADWIDTH + spacew);
399399
stext.IText = sep;
400-
PrintIText(dawin->RPort, &stext, 0, 3);
400+
PrintIText(dawin->RPort, &stext, LOFFS, TOFFS);
401401
stext.LeftEdge = textwidth(stext.LeftEdge, sep);
402402

403403
ActivateWindow(dawin);
@@ -472,7 +472,6 @@ static int exec_match(unsigned char *em)
472472
stags[3].ti_Tag = SYS_UserShell; //-V2544 //-V2568
473473
stags[3].ti_Data = TRUE; //-V2568
474474
stags[4].ti_Tag = NP_StackSize; //-V2544 //-V2568
475-
//stags[4].ti_Data = 32768; //-V2568
476475
stags[4].ti_Data = pstack_size; //-V2568
477476
stags[5].ti_Tag = TAG_DONE; //-V2568
478477

@@ -503,17 +502,22 @@ static int match_to_win(unsigned char *strbuf)
503502

504503
for (item = matches; item && item->text; ptext = (unsigned char *)item->text, item++) {
505504
short spos = 0;
505+
struct item *tmpitem = item;
506506
if (item->text != matches->text) {
507507
pos = (short)(textwidth(pos, ptext) + (short)spacew);
508508
}
509509

510510
mtext.IText = (unsigned char *)item->text;
511511
mtext.LeftEdge = pos;
512-
PrintIText(dawin->RPort, &mtext, 0, 3);
512+
PrintIText(dawin->RPort, &mtext, LOFFS, TOFFS);
513513
spos = textwidth(pos, (unsigned char *)item->text);
514+
tmpitem++;
515+
if (dawin->Width < (textwidth(spos, (unsigned char *)tmpitem->text))) {
516+
break;
517+
}
514518
mtext.IText = space;
515519
mtext.LeftEdge = spos;
516-
PrintIText(dawin->RPort, &mtext, 0, 3);
520+
PrintIText(dawin->RPort, &mtext, LOFFS, TOFFS);
517521
}
518522
mtext.LeftEdge = 0;
519523
return RUNNING;
@@ -565,7 +569,7 @@ static unsigned long hook_routine(__attribute__((unused)) struct Hook *hook, str
565569
if ((sgw->EditOp == REPLACE_C) || (sgw->EditOp == INSERT_C)) {
566570
if (custom_exec_n == 0) {
567571
if((match_to_win(sgw->WorkBuffer) == DONE)) {
568-
Signal(maintask, deadsig);
572+
Signal(tabexectask, deadsig);
569573
}
570574
sel = matches;
571575
}
@@ -575,7 +579,7 @@ static unsigned long hook_routine(__attribute__((unused)) struct Hook *hook, str
575579

576580
switch (sgw->Code) {
577581
case ESCAPE_C:
578-
Signal(maintask, deadsig);
582+
Signal(tabexectask, deadsig);
579583
break;
580584
case SPACE_C:
581585
if (custom_exec_n == 0) {
@@ -634,16 +638,14 @@ static unsigned long hook_routine(__attribute__((unused)) struct Hook *hook, str
634638
tabc = 0;
635639
if (custom_exec_n < sgw->BufferPos) {
636640
custom_exec_n = 0;
637-
} else {
638-
break;
639641
}
640642

641643
if (sgw->BufferPos == 0) {
642644
RectFill(dawin->RPort, stext.LeftEdge, 0, screen->Width, winh);
643645
sel = NULL;
644646
} else {
645647
if((match_to_win(sgw->WorkBuffer) == DONE)) {
646-
Signal(maintask, deadsig);
648+
Signal(tabexectask, deadsig);
647649
}
648650
sel = matches;
649651
}
@@ -772,6 +774,6 @@ static void cleanup(void)
772774
freetext();
773775
CloseWindow(dawin);
774776
FreeSignal((long)deadsignum);
775-
FreeMem(vars, sizeof(struct Vars));
777+
free(vars);
776778
FreeScreenDrawInfo(screen, drawinfo);
777779
}

tabexec.info

-1.29 KB
Binary file not shown.

0 commit comments

Comments
 (0)