Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable additional keys, remove lock files, fix clipboard under WSL, reduce binary size #103

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion config.mk.def
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# CC is the C compiler to use
CC=gcc
CFLAGS?=
CFLAGS+=-std=c99
CFLAGS+=-std=c99 -O2 -flto

# STANDARDS names the C preprocessor defines that need to
# be present to get a more-or-less standard compilation
Expand Down
4 changes: 3 additions & 1 deletion doc/samrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# This is samrc as I usually use it.

# Control-A/E jumps to beginning/end of line
# Control-A/E and Home/End jumps to beginning/end of line
bind C a command bol
bind C e command eol
bind * Home command bol
bind * End command eol

# Control-H/L/J/K moves left/right/down/up
bind C h command charleft
Expand Down
19 changes: 3 additions & 16 deletions include/libg.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,41 +157,33 @@ enum Fcode

typedef void (*Errfunc)(char *);

extern void addlatin(char, char, int16_t);
extern Point add(Point, Point);
extern Point sub(Point, Point);
extern Point mul(Point, int);
extern Point divpt(Point, int);
extern Rectangle rsubp(Rectangle, Point);
extern Rectangle raddp(Rectangle, Point);
extern Rectangle inset(Rectangle, int);
extern Rectangle rmul(Rectangle, int);
extern Rectangle rdiv(Rectangle, int);
extern Rectangle rshift(Rectangle, int);
extern Rectangle rcanon(Rectangle);
extern Bitmap* balloc(Rectangle, int);
extern void bfree(Bitmap*);
extern int rectclip(Rectangle*, Rectangle);
extern void xtbinit(Errfunc, char*, int*, char**, char**);
extern void bclose(void);
extern void berror(char*);
extern void bitblt2(Bitmap*, Point, Bitmap*, Rectangle, Fcode, uint64_t, uint64_t);
extern void bitblt(Bitmap*, Point, Bitmap*, Rectangle, Fcode);

extern Point string(Bitmap*, Point, XftFont*, char*, Fcode);
extern Point string(Bitmap*, Point, XftFont*, char*);
extern int64_t strwidth(XftFont*, char*);
extern int64_t charwidth(XftFont*, wchar_t);
extern void texture(Bitmap*, Rectangle, Bitmap*, Fcode);
extern void wrbitmap(Bitmap*, int, int, unsigned char*);
extern int ptinrect(Point, Rectangle);
extern int rectXrect(Rectangle, Rectangle);
extern int eqpt(Point, Point);
extern int eqrect(Rectangle, Rectangle);
extern void border(Bitmap*, Rectangle, int, Fcode, uint64_t);
extern void cursorswitch(unsigned int);
extern void cursorset(Point);
extern Rectangle bscreenrect(Rectangle*);
extern void bflush(void);

extern int clipr(Bitmap*, Rectangle);
extern int scrpix(int*,int*);
Expand All @@ -200,25 +192,21 @@ extern uint64_t getbg(void);
extern void einit(uint64_t);
extern uint64_t estart(uint64_t, int, size_t, bool);

extern uint64_t event(Event*);
extern uint64_t eread(uint64_t, Event*);
extern Mouse emouse(void);
extern Keystroke ekbd(void);
extern void pushkbd(int c);
extern int ecanread(uint64_t);
extern int ecanmouse(void);
extern int ecankbd(void);
extern void ereshaped(Rectangle); /* supplied by user */
extern void ereshaped(void); /* supplied by user */

extern int menuhit(int, Mouse*, Menu*);
extern Rectangle getrect(int, Mouse*);

extern void rdcolmap(Bitmap*, RGB*);
extern void wrcolmap(Bitmap*, RGB*);
extern void raisewindow(void);

/* Extra functions supplied by libXg */
extern int snarfswap(char*, int, char**);
extern int snarfswap(char*, char**);

