summaryrefslogtreecommitdiff
path: root/src/gmdocument.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2020-08-24 13:15:00 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2020-08-24 13:15:00 +0300
commit455a635080a1c1c4b164af3060836f0d8c1b3c1c (patch)
treebc77c492e9b7187d8b277d2a1cd024902c8ae3eb /src/gmdocument.c
parentfbf36dfbf77701d647f0133f1532ebc42eb05e32 (diff)
Updated for the_Foundation API changes
Diffstat (limited to 'src/gmdocument.c')
-rw-r--r--src/gmdocument.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/src/gmdocument.c b/src/gmdocument.c
index 5bc16fda..4cba5adf 100644
--- a/src/gmdocument.c
+++ b/src/gmdocument.c
@@ -128,11 +128,11 @@ enum iGmLineType {
128 max_GmLineType, 128 max_GmLineType,
129}; 129};
130 130
131static enum iGmLineType lineType_GmDocument_(const iGmDocument *d, const iRangecc *line) { 131static enum iGmLineType lineType_GmDocument_(const iGmDocument *d, const iRangecc line) {
132 if (d->format == plainText_GmDocumentFormat) { 132 if (d->format == plainText_GmDocumentFormat) {
133 return text_GmLineType; 133 return text_GmLineType;
134 } 134 }
135 if (isEmpty_Range(line)) { 135 if (isEmpty_Range(&line)) {
136 return text_GmLineType; 136 return text_GmLineType;
137 } 137 }
138 if (startsWith_Rangecc(line, "=>")) { 138 if (startsWith_Rangecc(line, "=>")) {
@@ -150,10 +150,10 @@ static enum iGmLineType lineType_GmDocument_(const iGmDocument *d, const iRangec
150 if (startsWith_Rangecc(line, "```")) { 150 if (startsWith_Rangecc(line, "```")) {
151 return preformatted_GmLineType; 151 return preformatted_GmLineType;
152 } 152 }
153 if (*line->start == '>') { 153 if (*line.start == '>') {
154 return quote_GmLineType; 154 return quote_GmLineType;
155 } 155 }
156 if (size_Range(line) >= 2 && line->start[0] == '*' && isspace(line->start[1])) { 156 if (size_Range(&line) >= 2 && line.start[0] == '*' && isspace(line.start[1])) {
157 return bullet_GmLineType; 157 return bullet_GmLineType;
158 } 158 }
159 return text_GmLineType; 159 return text_GmLineType;
@@ -179,11 +179,11 @@ static int lastVisibleRunBottom_GmDocument_(const iGmDocument *d) {
179iInt2 measurePreformattedBlock_GmDocument_(const iGmDocument *d, const char *start, int font) { 179iInt2 measurePreformattedBlock_GmDocument_(const iGmDocument *d, const char *start, int font) {
180 const iRangecc content = { start, constEnd_String(&d->source) }; 180 const iRangecc content = { start, constEnd_String(&d->source) };
181 iRangecc line = iNullRange; 181 iRangecc line = iNullRange;
182 nextSplit_Rangecc(&content, "\n", &line); 182 nextSplit_Rangecc(content, "\n", &line);
183 iAssert(startsWith_Rangecc(&line, "```")); 183 iAssert(startsWith_Rangecc(line, "```"));
184 iRangecc preBlock = { line.end + 1, line.end + 1 }; 184 iRangecc preBlock = { line.end + 1, line.end + 1 };
185 while (nextSplit_Rangecc(&content, "\n", &line)) { 185 while (nextSplit_Rangecc(content, "\n", &line)) {
186 if (startsWith_Rangecc(&line, "```")) { 186 if (startsWith_Rangecc(line, "```")) {
187 break; 187 break;
188 } 188 }
189 preBlock.end = line.end; 189 preBlock.end = line.end;
@@ -205,22 +205,22 @@ static iRangecc addLink_GmDocument_(iGmDocument *d, iRangecc line, iGmLinkId *li
205 /* Check the URL. */ { 205 /* Check the URL. */ {
206 iUrl parts; 206 iUrl parts;
207 init_Url(&parts, &link->url); 207 init_Url(&parts, &link->url);
208 if (!equalCase_Rangecc(&parts.host, cstr_String(&d->localHost))) { 208 if (!equalCase_Rangecc(parts.host, cstr_String(&d->localHost))) {
209 link->flags |= remote_GmLinkFlag; 209 link->flags |= remote_GmLinkFlag;
210 } 210 }
211 if (startsWithCase_Rangecc(&parts.protocol, "gemini")) { 211 if (startsWithCase_Rangecc(parts.protocol, "gemini")) {
212 link->flags |= gemini_GmLinkFlag; 212 link->flags |= gemini_GmLinkFlag;
213 } 213 }
214 else if (startsWithCase_Rangecc(&parts.protocol, "http")) { 214 else if (startsWithCase_Rangecc(parts.protocol, "http")) {
215 link->flags |= http_GmLinkFlag; 215 link->flags |= http_GmLinkFlag;
216 } 216 }
217 else if (equalCase_Rangecc(&parts.protocol, "gopher")) { 217 else if (equalCase_Rangecc(parts.protocol, "gopher")) {
218 link->flags |= gopher_GmLinkFlag; 218 link->flags |= gopher_GmLinkFlag;
219 } 219 }
220 else if (equalCase_Rangecc(&parts.protocol, "file")) { 220 else if (equalCase_Rangecc(parts.protocol, "file")) {
221 link->flags |= file_GmLinkFlag; 221 link->flags |= file_GmLinkFlag;
222 } 222 }
223 else if (equalCase_Rangecc(&parts.protocol, "data")) { 223 else if (equalCase_Rangecc(parts.protocol, "data")) {
224 link->flags |= data_GmLinkFlag; 224 link->flags |= data_GmLinkFlag;
225 } 225 }
226 /* Check the file name extension, if present. */ 226 /* Check the file name extension, if present. */
@@ -336,7 +336,7 @@ static void doLayout_GmDocument_(iGmDocument *d) {
336 isPreformat = iTrue; 336 isPreformat = iTrue;
337 isFirstText = iFalse; 337 isFirstText = iFalse;
338 } 338 }
339 while (nextSplit_Rangecc(&content, "\n", &line)) { 339 while (nextSplit_Rangecc(content, "\n", &line)) {
340 iGmRun run; 340 iGmRun run;
341 run.flags = 0; 341 run.flags = 0;
342 run.color = white_ColorId; 342 run.color = white_ColorId;
@@ -345,7 +345,7 @@ static void doLayout_GmDocument_(iGmDocument *d) {
345 enum iGmLineType type; 345 enum iGmLineType type;
346 int indent = 0; 346 int indent = 0;
347 if (!isPreformat) { 347 if (!isPreformat) {
348 type = lineType_GmDocument_(d, &line); 348 type = lineType_GmDocument_(d, line);
349 if (line.start == content.start) { 349 if (line.start == content.start) {
350 prevType = type; 350 prevType = type;
351 } 351 }
@@ -383,7 +383,7 @@ static void doLayout_GmDocument_(iGmDocument *d) {
383 /* Preformatted line. */ 383 /* Preformatted line. */
384 type = preformatted_GmLineType; 384 type = preformatted_GmLineType;
385 if (d->format == gemini_GmDocumentFormat && 385 if (d->format == gemini_GmDocumentFormat &&
386 startsWithSc_Rangecc(&line, "```", &iCaseSensitive)) { 386 startsWithSc_Rangecc(line, "```", &iCaseSensitive)) {
387 isPreformat = iFalse; 387 isPreformat = iFalse;
388 preAltText = iNullRange; 388 preAltText = iNullRange;
389 addSiteBanner = iFalse; /* overrides the banner */ 389 addSiteBanner = iFalse; /* overrides the banner */
@@ -851,7 +851,7 @@ static void normalize_GmDocument(iGmDocument *d) {
851 isPreformat = iTrue; /* Cannot be turned off. */ 851 isPreformat = iTrue; /* Cannot be turned off. */
852 } 852 }
853 const int preTabWidth = 8; /* TODO: user-configurable parameter */ 853 const int preTabWidth = 8; /* TODO: user-configurable parameter */
854 while (nextSplit_Rangecc(&src, "\n", &line)) { 854 while (nextSplit_Rangecc(src, "\n", &line)) {
855 if (isPreformat) { 855 if (isPreformat) {
856 /* Replace any tab characters with spaces for visualization. */ 856 /* Replace any tab characters with spaces for visualization. */
857 for (const char *ch = line.start; ch != line.end; ch++) { 857 for (const char *ch = line.start; ch != line.end; ch++) {
@@ -867,12 +867,12 @@ static void normalize_GmDocument(iGmDocument *d) {
867 } 867 }
868 } 868 }
869 appendCStr_String(normalized, "\n"); 869 appendCStr_String(normalized, "\n");
870 if (lineType_GmDocument_(d, &line) == preformatted_GmLineType) { 870 if (lineType_GmDocument_(d, line) == preformatted_GmLineType) {
871 isPreformat = iFalse; 871 isPreformat = iFalse;
872 } 872 }
873 continue; 873 continue;
874 } 874 }
875 if (lineType_GmDocument_(d, &line) == preformatted_GmLineType) { 875 if (lineType_GmDocument_(d, line) == preformatted_GmLineType) {
876 isPreformat = iTrue; 876 isPreformat = iTrue;
877 appendRange_String(normalized, line); 877 appendRange_String(normalized, line);
878 appendCStr_String(normalized, "\n"); 878 appendCStr_String(normalized, "\n");