mirror of
https://github.com/jeremysrand/md2teach.git
synced 2025-02-10 13:30:38 +00:00
Split out the work in progress on styling the text into its own file.
This commit is contained in:
parent
2c6c191af8
commit
6f5cefe417
@ -18,6 +18,7 @@
|
||||
9D65330D2626246700105D50 /* md4c.c in Sources */ = {isa = PBXBuildFile; fileRef = 9D65330C2626246700105D50 /* md4c.c */; };
|
||||
9D8125DD2634A584002F05F5 /* io.c in Sources */ = {isa = PBXBuildFile; fileRef = 9D8125DC2634A584002F05F5 /* io.c */; };
|
||||
9D8125E42634AC4A002F05F5 /* translate.c in Sources */ = {isa = PBXBuildFile; fileRef = 9D8125E32634AC4A002F05F5 /* translate.c */; };
|
||||
9D8125F32634B4D4002F05F5 /* style.c in Sources */ = {isa = PBXBuildFile; fileRef = 9D8125F22634B4D4002F05F5 /* style.c */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXCopyFilesBuildPhase section */
|
||||
@ -56,6 +57,8 @@
|
||||
9D8125DC2634A584002F05F5 /* io.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = io.c; sourceTree = "<group>"; };
|
||||
9D8125E22634AC4A002F05F5 /* translate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = translate.h; sourceTree = "<group>"; };
|
||||
9D8125E32634AC4A002F05F5 /* translate.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = translate.c; sourceTree = "<group>"; };
|
||||
9D8125F12634B4D4002F05F5 /* style.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = style.h; sourceTree = "<group>"; };
|
||||
9D8125F22634B4D4002F05F5 /* style.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = style.c; sourceTree = "<group>"; };
|
||||
9DDFC7B026269D23006D6E71 /* LICENSE */ = {isa = PBXFileReference; lastKnownFileType = text; path = LICENSE; sourceTree = "<group>"; };
|
||||
9DDFC7B126269D3F006D6E71 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
|
||||
9DDFC7B42627E081006D6E71 /* test.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = test.md; sourceTree = "<group>"; };
|
||||
@ -106,6 +109,8 @@
|
||||
9D8125DC2634A584002F05F5 /* io.c */,
|
||||
9D8125E22634AC4A002F05F5 /* translate.h */,
|
||||
9D8125E32634AC4A002F05F5 /* translate.c */,
|
||||
9D8125F12634B4D4002F05F5 /* style.h */,
|
||||
9D8125F22634B4D4002F05F5 /* style.c */,
|
||||
9D65330C2626246700105D50 /* md4c.c */,
|
||||
9D65330B2626246700105D50 /* md4c.h */,
|
||||
9D6532EE2626240800105D50 /* Makefile */,
|
||||
@ -239,6 +244,7 @@
|
||||
9D8125E42634AC4A002F05F5 /* translate.c in Sources */,
|
||||
9D6532EF2626240800105D50 /* Makefile in Sources */,
|
||||
9D8125DD2634A584002F05F5 /* io.c in Sources */,
|
||||
9D8125F32634B4D4002F05F5 /* style.c in Sources */,
|
||||
9D6532ED2626240800105D50 /* main.c in Sources */,
|
||||
9D65330D2626246700105D50 /* md4c.c in Sources */,
|
||||
);
|
||||
|
@ -7,19 +7,14 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <resources.h>
|
||||
#include <textedit.h>
|
||||
|
||||
#include "io.h"
|
||||
#include "main.h"
|
||||
#include "translate.h"
|
||||
#include "md4c.h"
|
||||
|
||||
|
||||
// GS_TODO - How big does the stack need to be? In looking over the code,
|
||||
// I don't see massive stack frames due to large globals (other than the
|
||||
@ -35,65 +30,6 @@
|
||||
// Leaving the stack very big for now at 32K.
|
||||
#pragma stacksize 32768
|
||||
|
||||
// Defines
|
||||
|
||||
#define NUM_HEADER_SIZES 6
|
||||
|
||||
// This is plain, emphasized, strong or strong+empasized
|
||||
#define NUM_TEXT_FORMATS 4
|
||||
|
||||
#define NUM_HEADER_STYLES (NUM_HEADER_SIZES * NUM_TEXT_FORMATS)
|
||||
#define NUM_CODE_STYLES 1
|
||||
#define NUM_TEXT_STYLES NUM_TEXT_FORMATS
|
||||
#define NUM_QUOTE_STYLES NUM_TEXT_FORMATS
|
||||
|
||||
#define TOTAL_STYLES (NUM_HEADER_STYLES + NUM_CODE_STYLES + NUM_TEXT_STYLES + NUM_QUOTE_STYLES)
|
||||
|
||||
// Typedefs
|
||||
|
||||
typedef struct tWindowPos
|
||||
{
|
||||
int16_t height;
|
||||
int16_t width;
|
||||
int16_t top;
|
||||
int16_t left;
|
||||
int32_t version;
|
||||
} tWindowPos;
|
||||
|
||||
// I wish I could use the structure definition from textedit.h but TERuler contains optional
|
||||
// fields in the definition and Teach isn't expecting them it seems (array of theTabs). So,
|
||||
// I need my own struct which omits them.
|
||||
typedef struct tRuler
|
||||
{
|
||||
int16_t leftMargin;
|
||||
int16_t leftIndent;
|
||||
int16_t rightMargin;
|
||||
int16_t just;
|
||||
int16_t extraLS;
|
||||
int16_t flags;
|
||||
int32_t userData;
|
||||
int16_t tabType;
|
||||
int16_t tabTerminator;
|
||||
} tRuler;
|
||||
|
||||
typedef struct tFormatHeader
|
||||
{
|
||||
int16_t version;
|
||||
int32_t rulerSize;
|
||||
tRuler ruler;
|
||||
int32_t styleListLength;
|
||||
TEStyle styleList[TOTAL_STYLES];
|
||||
LongWord numberOfStyles;
|
||||
} tFormatHeader;
|
||||
|
||||
typedef struct tFormat
|
||||
{
|
||||
tFormatHeader header;
|
||||
StyleItem styleItems[1];
|
||||
} tFormat;
|
||||
|
||||
//typedef struct tStyle
|
||||
|
||||
|
||||
// Globals
|
||||
|
||||
@ -101,35 +37,9 @@ void * lowestStackSeen;
|
||||
char * commandName;
|
||||
int debugEnabled = 0;
|
||||
|
||||
tWindowPos windowPos = {
|
||||
0xad, // height
|
||||
0x27c, // width
|
||||
0x1a, // top
|
||||
0x02, // left
|
||||
0x0 // version
|
||||
};
|
||||
|
||||
// For the 6 header sizes, we are going with:
|
||||
// 1 -> Helvetica 36
|
||||
// 2 -> Helvetica 30
|
||||
// 3 -> Helvetica 27
|
||||
// 4 -> Helvetica 24
|
||||
// 5 -> Helvetica 20
|
||||
// 6 -> Helvetica 18
|
||||
uint8_t headerFontSizes[NUM_HEADER_SIZES] = {
|
||||
36,
|
||||
30,
|
||||
27,
|
||||
24,
|
||||
20,
|
||||
18
|
||||
};
|
||||
|
||||
tFormat * formatPtr = NULL;
|
||||
|
||||
// Implementation
|
||||
|
||||
|
||||
static void printUsage(void)
|
||||
{
|
||||
fprintf(stderr, "USAGE: %s [ -d ] inputfile outputfile\n", commandName);
|
||||
|
88
md2teach/style.c
Normal file
88
md2teach/style.c
Normal file
@ -0,0 +1,88 @@
|
||||
/*
|
||||
* style.c
|
||||
* md2teach
|
||||
*
|
||||
* Created by Jeremy Rand on 2021-04-24.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <textedit.h>
|
||||
|
||||
#include "style.h"
|
||||
|
||||
|
||||
// Typedefs
|
||||
|
||||
typedef struct tWindowPos
|
||||
{
|
||||
int16_t height;
|
||||
int16_t width;
|
||||
int16_t top;
|
||||
int16_t left;
|
||||
int32_t version;
|
||||
} tWindowPos;
|
||||
|
||||
// I wish I could use the structure definition from textedit.h but TERuler contains optional
|
||||
// fields in the definition and Teach isn't expecting them it seems (array of theTabs). So,
|
||||
// I need my own struct which omits them.
|
||||
typedef struct tRuler
|
||||
{
|
||||
int16_t leftMargin;
|
||||
int16_t leftIndent;
|
||||
int16_t rightMargin;
|
||||
int16_t just;
|
||||
int16_t extraLS;
|
||||
int16_t flags;
|
||||
int32_t userData;
|
||||
int16_t tabType;
|
||||
int16_t tabTerminator;
|
||||
} tRuler;
|
||||
|
||||
typedef struct tFormatHeader
|
||||
{
|
||||
int16_t version;
|
||||
int32_t rulerSize;
|
||||
tRuler ruler;
|
||||
int32_t styleListLength;
|
||||
TEStyle styleList[TOTAL_STYLES];
|
||||
LongWord numberOfStyles;
|
||||
} tFormatHeader;
|
||||
|
||||
typedef struct tFormat
|
||||
{
|
||||
tFormatHeader header;
|
||||
StyleItem styleItems[1];
|
||||
} tFormat;
|
||||
|
||||
//typedef struct tStyle
|
||||
|
||||
|
||||
// Globals
|
||||
|
||||
static tWindowPos windowPos = {
|
||||
0xad, // height
|
||||
0x27c, // width
|
||||
0x1a, // top
|
||||
0x02, // left
|
||||
0x0 // version
|
||||
};
|
||||
|
||||
// For the 6 header sizes, we are going with:
|
||||
// 1 -> Helvetica 36
|
||||
// 2 -> Helvetica 30
|
||||
// 3 -> Helvetica 27
|
||||
// 4 -> Helvetica 24
|
||||
// 5 -> Helvetica 20
|
||||
// 6 -> Helvetica 18
|
||||
static uint8_t headerFontSizes[NUM_HEADER_SIZES] = {
|
||||
36,
|
||||
30,
|
||||
27,
|
||||
24,
|
||||
20,
|
||||
18
|
||||
};
|
||||
|
||||
static tFormat * formatPtr = NULL;
|
27
md2teach/style.h
Normal file
27
md2teach/style.h
Normal file
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* style.h
|
||||
* md2teach
|
||||
*
|
||||
* Created by Jeremy Rand on 2021-04-24.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _GUARD_PROJECTmd2teach_FILEstyle_
|
||||
#define _GUARD_PROJECTmd2teach_FILEstyle_
|
||||
|
||||
// Defines
|
||||
|
||||
#define NUM_HEADER_SIZES 6
|
||||
|
||||
// This is plain, emphasized, strong or strong+empasized
|
||||
#define NUM_TEXT_FORMATS 4
|
||||
|
||||
#define NUM_HEADER_STYLES (NUM_HEADER_SIZES * NUM_TEXT_FORMATS)
|
||||
#define NUM_CODE_STYLES 1
|
||||
#define NUM_TEXT_STYLES NUM_TEXT_FORMATS
|
||||
#define NUM_QUOTE_STYLES NUM_TEXT_FORMATS
|
||||
|
||||
#define TOTAL_STYLES (NUM_HEADER_STYLES + NUM_CODE_STYLES + NUM_TEXT_STYLES + NUM_QUOTE_STYLES)
|
||||
|
||||
|
||||
#endif /* define _GUARD_PROJECTmd2teach_FILEstyle_ */
|
Loading…
x
Reference in New Issue
Block a user