Compare commits

...
Sign in to create a new pull request.

23 commits

Author SHA1 Message Date
uobikiemukot
e11b41bd28
Merge pull request #38 from uobikiemukot/develop
merge develop into master
2018-11-14 14:05:58 +09:00
uobikiemukot
59ef091187
Merge pull request #37 from uobikiemukot/feature/update-default-font
Feature/update default font
2018-11-14 14:02:16 +09:00
uobikiemukot
ee9b8ad4e8 misc: update makefile 2018-11-14 13:57:14 +09:00
uobikiemukot
3da225e5d2 misc: add terminus font 2018-11-14 13:57:14 +09:00
uobikiemukot
2f2819e094 misc: convert encoding to UTF-8 2018-11-14 13:57:14 +09:00
uobikiemukot
c804194168 misc: move milkjf font 2018-11-14 13:57:11 +09:00
uobikiemukot
b5f7c1c462
feature: update unifont download url (#36) 2018-11-12 08:12:06 +09:00
uobikiemukot
b67aa90025
fix typo in comments (#33)
* misc: fix typo in comments
2018-10-15 07:42:16 +09:00
uobikiemukot
58e3308236 misc: occured => occurred 2018-10-15 07:40:24 +09:00
uobikiemukot
6455634529 doc: remove duplicated section 2018-08-13 17:16:45 +09:00
simon-i1-h
664024c6d8 fix typo gylphs -> glyphs (#30) 2018-08-13 17:16:45 +09:00
uobikiemukot
ca711f1d1a Feature/parse command line arg at startup (#28)
* feature: change argument type

* feature: pass command line arguments to execvp (yaft)

* feature: remove comment related to SHELL env

* doc: update README.md

* feature: pass command line arguments to execvp (yaftx)
2018-08-13 17:16:45 +09:00
uobikiemukot
fb076acf16 misc: fetch dina font from ProgrammerFonts repository (#24)
misc: fetch dina font from ProgrammerFonts repository
2018-08-13 17:16:45 +09:00
uobikiemukot
4e3145c3b8 misc: build yaftx on CircleCI (#22)
* misc: build yaftx on CircleCI
* misc: change docker image (centos => archlinux)
2018-08-13 17:16:45 +09:00
Yoteichi
2cae7d4bdb XAllocColorの結果をキャッシュするようにした。 2018-08-13 17:16:45 +09:00
uobikiemukot
866ed8ba8b doc: remove duplicated section 2018-08-13 17:11:20 +09:00
simon-i1-h
d56743ebfc fix typo gylphs -> glyphs (#30) 2018-08-13 16:54:01 +09:00
uobikiemukot
b5904bb9df Feature/parse command line arg at startup (#28)
* feature: change argument type

* feature: pass command line arguments to execvp (yaft)

* feature: remove comment related to SHELL env

* doc: update README.md

* feature: pass command line arguments to execvp (yaftx)
2018-08-13 16:54:01 +09:00
uobikiemukot
6a6387cfd4 misc: fetch dina font from ProgrammerFonts repository (#24)
misc: fetch dina font from ProgrammerFonts repository
2018-08-13 16:54:01 +09:00
uobikiemukot
d7c97282c0 misc: build yaftx on CircleCI (#22)
* misc: build yaftx on CircleCI
* misc: change docker image (centos => archlinux)
2018-08-13 16:54:01 +09:00
Yoteichi
21cb8c59f1 XAllocColorの結果をキャッシュするようにした。 2018-08-13 16:54:01 +09:00
uobikiemukot
ac9809d748 doc: update README 2018-03-14 19:22:56 +09:00
uobikiemukot
f6ee323bda misc: Add CircleCI config 2018-03-14 19:22:56 +09:00
22 changed files with 20777 additions and 130 deletions

13
.circleci/config.yml Normal file
View file

@ -0,0 +1,13 @@
version: 2
jobs:
build:
docker:
- image: uobikiemukot/archlinux-circleci:latest
steps:
- checkout
- run:
name: build yaft
command: make
- run:
name: build yaftx
command: make yaftx

View file

@ -1,6 +1,11 @@
# yaft (yet another framebuffer terminal)
Last update: Mon Jul 27 10:36:02 JST 2015
| Branch | Badge |
| :--: | :--: |
| master | [![CircleCI](https://circleci.com/gh/uobikiemukot/yaft.svg?style=svg)](https://circleci.com/gh/uobikiemukot/yaft) |
| develop | [![CircleCI](https://circleci.com/gh/uobikiemukot/yaft/tree/develop.svg?style=svg)](https://circleci.com/gh/uobikiemukot/yaft/tree/develop) |
Last update: Wed Mar 14 18:44:27 JST 2018
## description
@ -10,7 +15,7 @@ Features:
+ various framebuffer types (8/15/16/24/32bpp)
+ compatible with vt102 and Linux console ([detail](http://uobikiemukot.github.io/yaft/escape.html))
+ UTF-8 encoding and UCS2 gylphs
+ UTF-8 encoding and UCS2 glyphs
+ 256 colors (same as xterm)
+ wallpaper
+ DRCS (DECDLD/DRCSMMv1) (experimental)
@ -36,40 +41,10 @@ If you want to change configuration, rewrite "conf.h".
## environment variables
- FRAMEBUFFER=/dev/fb0: specify farmebuffer device
- SHELL=/bin/bash: specify shell command
- YAFT="wall": use current background as wallpaper (need [idump](https://github.com/uobikiemukot/idump) or fbv)
~~~
$ idump /path/to/wallpaper.png; tput civis; YAFT="wall" FRAMEBUFFER="/dev/fb1" SHELL="/bin/csh" yaft
~~~
## how to use your favorite fonts
You can use tools/mkfont_bdf to create "glyph.h".
usage: tools/mkfont_bdf ALIAS_FILE BDF1 BDF2 BDF3 ... > glyph.h
- ALIAS_FILE: glyph substitution rule file (see table/alias)
- BDF1, BDF2, BDF3...: bdf files
+ yaft supports only "monospace" bdf font
+ you can specify mulitiple bdf fonts (but these fonts MUST be the same size)
+ If there is more than one glyph of the same codepoint, the glyph included in the FIRST bdf file is choosed
~~~
$ ./mkfont_bdf table/your_alias your/favorite/fonts.bdf > glyph.h
~~~
## build and install
*BSD users should check README.bsd
~~~
$ export LANG=en_US.UTF-8 # yaft uses libc's wcwidth for calculating glyph width
$ make
# make install
or
$ make yaftx
# make installx
$ idump /path/to/wallpaper.png; tput civis; YAFT="wall" FRAMEBUFFER="/dev/fb1" yaft
~~~
## how to use your favorite fonts
@ -92,6 +67,19 @@ Or try glyph_builder.sh (bash script for creating yaft's glyph.h)
- supported fonts: mplus, efont, milkjf, unifont, dina, terminus, profont, tamsyn
## build and install
BSD users should check README.bsd
~~~
$ export LANG=en_US.UTF-8 # yaft uses libc's wcwidth for calculating glyph width
$ make
# make install
or
$ make yaftx
# make installx
~~~
## screenshot
![screenshot1](http://uobikiemukot.github.io/img/yaft-screenshot.png)

2
conf.h
View file

@ -38,7 +38,7 @@ const char *term_name = "yaft-256color";
const char *fb_path = "/dev/graphics/fb0";
#endif
/* shell: refer SHELL environment variable at first */
/* shell */
#if defined(__linux__) || defined(__MACH__)
const char *shell_cmd = "/bin/bash";
#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)

View file

@ -438,7 +438,7 @@ void reset_mode(struct terminal_t *term, struct parm_t *parm)
set_cursor(term, 0, 0);
} else if (mode == 7) {
term->mode &= ~MODE_AMRIGHT;
term->wrap_occured = false;
term->wrap_occurred = false;
} else if (mode == 25) {
term->mode &= ~MODE_CURSOR;
} else if (mode == 8901) {

View file

@ -525,8 +525,8 @@ void decdld_parse_header(struct terminal_t *term, char *start_buf)
(TODO: implement sixel/text mode)
Pcmh: max cellheight (force CELL_HEIGHT defined in glyph.h)
Pcss: character set size (force: 96)
0: 94 gylphs charset
1: 96 gylphs charset
0: 94 glyphs charset
1: 96 glyphs charset
f : '{' (0x7B)
Dscs: define character set
Intermediate char: SPACE (0x20) to '/' (0x2F)
@ -579,7 +579,7 @@ void decdld_parse_header(struct terminal_t *term, char *start_buf)
else if (erase_mode == 0) /* reset selected drcs charset */
memset(term->drcs + GLYPHS_PER_CHARSET * charset, 0, sizeof(struct glyph_t) * DRCS_CHARS);
//if (term->drcs[charset] == NULL) /* always allcate 96 chars buffer */
//if (term->drcs[charset] == NULL) /* always allocate 96 chars buffer */
//term->drcs[charset] = ecalloc(GLYPH_PER_CHARSET, sizeof(struct glyph_t));
decdld_parse_data(cp + 1, start_char, term->drcs + GLYPHS_PER_CHARSET * charset); /* skip final char */

View file

@ -411,7 +411,7 @@ static inline void draw_line(struct framebuffer_t *fb, struct terminal_t *term,
if (cellp->width == WIDE)
bdf_padding += CELL_WIDTH;
/* check cursor positon */
/* check cursor position */
if ((term->mode & MODE_CURSOR && line == term->cursor.y)
&& (col == term->cursor.x
|| (cellp->width == WIDE && (col + 1) == term->cursor.x)

View file

@ -1,39 +0,0 @@
《X Window BDF/PCF形式 16ドットフォントmilkjf》
製作 : 日本農園様
X68000/X68030 シリーズ用に日本農園様が製作されたmilkjfフォ
ント(全角非漢字部と半角)を,許可を得て X WindowのBDF形式に変換し
配布する事が可能になりました(Public Domainです).なお,オリジナル
の milkjfにない部分(特に漢字部)と, ギリシャ文字,ロシア文字は東
雲フォントを埋め込んでいます.
フォントの一覧は以下の通りですbold体はmkboldで作成したあと
若干フォントエディタで修正を加えたものです.
milkjf_8x16.bdf(.pcf)
-milkjf-fixed-medium-r-normal--16-150-75-75-C-80-iso8859-1
milkjf_8x16r.bdf(.pcf)
-milkjf-fixed-medium-r-normal--16-150-75-75-C-80-jisx0201.1976-0
milkjf_k16.bdf(.pcf)
-milkjf-fixed-medium-r-normal--16-150-75-75-C-160-jisx0208.1990-0
milkjf_8x16B.bdf(.pcf)
-milkjf-fixed-bold-r-normal--16-150-75-75-C-80-iso8859-1
milkjf_8x16rb.bdf(.pcf)
-milkjf-fixed-bold-r-normal--16-150-75-75-C-80-jisx0201.1976-0
milkjf_k16b.bdf(.pcf)
-milkjf-fixed-bold-r-normal--16-150-75-75-C-160-jisx0208.1990-0
X Window固有の問題等に関しては以下にて
http://phe.phyas.aichi-edu.ac.jp/~cyamauch/xfonts.html
cyamauch@hst.phyas.aichi-edu.ac.jp 山内千里 Oct.1,2001

39
fonts/milkjf/README.1ST Normal file
View file

@ -0,0 +1,39 @@
《X Window BDF/PCF形式 16ドットフォントmilkjf》
製作 : 日本農園様
X68000/X68030 シリーズ用に日本農園様が製作されたmilkjfフォ
ント(全角非漢字部と半角)を,許可を得て X WindowのBDF形式に変換し
配布する事が可能になりました(Public Domainです).なお,オリジナル
の milkjfにない部分(特に漢字部)と, ギリシャ文字,ロシア文字は東
雲フォントを埋め込んでいます.
フォントの一覧は以下の通りですbold体はmkboldで作成したあと
若干フォントエディタで修正を加えたものです.
milkjf_8x16.bdf(.pcf)
-milkjf-fixed-medium-r-normal--16-150-75-75-C-80-iso8859-1
milkjf_8x16r.bdf(.pcf)
-milkjf-fixed-medium-r-normal--16-150-75-75-C-80-jisx0201.1976-0
milkjf_k16.bdf(.pcf)
-milkjf-fixed-medium-r-normal--16-150-75-75-C-160-jisx0208.1990-0
milkjf_8x16B.bdf(.pcf)
-milkjf-fixed-bold-r-normal--16-150-75-75-C-80-iso8859-1
milkjf_8x16rb.bdf(.pcf)
-milkjf-fixed-bold-r-normal--16-150-75-75-C-80-jisx0201.1976-0
milkjf_k16b.bdf(.pcf)
-milkjf-fixed-bold-r-normal--16-150-75-75-C-160-jisx0208.1990-0
X Window固有の問題等に関しては以下にて
http://phe.phyas.aichi-edu.ac.jp/~cyamauch/xfonts.html
cyamauch@hst.phyas.aichi-edu.ac.jp 山内千里 Oct.1,2001

94
fonts/terminus/LICENSE Normal file
View file

@ -0,0 +1,94 @@
Copyright (c) 2014 Dimitar Toshkov Zhekov,
with Reserved Font Name "Terminus Font".
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.

20522
fonts/terminus/ter-u16n.bdf Normal file

File diff suppressed because it is too large Load diff

View file

@ -23,16 +23,17 @@ EFONT_URL=http://openlab.ring.gr.jp/efont/dist/unicode-bdf/${EFONT_FILE}
# already included in yaft
# unifont
UNIFONT_VERSION=8.0.01
UNIFONT_VERSION=11.0.02
UNIFONT_NAME=unifont-${UNIFONT_VERSION}
UNIFONT_FILE=${UNIFONT_NAME}.bdf.gz
UNIFONT_URL=http://unifoundry.com/pub/${UNIFONT_NAME}/font-builds/${UNIFONT_FILE}
UNIFONT_URL=http://unifoundry.com/pub/unifont/${UNIFONT_NAME}/font-builds/${UNIFONT_FILE}
# dina font
# dina font (fetch from ProgrammingFonts repository)
DINA_VERSION=
DINA_NAME=Dina
DINA_FILE=${DINA_NAME}.zip
DINA_URL=http://www.donationcoder.com/Software/Jibz/${DINA_NAME}/downloads/${DINA_FILE}
DINA_NAME=
DINA_FILE=
DINA_DIR=ProgrammingFonts/Dina/BDF
DINA_URL=https://github.com/ProgrammingFonts/ProgrammingFonts.git
# terminus font
TERMINUS_VERSION=4.39
@ -235,18 +236,14 @@ unifont()
dina()
{
echo -ne "creating glyph.h from dina font...\n"
wget -q -nc ${DINA_URL}
if test ! -d BDF; then
bsdtar xf ${DINA_FILE}
fi
git clone ${DINA_URL}
ln -sf $YAFT_DIR/mkfont_bdf .
ln -sf $YAFT_DIR/table .
case "$1" in
r*)
FILES=`find BDF -type f -name "*${1}.bdf" | tr "\n" " "`;;
FILES=`find ${DINA_DIR} -type f -name "*${1}.bdf" | tr "\n" " "`;;
*)
echo -ne "avalable font variations: r400-(6|8|9|10), r700-(8|9|10)\n"
exit -1;;

View file

@ -31,7 +31,7 @@ glyph.h: mkfont_bdf
# ALIAS: glyph substitution rule file (see table/alias for more detail)
# BDF1 BDF2 BDF3...: monospace bdf files (must be the same size)
# If there is more than one glyph of the same codepoint, the glyph included in the first bdf file is choosed
./mkfont_bdf table/alias fonts/milkjf_k16.bdf fonts/milkjf_8x16r.bdf fonts/milkjf_8x16.bdf > glyph.h
./mkfont_bdf table/alias fonts/milkjf/milkjf_k16.bdf fonts/milkjf/milkjf_8x16r.bdf fonts/milkjf/milkjf_8x16.bdf fonts/terminus/ter-u16n.bdf > glyph.h
yaft: yaft.c $(HDR)
# If you want to change configuration, please modify conf.h before make (see conf.h for more detail)

View file

@ -130,7 +130,7 @@ void move_cursor(struct terminal_t *term, int y_offset, int x_offset)
x = 0;
} else if (x >= term->cols) {
if (term->mode & MODE_AMRIGHT)
term->wrap_occured = true;
term->wrap_occurred = true;
x = term->cols - 1;
}
term->cursor.x = x;
@ -167,7 +167,7 @@ void set_cursor(struct terminal_t *term, int y, int x)
term->cursor.x = x;
term->cursor.y = y;
term->wrap_occured = false;
term->wrap_occurred = false;
}
const struct glyph_t *drcs_glyph(struct terminal_t *term, uint32_t code)
@ -198,23 +198,23 @@ void addch(struct terminal_t *term, uint32_t code)
width = wcwidth(code);
if (width <= 0) /* zero width: not support comibining character */
if (width <= 0) /* zero width: not support combining characters */
return;
else if (0x100000 <= code && code <= 0x10FFFD) /* unicode private area: plane 16 (DRCSMMv1) */
glyphp = drcs_glyph(term, code);
else if (code >= UCS2_CHARS /* yaft support only UCS2 */
|| term->glyph[code] == NULL /* missing glyph */
|| term->glyph[code]->width != width) /* width unmatch */
|| term->glyph[code]->width != width) /* width unmatched */
glyphp = (width == 1) ? term->glyph[SUBSTITUTE_HALF]: term->glyph[SUBSTITUTE_WIDE];
else
glyphp = term->glyph[code];
if ((term->wrap_occured && term->cursor.x == term->cols - 1) /* folding */
if ((term->wrap_occurred && term->cursor.x == term->cols - 1) /* folding */
|| (glyphp->width == WIDE && term->cursor.x == term->cols - 1)) {
set_cursor(term, term->cursor.y, 0);
move_cursor(term, 1, 0);
}
term->wrap_occured = false;
term->wrap_occurred = false;
move_cursor(term, 0, set_cell(term, term->cursor.y, term->cursor.x, glyphp));
}
@ -293,7 +293,7 @@ void reset(struct terminal_t *term)
{
term->mode = MODE_RESET;
term->mode |= (MODE_CURSOR | MODE_AMRIGHT);
term->wrap_occured = false;
term->wrap_occurred = false;
term->scroll.top = 0;
term->scroll.bottom = term->lines - 1;

View file

@ -180,7 +180,7 @@ int main(int argc, char *argv[])
if (!map_glyph(font, glist_head, &default_glyph)) {
logging(FATAL, "map_glyph() failed\n");
goto err_occured;
goto err_occurred;
}
if (!load_alias(font, argv[1]))
@ -188,18 +188,18 @@ int main(int argc, char *argv[])
if (!check_font(font, &empty_half, &empty_wide)) {
logging(FATAL, "check_font() failed\n");
goto err_occured;
goto err_occurred;
}
if (!dump_font(font)) {
logging(FATAL, "dump_font() failed\n");
goto err_occured;
goto err_occurred;
}
cleanup(glist_head, &empty_half, &empty_wide);
return EXIT_SUCCESS;
err_occured:
err_occurred:
cleanup(glist_head, &empty_half, &empty_wide);
return EXIT_FAILURE;
}

2
util.h
View file

@ -268,7 +268,7 @@ int esetenv(const char *name, const char *value, int overwrite)
return ret;
}
int eexecvp(const char *file, const char *argv[])
int eexecvp(const char *file, char *const argv[])
{
int ret;
errno = 0;

53
x/x.h
View file

@ -71,16 +71,53 @@ struct xwindow_t {
unsigned long color_palette[COLORS];
};
#define PXCACHE_SIZE (1024)
struct pxcache_entry {
uint32_t color;
unsigned long pixel;
};
static struct pxcache_entry pxcache[PXCACHE_SIZE];
static int pxcache_top = 0;
bool search_pxcache(uint32_t color, unsigned long *pixel)
{
int i;
/* usually faster to search recently allocated colors first */
for (i = pxcache_top - 1; i >= 0; i--) {
if (pxcache[i].color == color) {
*pixel = pxcache[i].pixel;
return true;
}
}
return false;
}
unsigned long color2pixel(struct xwindow_t *xw, uint32_t color)
{
XColor xc;
unsigned long pixel;
if (search_pxcache(color, &pixel)) {
return pixel;
} else {
XColor xc;
xc.red = ((color >> 16) & bit_mask[8]) << 8;
xc.green = ((color >> 8) & bit_mask[8]) << 8;
xc.blue = ((color >> 0) & bit_mask[8]) << 8;
xc.red = ((color >> 16) & bit_mask[8]) << 8;
xc.green = ((color >> 8) & bit_mask[8]) << 8;
xc.blue = ((color >> 0) & bit_mask[8]) << 8;
XAllocColor(xw->display, xw->cmap, &xc);
return xc.pixel;
if (!XAllocColor(xw->display, xw->cmap, &xc)) {
logging(WARN, "could not allocate color\n");
return BlackPixel(xw->display, DefaultScreen(xw->display));
} else {
if (pxcache_top == PXCACHE_SIZE) {
logging(WARN, "pixel cache is full. starting over\n");
pxcache_top = 0;
}
pxcache[pxcache_top].color = color;
pxcache[pxcache_top].pixel = xc.pixel;
pxcache_top++;
return xc.pixel;
}
}
}
bool xw_init(struct xwindow_t *xw)
@ -158,7 +195,7 @@ static inline void draw_line(struct xwindow_t *xw, struct terminal_t *term, int
struct cell_t *cellp;
const struct glyph_t *glyphp;
/* at first, fill all pixels of line in backgournd color */
/* at first, fill all pixels of line in background color */
XSetForeground(xw->display, xw->gc, xw->color_palette[DEFAULT_BG]);
XFillRectangle(xw->display, xw->pixbuf, xw->gc, 0, line * CELL_HEIGHT, term->width, CELL_HEIGHT);
@ -182,7 +219,7 @@ static inline void draw_line(struct xwindow_t *xw, struct terminal_t *term, int
if (cellp->width == WIDE)
bdf_padding += CELL_WIDTH;
/* check cursor positon */
/* check cursor position */
if ((term->mode & MODE_CURSOR && line == term->cursor.y)
&& (col == term->cursor.x
|| (cellp->width == WIDE && (col + 1) == term->cursor.x)

View file

@ -138,10 +138,8 @@ void (*event_func[LASTEvent])(struct xwindow_t *xw, struct terminal_t *term, XEv
[Expose] = xredraw,
};
bool fork_and_exec(int *master, int lines, int cols)
bool fork_and_exec(int *master, const char *cmd, char *const argv[], int lines, int cols)
{
extern const char *shell_cmd; /* defined in conf.h */
char *shell_env;
pid_t pid;
struct winsize ws = {.ws_row = lines, .ws_col = cols,
/* XXX: this variables are UNUSED (man tty_ioctl),
@ -153,18 +151,17 @@ bool fork_and_exec(int *master, int lines, int cols)
return false;
else if (pid == 0) { /* child */
esetenv("TERM", term_name, 1);
if ((shell_env = getenv("SHELL")) != NULL)
eexecl(shell_env);
else
eexecl(shell_cmd);
eexecvp(cmd, argv);
/* never reach here */
exit(EXIT_FAILURE);
}
return true;
}
int main()
int main(int argc, char *const argv[])
{
extern const char *shell_cmd; /* defined in conf.h */
const char *cmd;
uint8_t buf[BUFSIZE];
ssize_t size;
fd_set fds;
@ -193,7 +190,8 @@ int main()
}
/* fork and exec shell */
if (!fork_and_exec(&term.fd, term.lines, term.cols)) {
cmd = (argc < 2) ? shell_cmd: argv[1];
if (!fork_and_exec(&term.fd, cmd, argv + 1, term.lines, term.cols)) {
logging(FATAL, "forkpty failed\n");
goto fork_failed;
}

16
yaft.c
View file

@ -121,10 +121,8 @@ void tty_die(struct termios *termios_orig)
ewrite(STDIN_FILENO, "\033[?25h", 6); /* make cursor visible */
}
bool fork_and_exec(int *master, int lines, int cols)
bool fork_and_exec(int *master, const char *cmd, char *const argv[], int lines, int cols)
{
extern const char *shell_cmd; /* defined in conf.h */
char *shell_env;
pid_t pid;
struct winsize ws = {.ws_row = lines, .ws_col = cols,
/* XXX: this variables are UNUSED (man tty_ioctl),
@ -136,10 +134,7 @@ bool fork_and_exec(int *master, int lines, int cols)
return false;
else if (pid == 0) { /* child */
esetenv("TERM", term_name, 1);
if ((shell_env = getenv("SHELL")) != NULL)
eexecl(shell_env);
else
eexecl(shell_cmd);
eexecvp(cmd, argv);
/* never reach here */
exit(EXIT_FAILURE);
}
@ -156,8 +151,10 @@ int check_fds(fd_set *fds, struct timeval *tv, int input, int master)
return eselect(master + 1, fds, NULL, NULL, tv);
}
int main()
int main(int argc, char *const argv[])
{
extern const char *shell_cmd; /* defined in conf.h */
const char *cmd;
uint8_t buf[BUFSIZE];
ssize_t size;
fd_set fds;
@ -189,7 +186,8 @@ int main()
}
/* fork and exec shell */
if (!fork_and_exec(&term.fd, term.lines, term.cols)) {
cmd = (argc < 2) ? shell_cmd: argv[1];
if (!fork_and_exec(&term.fd, cmd, argv + 1, term.lines, term.cols)) {
logging(FATAL, "forkpty failed\n");
goto tty_init_failed;
}

2
yaft.h
View file

@ -156,7 +156,7 @@ struct terminal_t {
bool *line_dirty; /* dirty flag */
bool *tabstop; /* tabstop flag */
enum term_mode mode; /* for set/reset mode */
bool wrap_occured; /* whether auto wrap occured or not */
bool wrap_occurred; /* whether auto wrap occurred or not */
struct state_t state; /* for restore */
struct color_pair_t color_pair; /* color (fg, bg) */
enum char_attr attribute; /* bold, underscore, etc... */