enum{
Emouse = 1,
Expand All @@ -237,7 +225,6 @@ extern Rectangle Rpt(Point, Point);
extern Bitmap screen;
extern XftFont *font;
extern XftColor fontcolor;
extern XftColor bgcolor;

#define BGSHORT(p) (((p)[0]<<0) | ((p)[1]<<8))
#define BGLONG(p) ((BGSHORT(p)<<0) | (BGSHORT(p+2)<<16))
Expand Down
65 changes: 0 additions & 65 deletions include/regexp.h

This file was deleted.

5 changes: 5 additions & 0 deletions include/unused.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#ifdef __GNUC__
# define UNUSED(x) UNUSED_ ## x __attribute__((__unused__))
#else
# define UNUSED(x) UNUSED_ ## x
#endif
3 changes: 0 additions & 3 deletions libXg/GwinP.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,4 @@ typedef struct _GwinClassRec {
GwinClassPart gwin_class;
} GwinClassRec, *GwinWidgetClass;

/* External definition for class record */
extern GwinClassRec gwinClassRec;

#endif /* GWINP_H */
2 changes: 1 addition & 1 deletion libXg/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ XLIBS=-lXt -lXi
RANLIB=:

# add name of librarian
AR=ar
AR=gcc-ar

# the name of the library
LIB=libXg.a
Expand Down
68 changes: 0 additions & 68 deletions libXg/arith.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,6 @@ divpt(Point a, int b)
return a;
}

Point
mul(Point a, int b)
{
a.x *= b;
a.y *= b;
return a;
}

Rectangle
rsubp(Rectangle r, Point p)
{
Expand All @@ -64,79 +56,19 @@ raddp(Rectangle r, Point p)
return r;
}

Rectangle
rmul(Rectangle r, int a)
{
if (a != 1) {
r.min.x *= a;
r.min.y *= a;
r.max.x *= a;
r.max.y *= a;
}
return r;
}

Rectangle
rdiv(Rectangle r, int a)
{
if (a != 1) {
r.min.x /= a;
r.min.y /= a;
r.max.x /= a;
r.max.y /= a;
}
return r;
}

Rectangle
rshift(Rectangle r, int a)
{
if (a > 0) {
r.min.x <<= a;
r.min.y <<= a;
r.max.x <<= a;
r.max.y <<= a;
}
else if (a < 0) {
a = -a;
r.min.x >>= a;
r.min.y >>= a;
r.max.x >>= a;
r.max.y >>= a;
}
return r;
}

int
eqpt(Point p, Point q)
{
return p.x==q.x && p.y==q.y;
}

int
eqrect(Rectangle r, Rectangle s)
{
return r.min.x==s.min.x && r.max.x==s.max.x &&
r.min.y==s.min.y && r.max.y==s.max.y;
}

int
rectXrect(Rectangle r, Rectangle s)
{
return r.min.x<s.max.x && s.min.x<r.max.x &&
r.min.y<s.max.y && s.min.y<r.max.y;
}

int
rectinrect(Rectangle r, Rectangle s)
{
/* !ptinrect(r.min, s) in line for speed */
if(!(r.min.x>=s.min.x && r.min.x<s.max.x &&
r.min.y>=s.min.y && r.min.y<s.max.y))
return 0;
return r.max.x<=s.max.x && r.max.y<=s.max.y;
}

int
ptinrect(Point p, Rectangle r)
{
Expand Down
6 changes: 4 additions & 2 deletions libXg/gcs.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include <libg.h>
#include "libgint.h"

static GC _getfillgc2(Fcode, Bitmap*, uint64_t, uint64_t, uint64_t);

/*
* Libg applications are written assuming that black is ~0
* and white is 0. Some screens use the reverse convention.
Expand Down Expand Up @@ -156,7 +158,7 @@ static int degengc[16] = {
* Also, set (or unset) the clip rectangle if necessary.
* (This implementation should be improved if setting a clip rectangle is not rare).
*/
GC
static GC
_getgc(Bitmap *b, uint64_t gcvm, XGCValues *pgcv)
{
static GC gc0, gcn;
Expand Down Expand Up @@ -203,7 +205,7 @@ _getfillgc(Fcode f, Bitmap *b, uint64_t val)
return _getfillgc2(f, b, val, _fgpixel, _bgpixel);
}

GC
static GC
_getfillgc2(Fcode f, Bitmap *b, uint64_t val, uint64_t fg, uint64_t bg)
{
int xf, m;
Expand Down