Skip to content

Commit

Permalink
Limit win print (#2)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
RasmusEdgar committed Sep 10, 2021
1 parent cf3f567 commit dddefdb
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 23 deletions.
43 changes: 39 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Tabexec is inspired by Dmenu by suckless.org.

Tabexec is configured through the AmigaOS ToolType system.

## Paths to scan
### Paths to scan

Set paths with info ToolType PATHS, like so:

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

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

## Stack size
### Stack size

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

Default stack size is: 32768

## Usage
### Colors

The colors of the tabexec window can be changed with the following TTs.

Change the front and backgrounbd coloris of the window:
```
FPEN=<integer>
BPEN=<integer>
```

Change the front and background color of the seperator:
```
FPEN_SEP=<integer>
BPEN_SEP=<integer>
```

## Installation

Copy tabexec and tabexec.info to somewhere in your path.

```
copy tabexec C:
copy tabexec.info C:
```

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

## Usage

It is a good companion to dintwm (a tiling wm also found on aminet),
but is perfectly usable a standalone launcher.

Bind it to a shortcut key, launch it with the mouse or dedicate a CMD entry
to it in dintwm.

Tabexec makes most sense used as a shortcut launched app.

Tabexec gadget grabs input.

In short:

* Launch tabexec
* Start typing command
* Tab suggestions, continously tabbing will move through suggestions
* Ctrl-j and Ctrl-l moves back and forth through suggestions
* Return launches command
* Esc exits

Info files are filtered out by default.
Info files are filtered out of suggestions.
8 changes: 5 additions & 3 deletions include/tabexec.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@

#define MYSTRGADWIDTH (215)

#define SG_STRLEN (44)
#define INIT_LATER 0
#define SG_STRLEN (214)

#define DONE 0
#define RUNNING 1
Expand Down Expand Up @@ -74,7 +73,10 @@
#define DEFAULT_FPEN 3U
#define DEFAULT_BPEN 1U

#define DEFAULT_STACK (unsigned long)32768
#define DEFAULT_STACK (unsigned long)16384

#define LOFFS 0
#define TOFFS 3

struct ExecBase *SysBase;
struct ExAllData *tead, *ead, *buffer;
Expand Down
34 changes: 18 additions & 16 deletions src/tabexec.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@ static void setdefaults(void);
static int pup_paths(const char * s);
static bool filter(const char *s);
static int custom_exec_n = 0;
static unsigned char *space;
static unsigned char space[] = " ";
static unsigned char sep[] = " || ";
static unsigned short spacew;
static char deadsignum = -1;
static unsigned long deadsig, uportsig;
static struct Task *maintask = NULL;
static struct Task *tabexectask = NULL;
static unsigned short winh = 0;
static char *paths[TT_MAX_LENGTH];
static char *freepaths, *ppath;
Expand Down Expand Up @@ -129,7 +129,7 @@ int main(void)
}

deadsig = 1UL << (unsigned long)deadsignum;
maintask = FindTask(NULL);
tabexectask = FindTask(NULL);

state = init_dawin();

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

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

Expand Down Expand Up @@ -335,7 +335,8 @@ static int init_dawin(void)
return DONE;
}

vars = (struct Vars *)AllocMem(sizeof(struct Vars), MEMF_CLEAR); //-V2544
//vars = (struct Vars *)AllocMem(sizeof(struct Vars), MEMF_CLEAR); //-V2544
vars = (struct Vars *)malloc(sizeof(struct Vars)); //-V2544
if (vars != NULL) {
vars->sgg_Extend.Pens[0] = (unsigned char)drawinfo->dri_Pens[FILLTEXTPEN];
vars->sgg_Extend.Pens[1] = (unsigned char)drawinfo->dri_Pens[FILLPEN];
Expand Down Expand Up @@ -388,7 +389,6 @@ static int init_dawin(void)
return DONE;
}

*space = (unsigned char)' ';
spacew = (unsigned short)textwidth(0, space);

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

ActivateWindow(dawin);
Expand Down Expand Up @@ -472,7 +472,6 @@ static int exec_match(unsigned char *em)
stags[3].ti_Tag = SYS_UserShell; //-V2544 //-V2568
stags[3].ti_Data = TRUE; //-V2568
stags[4].ti_Tag = NP_StackSize; //-V2544 //-V2568
//stags[4].ti_Data = 32768; //-V2568
stags[4].ti_Data = pstack_size; //-V2568
stags[5].ti_Tag = TAG_DONE; //-V2568

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

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

mtext.IText = (unsigned char *)item->text;
mtext.LeftEdge = pos;
PrintIText(dawin->RPort, &mtext, 0, 3);
PrintIText(dawin->RPort, &mtext, LOFFS, TOFFS);
spos = textwidth(pos, (unsigned char *)item->text);
tmpitem++;
if (dawin->Width < (textwidth(spos, (unsigned char *)tmpitem->text))) {
break;
}
mtext.IText = space;
mtext.LeftEdge = spos;
PrintIText(dawin->RPort, &mtext, 0, 3);
PrintIText(dawin->RPort, &mtext, LOFFS, TOFFS);
}
mtext.LeftEdge = 0;
return RUNNING;
Expand Down Expand Up @@ -565,7 +569,7 @@ static unsigned long hook_routine(__attribute__((unused)) struct Hook *hook, str
if ((sgw->EditOp == REPLACE_C) || (sgw->EditOp == INSERT_C)) {
if (custom_exec_n == 0) {
if((match_to_win(sgw->WorkBuffer) == DONE)) {
Signal(maintask, deadsig);
Signal(tabexectask, deadsig);
}
sel = matches;
}
Expand All @@ -575,7 +579,7 @@ static unsigned long hook_routine(__attribute__((unused)) struct Hook *hook, str

switch (sgw->Code) {
case ESCAPE_C:
Signal(maintask, deadsig);
Signal(tabexectask, deadsig);
break;
case SPACE_C:
if (custom_exec_n == 0) {
Expand Down Expand Up @@ -634,16 +638,14 @@ static unsigned long hook_routine(__attribute__((unused)) struct Hook *hook, str
tabc = 0;
if (custom_exec_n < sgw->BufferPos) {
custom_exec_n = 0;
} else {
break;
}

if (sgw->BufferPos == 0) {
RectFill(dawin->RPort, stext.LeftEdge, 0, screen->Width, winh);
sel = NULL;
} else {
if((match_to_win(sgw->WorkBuffer) == DONE)) {
Signal(maintask, deadsig);
Signal(tabexectask, deadsig);
}
sel = matches;
}
Expand Down Expand Up @@ -772,6 +774,6 @@ static void cleanup(void)
freetext();
CloseWindow(dawin);
FreeSignal((long)deadsignum);
FreeMem(vars, sizeof(struct Vars));
free(vars);
FreeScreenDrawInfo(screen, drawinfo);
}
Binary file modified tabexec.info
Binary file not shown.

0 comments on commit dddefdb

Please sign in to comment.