mirror of
https://github.com/rhaleblian/dslibris.git
synced 2025-06-18 16:55:41 -04:00
Try to improve whitespacing.
This commit is contained in:
parent
adcac98cc0
commit
10b5dacc7c
32
.vscode/launch.json
vendored
Normal file
32
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "(gdb) Launch",
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}/dslibris.elf",
|
||||
"args": [],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "${workspaceFolder}",
|
||||
"environment": [],
|
||||
"externalConsole": false,
|
||||
"MIMode": "gdb",
|
||||
"targetArchitecture": "arm",
|
||||
"setupCommands": [
|
||||
// {
|
||||
// "description": "Enable pretty-printing for gdb",
|
||||
// "text": "-enable-pretty-printing",
|
||||
// "ignoreFailures": true
|
||||
// },
|
||||
// {
|
||||
// "description": "Remote debug DeSmuME",
|
||||
// "text": "--init-commands=etc/gdb-init-commands"
|
||||
// }
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
8
Makefile
8
Makefile
@ -166,16 +166,18 @@ debug:
|
||||
desmume --cflash-image $(CFLASHIMAGE) --arm9gdb=9000 $(TARGET).nds &
|
||||
sleep 2
|
||||
$(DEVKITARM)/bin/arm-none-eabi-gdb --init-command=etc/gdb-init-commands $(TARGET).elf
|
||||
# Stop both GDB and DeSMuME when done.
|
||||
|
||||
mount: $(CFLASHIMAGE) $(MOUNTPOINT)
|
||||
mount -o loop $(CFLASHIMAGE) $(MOUNTPOINT)
|
||||
- sudo mount -o loop $(CFLASHIMAGE) $(MOUNTPOINT)
|
||||
ls $(MOUNTPOINT)
|
||||
|
||||
umount:
|
||||
umount $(MOUNTPOINT)
|
||||
sudo umount $(MOUNTPOINT)
|
||||
rmdir $(MOUNTPOINT)
|
||||
|
||||
# Fetch the log from inside the cflash image.
|
||||
log: mount
|
||||
cp $(MOUNTPOINT)/$(TARGET).log .
|
||||
- sudo mount -o loop $(CFLASHIMAGE) $(MOUNTPOINT)
|
||||
sudo mv $(MOUNTPOINT)/$(TARGET).log .
|
||||
make umount
|
||||
|
Binary file not shown.
@ -177,7 +177,7 @@ public:
|
||||
//! Not used ... really.
|
||||
struct { u8 r; u8 g; u8 b; } bgcolor;
|
||||
bool usebgcolor;
|
||||
u16 *screen, *screenleft, *screenright;
|
||||
u16 *screen, *screenleft, *screenright, *offscreen;
|
||||
struct {
|
||||
int left, right, top, bottom;
|
||||
} margin;
|
||||
@ -231,6 +231,7 @@ public:
|
||||
void ClearRect(u16 xl, u16 yl, u16 xh, u16 yh);
|
||||
void ClearScreen();
|
||||
void ClearScreen(u16*, u8, u8, u8);
|
||||
void CopyScreen(u16 *src, u16 *dst);
|
||||
void SwapScreens();
|
||||
|
||||
void PrintChar(u32 ucs);
|
||||
|
@ -19,10 +19,6 @@ along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _LOG_H_
|
||||
#define _LOG_H_
|
||||
|
||||
/*
|
||||
* log.h
|
||||
*
|
||||
@ -30,10 +26,10 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
* Author: rhaleblian
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
void Log(const char *msg);
|
||||
void Log(std::string msg);
|
||||
void Log(const char *format, const char *msg);
|
||||
|
||||
#endif
|
||||
|
@ -38,10 +38,10 @@
|
||||
#define SPLASH_LEFT 28
|
||||
#define SPLASH_TOP 44
|
||||
|
||||
#define FONTDIR "/font/"
|
||||
#define BOOKDIR "/book/"
|
||||
#define LOGFILEPATH "/dslibris.log"
|
||||
#define PREFSPATH "/dslibris.xml"
|
||||
#define FONTDIR "Font"
|
||||
#define BOOKDIR "Book"
|
||||
#define LOGFILEPATH "dslibris.log"
|
||||
#define PREFSPATH "dslibris.xml"
|
||||
|
||||
#define FONTREGULARFILE "LiberationSerif-Regular.ttf"
|
||||
#define FONTBOLDFILE "LiberationSerif-Bold.ttf"
|
||||
|
@ -61,17 +61,25 @@ void Page::Draw()
|
||||
|
||||
void Page::Draw(Text *ts)
|
||||
{
|
||||
//! Write directly to video memory, for both screens.
|
||||
ts->SetScreen(ts->screenleft);
|
||||
ts->ClearScreen();
|
||||
ts->SetScreen(ts->screenright);
|
||||
ts->ClearScreen();
|
||||
ts->SetScreen(ts->screenleft);
|
||||
iprintf("hi\n");
|
||||
//! Write to offscreen buffer, then blit to video memory, for both screens.
|
||||
ts->InitPen();
|
||||
ts->linebegan = false;
|
||||
ts->italic = false;
|
||||
ts->bold = false;
|
||||
|
||||
|
||||
#ifdef OFFSCREEN
|
||||
// Draw offscreen.
|
||||
auto pushscreen = ts->screen;
|
||||
ts->SetScreen(ts->offscreen);
|
||||
#else
|
||||
ts->SetScreen(ts->screenleft);
|
||||
#endif
|
||||
ts->SetScreen(ts->screenright);
|
||||
ts->ClearScreen();
|
||||
ts->SetScreen(ts->screenleft);
|
||||
ts->ClearScreen();
|
||||
|
||||
u16 i=0;
|
||||
while (i<length)
|
||||
{
|
||||
@ -81,11 +89,19 @@ void Page::Draw(Text *ts)
|
||||
// line break, page breaking if necessary
|
||||
i++;
|
||||
|
||||
if (ts->GetPenY() + ts->GetHeight() + ts->linespacing
|
||||
if (ts->GetPenY() + ts->GetHeight() + ts->linespacing
|
||||
> ts->display.height - ts->margin.bottom)
|
||||
{
|
||||
// Move to right page
|
||||
if(ts->GetScreen() == ts->screenleft) {
|
||||
#ifdef OFFSCREEN
|
||||
ts->SetScreen(ts->screenleft);
|
||||
ts->CopyScreen(ts->offscreen, ts->screen);
|
||||
ts->SetScreen(ts->offscreen);
|
||||
#else
|
||||
ts->SetScreen(ts->screenright);
|
||||
#endif
|
||||
ts->ClearScreen();
|
||||
ts->InitPen();
|
||||
ts->linebegan = false;
|
||||
}
|
||||
@ -124,7 +140,13 @@ void Page::Draw(Text *ts)
|
||||
ts->linebegan = true;
|
||||
}
|
||||
}
|
||||
|
||||
DrawNumber(ts);
|
||||
#ifdef OFFSCREEN
|
||||
ts->SetScreen(ts->screenright);
|
||||
ts->CopyScreen(ts->offscreen, ts->screen);
|
||||
ts->SetScreen(pushscreen);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Page::DrawNumber(Text *ts)
|
||||
|
@ -37,6 +37,10 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
extern char msg[];
|
||||
std::stringstream ss;
|
||||
|
||||
void Text::CopyScreen(u16 *src, u16 *dst) {
|
||||
memcpy(src, dst, display.width * display.height * sizeof(u16));
|
||||
}
|
||||
|
||||
Text::Text()
|
||||
{
|
||||
display.height = PAGE_HEIGHT;
|
||||
@ -45,6 +49,7 @@ Text::Text()
|
||||
screenleft = (u16*)BG_BMP_RAM_SUB(0);
|
||||
screenright = (u16*)BG_BMP_RAM(0);
|
||||
screen = screenleft;
|
||||
offscreen = new u16[display.width * display.height];
|
||||
margin.left = MARGINLEFT;
|
||||
margin.right = MARGINRIGHT;
|
||||
margin.top = MARGINTOP;
|
||||
@ -53,7 +58,11 @@ Text::Text()
|
||||
bgcolor.g = 31;
|
||||
bgcolor.b = 15;
|
||||
usebgcolor = false;
|
||||
|
||||
invert = false;
|
||||
justify = false;
|
||||
linespacing = 0;
|
||||
ftc = false;
|
||||
initialized = false;
|
||||
imagetype.face_id = (FTC_FaceID)&face_id;
|
||||
imagetype.flags = FT_LOAD_DEFAULT;
|
||||
imagetype.height = pixelsize;
|
||||
@ -70,37 +79,34 @@ Text::Text()
|
||||
hit = false;
|
||||
linebegan = false;
|
||||
codeprev = 0;
|
||||
|
||||
bold = false;
|
||||
italic = false;
|
||||
invert = false;
|
||||
justify = false;
|
||||
linespacing = 0;
|
||||
|
||||
// Caching statistics.
|
||||
stats_hits = 0;
|
||||
stats_misses = 0;
|
||||
|
||||
ftc = false;
|
||||
initialized = false;
|
||||
|
||||
ClearScreen(offscreen, 255, 255, 255);
|
||||
ss.clear();
|
||||
}
|
||||
|
||||
Text::~Text()
|
||||
{
|
||||
ClearCache();
|
||||
// framebuffers
|
||||
free(offscreen);
|
||||
|
||||
// homemade cache
|
||||
ClearCache();
|
||||
for(map<FT_Face, Cache*>::iterator iter = textCache.begin();
|
||||
iter != textCache.end(); iter++) {
|
||||
delete iter->second;
|
||||
}
|
||||
|
||||
textCache.clear();
|
||||
|
||||
// FreeType
|
||||
for (map<u8, FT_Face>::iterator iter = faces.begin(); iter != faces.end(); iter++) {
|
||||
FT_Done_Face(iter->second);
|
||||
}
|
||||
|
||||
FT_Done_FreeType(library);
|
||||
}
|
||||
|
||||
@ -134,7 +140,7 @@ FT_Error Text::InitFreeTypeCache(void) {
|
||||
if(error) return error;
|
||||
app->Log("ok\n");
|
||||
|
||||
sprintf(face_id.file_path, "/font/%s", filenames[TEXT_STYLE_REGULAR].c_str());
|
||||
sprintf(face_id.file_path, "%s/%s", FONTDIR, filenames[TEXT_STYLE_REGULAR].c_str());
|
||||
face_id.face_index = 0;
|
||||
sprintf(msg, "%s %s %d\n", filenames[TEXT_STYLE_REGULAR].c_str(), face_id.file_path, face_id.face_index);
|
||||
app->Log(msg);
|
||||
@ -159,7 +165,7 @@ FT_Error Text::InitFreeTypeCache(void) {
|
||||
}
|
||||
|
||||
FT_Error Text::CreateFace(int style) {
|
||||
std::string path = std::string("/font/") + filenames[style];
|
||||
std::string path = std::string(FONTDIR) + "/" + filenames[style];
|
||||
FT_Error err = FT_New_Face(library, path.c_str(), 0, &face);
|
||||
if (!err)
|
||||
faces[style] = face;
|
||||
@ -652,12 +658,12 @@ void Text::PrintChar(u32 ucs, FT_Face face) {
|
||||
// height = glyph->bitmap.rows;
|
||||
// advance = width;
|
||||
|
||||
ss.clear();
|
||||
ss << " err " << error
|
||||
<< " glyph_index " << glyph_index << " glyph " << glyph
|
||||
<< " width " << width << " height " << height << " advance " << advance
|
||||
<< std::endl;
|
||||
app->Log(ss.str());
|
||||
// ss.clear();
|
||||
// ss << " err " << error
|
||||
// << " glyph_index " << glyph_index << " glyph " << glyph
|
||||
// << " width " << width << " height " << height << " advance " << advance
|
||||
// << std::endl;
|
||||
// app->Log(ss.str());
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -684,16 +690,6 @@ void Text::PrintChar(u32 ucs, FT_Face face) {
|
||||
advance = glyph->advance.x >> 6;
|
||||
buffer = bitmap.buffer;
|
||||
}
|
||||
//sprintf(msg, "%ld %d %d %d %d %d\n", ucs, bx, by, width, height, advance);
|
||||
//app->Log(msg);
|
||||
|
||||
// ss.clear();
|
||||
// ss << "buffer ";
|
||||
// for(auto i=0; i<128; i++) {
|
||||
// ss << " " << buffer[i];
|
||||
// }
|
||||
// ss << std::endl;
|
||||
// app->Log(ss.str());
|
||||
|
||||
#ifdef EXPERIMENTAL_KERNING
|
||||
// kern.
|
||||
@ -723,21 +719,16 @@ void Text::PrintChar(u32 ucs, FT_Face face) {
|
||||
|
||||
// render to framebuffer.
|
||||
|
||||
// if (firsttime) {
|
||||
// std::stringstream ss;
|
||||
// ss << pen.x << " " << pen.y << " " << bx << " " << by << " " << width << " " << height << std::endl;
|
||||
// app->Log("%s\n", ss.str().c_str());
|
||||
// }
|
||||
|
||||
#ifdef DEBUG
|
||||
// DEBUG Mark the pen position.
|
||||
// screen[pen.y*display.height+pen.x] = RGB15(0, 0, 0) | BIT(15);
|
||||
screen[pen.y*display.height+pen.x] = RGB15(0, 0, 0) | BIT(15);
|
||||
#endif
|
||||
|
||||
u16 gx, gy;
|
||||
for (gy=0; gy<height; gy++) {
|
||||
for (gx=0; gx<width; gx++) {
|
||||
u8 a = buffer[gy*width+gx];
|
||||
if (a) {
|
||||
// ss << " " << a;
|
||||
u16 sx = (pen.x+gx+bx);
|
||||
u16 sy = (pen.y+gy-by);
|
||||
if(usebgcolor) {
|
||||
@ -753,7 +744,8 @@ void Text::PrintChar(u32 ucs, FT_Face face) {
|
||||
if (invert) l = a >> 3;
|
||||
else l = (255-a) >> 3;
|
||||
#ifdef DEBUG_CACHE
|
||||
if(!hit)
|
||||
// Draw cache hits in red.
|
||||
if(!hit)
|
||||
screen[sy*display.height+sx] = RGB15(l,0,0) | BIT(15);
|
||||
else
|
||||
#endif
|
||||
@ -763,14 +755,12 @@ void Text::PrintChar(u32 ucs, FT_Face face) {
|
||||
}
|
||||
}
|
||||
|
||||
// app->Log(ss.str());
|
||||
// ss.clear();
|
||||
|
||||
pen.x += advance;
|
||||
codeprev = ucs;
|
||||
|
||||
// Release the glyph storage.
|
||||
if (ftc && anode)
|
||||
FTC_Node_Unref(anode, cache.manager);
|
||||
// firsttime = false;
|
||||
}
|
||||
|
||||
bool Text::PrintNewLine(void) {
|
||||
@ -841,7 +831,7 @@ void Text::PrintStatusMessage(const char *msg)
|
||||
bool invert = GetInvert();
|
||||
|
||||
screen = screenleft;
|
||||
SetInvert(false);
|
||||
SetInvert(invert);
|
||||
SetPixelSize(10);
|
||||
SetPen(16, PAGE_HEIGHT-32);
|
||||
PrintString(msg);
|
||||
|
@ -4,26 +4,22 @@
|
||||
* Created on: Jul 11, 2009
|
||||
* Author: rhaleblian
|
||||
*/
|
||||
#include <nds.h>
|
||||
#include <fat.h>
|
||||
#include <stdio.h>
|
||||
#include "main.h"
|
||||
#include "log.h"
|
||||
|
||||
#define LOGFILEPATH "dslibris.log"
|
||||
|
||||
void Log(const char *msg)
|
||||
{
|
||||
Log("%s",msg);
|
||||
Log("%s", msg);
|
||||
}
|
||||
|
||||
void Log(std::string msg)
|
||||
{
|
||||
Log("%s",msg.c_str());
|
||||
Log("%s", msg.c_str());
|
||||
}
|
||||
|
||||
void Log(const char *format, const char *msg)
|
||||
{
|
||||
FILE *logfile = fopen(LOGFILEPATH,"a");
|
||||
FILE *logfile = fopen(LOGFILEPATH, "a");
|
||||
fprintf(logfile,format,msg);
|
||||
fclose(logfile);
|
||||
}
|
||||
|
219
source/main.cpp
219
source/main.cpp
@ -442,34 +442,85 @@ void title_end_hndl(void *userdata, const char *el)
|
||||
parsedata_t *data = (parsedata_t*)userdata;
|
||||
if(!strcmp(el,"title")) data->book->SetTitle(title);
|
||||
if(!strcmp(el,"head")) data->status = 1; // done.
|
||||
app->parse_pop(data);
|
||||
app->parse_pop(data);
|
||||
}
|
||||
|
||||
// Expat callbacks for parsing full text follow. //
|
||||
|
||||
void linefeed(parsedata_t *p) {
|
||||
Text *ts = app->ts;
|
||||
p->buf[p->buflen++] = '\n';
|
||||
p->pen.x = MARGINLEFT;
|
||||
p->pen.y += ts->GetHeight() + ts->linespacing;
|
||||
p->linebegan = false;
|
||||
}
|
||||
|
||||
bool blankline(parsedata_t *p) {
|
||||
// Was the preceding text a blenk line?
|
||||
return p->buflen > 1 && p->buf[p->buflen] == '\n' && p->buf[p->buflen-1] == '\n';
|
||||
}
|
||||
|
||||
void start_hndl(void *data, const char *el, const char **attr)
|
||||
{
|
||||
//! Expat callback, when starting an element.
|
||||
|
||||
parsedata_t *p = (parsedata_t*)data;
|
||||
|
||||
if (!strcmp(el,"html")) app->parse_push(p,TAG_HTML);
|
||||
else if (!strcmp(el,"body")) app->parse_push(p,TAG_BODY);
|
||||
else if (!strcmp(el,"div")) app->parse_push(p,TAG_DIV);
|
||||
else if (!strcmp(el,"dt")) app->parse_push(p,TAG_DT);
|
||||
else if (!strcmp(el,"h1")) {
|
||||
app->parse_push(p,TAG_H1);
|
||||
bool lf = !blankline(p);
|
||||
p->buf[p->buflen] = TEXT_BOLD_ON;
|
||||
p->buflen++;
|
||||
p->pos++;
|
||||
p->bold = true;
|
||||
if (lf) linefeed(p);
|
||||
}
|
||||
else if (!strcmp(el,"h2")) {
|
||||
app->parse_push(p,TAG_H2);
|
||||
bool lf = !blankline(p);
|
||||
p->buf[p->buflen] = TEXT_BOLD_ON;
|
||||
p->buflen++;
|
||||
p->pos++;
|
||||
p->bold = true;
|
||||
if (lf) linefeed(p);
|
||||
}
|
||||
else if (!strcmp(el,"h3")) {
|
||||
app->parse_push(p,TAG_H3);
|
||||
linefeed(p);
|
||||
}
|
||||
else if (!strcmp(el,"h4")) {
|
||||
app->parse_push(p,TAG_H4);
|
||||
if (!blankline(p)) linefeed(p);
|
||||
}
|
||||
else if (!strcmp(el,"h5")) {
|
||||
app->parse_push(p,TAG_H5);
|
||||
if (!blankline(p)) linefeed(p);
|
||||
}
|
||||
else if (!strcmp(el,"h6")) {
|
||||
app->parse_push(p,TAG_H6);
|
||||
if (!blankline(p)) linefeed(p);
|
||||
}
|
||||
else if (!strcmp(el,"h2")) app->parse_push(p,TAG_H2);
|
||||
else if (!strcmp(el,"h3")) app->parse_push(p,TAG_H3);
|
||||
else if (!strcmp(el,"h4")) app->parse_push(p,TAG_H4);
|
||||
else if (!strcmp(el,"h5")) app->parse_push(p,TAG_H5);
|
||||
else if (!strcmp(el,"h6")) app->parse_push(p,TAG_H6);
|
||||
else if (!strcmp(el,"head")) app->parse_push(p,TAG_HEAD);
|
||||
else if (!strcmp(el,"ol")) app->parse_push(p,TAG_OL);
|
||||
else if (!strcmp(el,"p")) app->parse_push(p,TAG_P);
|
||||
else if (!strcmp(el,"p")) {
|
||||
app->parse_push(p,TAG_P);
|
||||
if (!blankline(p)) {
|
||||
// for(int i=0;i<app->paraspacing;i++)
|
||||
// {
|
||||
// linefeed(p);
|
||||
// }
|
||||
// for(int i=0;i<app->paraindent;i++)
|
||||
// {
|
||||
// p->buf[p->buflen++] = ' ';
|
||||
// p->pen.x += ts->GetAdvance(' ');
|
||||
// }
|
||||
linefeed(p);
|
||||
}
|
||||
}
|
||||
else if (!strcmp(el,"pre")) app->parse_push(p,TAG_PRE);
|
||||
else if (!strcmp(el,"script")) app->parse_push(p,TAG_SCRIPT);
|
||||
else if (!strcmp(el,"style")) app->parse_push(p,TAG_STYLE);
|
||||
@ -638,101 +689,27 @@ void end_hndl(void *data, const char *el)
|
||||
{
|
||||
parsedata_t *p = (parsedata_t *)data;
|
||||
Text *ts = app->ts;
|
||||
if (
|
||||
!strcmp(el,"br")
|
||||
|| !strcmp(el,"div")
|
||||
|| !strcmp(el,"dt")
|
||||
|| !strcmp(el,"h1")
|
||||
|| !strcmp(el,"h2")
|
||||
|| !strcmp(el,"h3")
|
||||
|| !strcmp(el,"h4")
|
||||
|| !strcmp(el,"h5")
|
||||
|| !strcmp(el,"h6")
|
||||
|| !strcmp(el,"hr")
|
||||
|| !strcmp(el,"li")
|
||||
|| !strcmp(el,"p")
|
||||
|| !strcmp(el,"pre")
|
||||
|| !strcmp(el,"ol")
|
||||
|| !strcmp(el,"td")
|
||||
|| !strcmp(el,"ul"))
|
||||
{
|
||||
if(p->linebegan || !strcmp(el,"br")) {
|
||||
p->linebegan = false;
|
||||
p->buf[p->buflen] = '\n';
|
||||
p->buflen++;
|
||||
p->pen.x = MARGINLEFT;
|
||||
p->pen.y += ts->GetHeight() + ts->linespacing;
|
||||
if (!strcmp(el,"p"))
|
||||
{
|
||||
for(int i=0;i<app->paraspacing;i++)
|
||||
{
|
||||
p->buf[p->buflen++] = '\n';
|
||||
p->pen.x = MARGINLEFT;
|
||||
p->pen.y += ts->GetHeight() + ts->linespacing;
|
||||
}
|
||||
for(int i=0;i<app->paraindent;i++)
|
||||
{
|
||||
p->buf[p->buflen++] = ' ';
|
||||
p->pen.x += ts->GetAdvance(' ');
|
||||
}
|
||||
}
|
||||
else if(!strcmp(el,"h1")) {
|
||||
p->buf[p->buflen] = '\n';
|
||||
p->buflen++;
|
||||
p->linebegan = false;
|
||||
p->pen.x = ts->margin.left;
|
||||
p->pen.y += ts->GetHeight() + ts->linespacing;
|
||||
p->buf[p->buflen] = TEXT_BOLD_OFF;
|
||||
p->buflen++;
|
||||
p->bold = false;
|
||||
} else if (
|
||||
!strcmp(el,"h2")
|
||||
|| !strcmp(el,"h3")
|
||||
|| !strcmp(el,"h4")
|
||||
|| !strcmp(el,"h5")
|
||||
|| !strcmp(el,"h6")
|
||||
|| !strcmp(el,"hr")
|
||||
|| !strcmp(el,"pre")
|
||||
)
|
||||
{
|
||||
p->buf[p->buflen] = '\n';
|
||||
p->buflen++;
|
||||
p->linebegan = false;
|
||||
p->pen.x = ts->margin.left;
|
||||
p->pen.y += ts->GetHeight() + ts->linespacing;
|
||||
}
|
||||
if (p->pen.y > (ts->display.height - ts->margin.bottom))
|
||||
{
|
||||
if (p->screen == 1)
|
||||
{
|
||||
// End of right screen; end of page.
|
||||
// Copy in buffered char data into a new page.
|
||||
Page *page = p->book->AppendPage();
|
||||
page->SetBuffer(p->buf, p->buflen);
|
||||
if (app->cache)
|
||||
WriteBufferToCache(p);
|
||||
p->buflen = 0;
|
||||
if (p->italic) p->buf[p->buflen++] = TEXT_ITALIC_ON;
|
||||
if (p->bold )p->buf[p->buflen++] = TEXT_BOLD_ON;
|
||||
p->screen = 0;
|
||||
}
|
||||
else
|
||||
// End of left screen; same page, next screen.
|
||||
p->screen = 1;
|
||||
p->pen.x = ts->margin.left;
|
||||
p->pen.y = ts->margin.top + ts->GetHeight();
|
||||
p->linebegan = false;
|
||||
}
|
||||
}
|
||||
} else if (!strcmp(el,"body")) {
|
||||
|
||||
if (!strcmp(el,"body")) {
|
||||
// Save off our last page.
|
||||
Page *page = p->book->AppendPage();
|
||||
page->SetBuffer(p->buf,p->buflen);
|
||||
if (app->cache)
|
||||
WriteBufferToCache(p);
|
||||
p->buflen = 0;
|
||||
// Retain styles across the page.
|
||||
if (p->italic) p->buf[p->buflen++] = TEXT_ITALIC_ON;
|
||||
if (p->bold )p->buf[p->buflen++] = TEXT_BOLD_ON;
|
||||
if (p->bold) p->buf[p->buflen++] = TEXT_BOLD_ON;
|
||||
app->parse_pop(p);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!strcmp(el,"br")) {
|
||||
linefeed(p);
|
||||
} else if (!strcmp(el,"p")) {
|
||||
linefeed(p);
|
||||
linefeed(p);
|
||||
} else if(!strcmp(el,"div")) {
|
||||
} else if (!strcmp(el, "strong") || !strcmp(el, "b")) {
|
||||
p->buf[p->buflen] = TEXT_BOLD_OFF;
|
||||
p->buflen++;
|
||||
@ -741,6 +718,58 @@ void end_hndl(void *data, const char *el)
|
||||
p->buf[p->buflen] = TEXT_ITALIC_OFF;
|
||||
p->buflen++;
|
||||
p->italic = false;
|
||||
} else if(!strcmp(el,"h1")) {
|
||||
p->buf[p->buflen] = TEXT_BOLD_OFF;
|
||||
p->buflen++;
|
||||
p->bold = false;
|
||||
linefeed(p);
|
||||
linefeed(p);
|
||||
} else if (!strcmp(el,"h2")) {
|
||||
p->buf[p->buflen] = TEXT_BOLD_OFF;
|
||||
p->buflen++;
|
||||
p->bold = false;
|
||||
linefeed(p);
|
||||
} else if (
|
||||
!strcmp(el,"h3")
|
||||
|| !strcmp(el,"h4")
|
||||
|| !strcmp(el,"h5")
|
||||
|| !strcmp(el,"h6")
|
||||
|| !strcmp(el,"hr")
|
||||
|| !strcmp(el,"pre")
|
||||
) {
|
||||
linefeed(p);
|
||||
linefeed(p);
|
||||
} else if (
|
||||
!strcmp(el, "li")
|
||||
|| !strcmp(el, "ul")
|
||||
|| !strcmp(el, "ol")
|
||||
) {
|
||||
linefeed(p);
|
||||
}
|
||||
|
||||
app->parse_pop(p);
|
||||
|
||||
if (p->pen.y > (ts->display.height - ts->margin.bottom))
|
||||
{
|
||||
if (p->screen == 1)
|
||||
{
|
||||
// End of right screen; end of page.
|
||||
// Copy in buffered char data into a new page.
|
||||
Page *page = p->book->AppendPage();
|
||||
page->SetBuffer(p->buf, p->buflen);
|
||||
if (app->cache)
|
||||
WriteBufferToCache(p);
|
||||
p->buflen = 0;
|
||||
if (p->italic) p->buf[p->buflen++] = TEXT_ITALIC_ON;
|
||||
if (p->bold )p->buf[p->buflen++] = TEXT_BOLD_ON;
|
||||
p->screen = 0;
|
||||
}
|
||||
else
|
||||
// End of left screen; same page, next screen.
|
||||
p->screen = 1;
|
||||
p->pen.x = ts->margin.left;
|
||||
p->pen.y = ts->margin.top + ts->GetHeight();
|
||||
p->linebegan = false;
|
||||
}
|
||||
|
||||
app->parse_pop(p);
|
||||
|
Loading…
Reference in New Issue
Block a user