mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-31 17:31:11 +02:00
yaft: refactor term_init() into init() function
Origin commit data
------------------
Commit: 8b6e3c0724
Author: Stefan Seyfried <seife@tuxbox-git.slipkontur.de>
Date: 2018-01-28 (Sun, 28 Jan 2018)
This commit is contained in:
committed by
vanhofen
parent
b33fc3a25a
commit
a00a88d75c
@@ -114,7 +114,57 @@ bool YaFT_p::init()
|
|||||||
fb.dy_max = -1;
|
fb.dy_max = -1;
|
||||||
screeninfo = fb.cfb->getScreenInfo();
|
screeninfo = fb.cfb->getScreenInfo();
|
||||||
|
|
||||||
return term_init(fb.width, fb.height);
|
width = fb.width;
|
||||||
|
height = fb.height;
|
||||||
|
int fw, fh;
|
||||||
|
#define LINES 30
|
||||||
|
#define COLS 100
|
||||||
|
int scalex = 64, scaley = 64;
|
||||||
|
/*
|
||||||
|
* try to get a font size that fits about LINES x COLS into the terminal.
|
||||||
|
* NOTE: this is not guaranteed to work! Terminal might be smaller or bigger
|
||||||
|
*/
|
||||||
|
for (int i = 0; i < 2; i++) {
|
||||||
|
delete font;
|
||||||
|
delete fr;
|
||||||
|
fr = new FBFontRenderClass(scalex, scaley);
|
||||||
|
fontstyle = fr->AddFont(ttx_font_file.c_str());
|
||||||
|
font = fr->getFont(fr->getFamily(ttx_font_file.c_str()).c_str(), fontstyle, height / LINES);
|
||||||
|
fw = font->getWidth();
|
||||||
|
fh = font->getHeight();
|
||||||
|
fprintf(stderr, "FONT[%d]: fw %d fh: %d sx %d sy %d w %d h %d\n", i, fw, fh, scalex, scaley, width, height);
|
||||||
|
scalex = 64 * width / (fw * COLS) + 1;
|
||||||
|
scaley = 64 * height / (fh * LINES) + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
CELL_WIDTH = fw;
|
||||||
|
CELL_HEIGHT = fh;
|
||||||
|
lines = height / CELL_HEIGHT;
|
||||||
|
cols = width / CELL_WIDTH;
|
||||||
|
|
||||||
|
logging(NORMAL, "terminal cols:%d lines:%d\n", cols, lines);
|
||||||
|
|
||||||
|
/* allocate memory */
|
||||||
|
line_dirty.reserve(lines);
|
||||||
|
tabstop.reserve(cols);
|
||||||
|
esc.buf.reserve(1024);
|
||||||
|
|
||||||
|
cells.clear();
|
||||||
|
std::vector<cell_t> line;
|
||||||
|
line.resize(cols);
|
||||||
|
for (int i = 0; i < lines; i++)
|
||||||
|
cells.push_back(line);
|
||||||
|
line.resize(0);
|
||||||
|
|
||||||
|
/* initialize palette */
|
||||||
|
for (int i = 0; i < COLORS; i++)
|
||||||
|
virtual_palette[i] = color_list[i];
|
||||||
|
palette_modified = true; /* first refresh() will initialize real_palette[] */
|
||||||
|
|
||||||
|
/* reset terminal */
|
||||||
|
reset();
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void YaFT_p::erase_cell(int y, int x)
|
void YaFT_p::erase_cell(int y, int x)
|
||||||
@@ -386,61 +436,6 @@ void YaFT_p::term_die(void)
|
|||||||
cells.clear();
|
cells.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool YaFT_p::term_init(int w, int h)
|
|
||||||
{
|
|
||||||
width = w;
|
|
||||||
height = h;
|
|
||||||
int fw, fh;
|
|
||||||
#define LINES 30
|
|
||||||
#define COLS 100
|
|
||||||
int scalex = 64, scaley = 64;
|
|
||||||
/*
|
|
||||||
* try to get a font size that fits about LINES x COLS into the terminal.
|
|
||||||
* NOTE: this is not guaranteed to work! Terminal might be smaller or bigger
|
|
||||||
*/
|
|
||||||
for (int i = 0; i < 2; i++) {
|
|
||||||
delete font;
|
|
||||||
delete fr;
|
|
||||||
fr = new FBFontRenderClass(scalex, scaley);
|
|
||||||
fontstyle = fr->AddFont(ttx_font_file.c_str());
|
|
||||||
font = fr->getFont(fr->getFamily(ttx_font_file.c_str()).c_str(), fontstyle, height / LINES);
|
|
||||||
fw = font->getWidth();
|
|
||||||
fh = font->getHeight();
|
|
||||||
fprintf(stderr, "FONT[%d]: fw %d fh: %d sx %d sy %d w %d h %d\n", i, fw, fh, scalex, scaley, width, height);
|
|
||||||
scalex = 64 * width / (fw * COLS) + 1;
|
|
||||||
scaley = 64 * height / (fh * LINES) + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
CELL_WIDTH = fw;
|
|
||||||
CELL_HEIGHT = fh;
|
|
||||||
lines = height / CELL_HEIGHT;
|
|
||||||
cols = width / CELL_WIDTH;
|
|
||||||
|
|
||||||
logging(NORMAL, "terminal cols:%d lines:%d\n", cols, lines);
|
|
||||||
|
|
||||||
/* allocate memory */
|
|
||||||
line_dirty.reserve(lines);
|
|
||||||
tabstop.reserve(cols);
|
|
||||||
esc.buf.reserve(1024);
|
|
||||||
|
|
||||||
cells.clear();
|
|
||||||
std::vector<cell_t> line;
|
|
||||||
line.resize(cols);
|
|
||||||
for (int i = 0; i < lines; i++)
|
|
||||||
cells.push_back(line);
|
|
||||||
line.resize(0);
|
|
||||||
|
|
||||||
/* initialize palette */
|
|
||||||
for (int i = 0; i < COLORS; i++)
|
|
||||||
virtual_palette[i] = color_list[i];
|
|
||||||
palette_modified = true; /* first refresh() will initialize real_palette[] */
|
|
||||||
|
|
||||||
/* reset terminal */
|
|
||||||
reset();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void YaFT_p::parse(uint8_t *buf, int size)
|
void YaFT_p::parse(uint8_t *buf, int size)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
|
@@ -199,7 +199,6 @@ class YaFT_p
|
|||||||
void reset_charset(void);
|
void reset_charset(void);
|
||||||
void reset(void);
|
void reset(void);
|
||||||
void term_die(void);
|
void term_die(void);
|
||||||
bool term_init(int width, int height);
|
|
||||||
void utf8_charset(uint8_t ch);
|
void utf8_charset(uint8_t ch);
|
||||||
void control_character(uint8_t ch);
|
void control_character(uint8_t ch);
|
||||||
void esc_sequence(uint8_t ch);
|
void esc_sequence(uint8_t ch);
|
||||||
|
Reference in New Issue
Block a user