Can now position the image in any cell.

master
Zed A. Shaw 2 days ago
parent 142aa235a4
commit c64c81b599
  1. 12
      assets/layouts.json
  2. 7
      sample/about-bezos.md
  3. 135
      src/md_parser.cpp
  4. 10
      src/md_parser.rl
  5. 4
      src/slides_ui.cpp

@ -12,7 +12,17 @@
"default_slide": [ "default_slide": [
"[=*%(300,200)title|_|_|_|_]", "[=*%(300,200)title|_|_|_|_]",
"[_|_|_]", "[_|_|_]",
"[*%(300,600)content|_|_|*%(200,600)alt|_]", "[*%(300,600)content|_|_|*%(200,600)image|_]",
"[_|_|_|_|_]",
"[_|_|_|_|_]",
"[_|_|_|_|_]",
"[_|_|_|_|_]",
"[_|_|_|_|_]"
],
"image_left": [
"[=*%(300,200)title|_|_|_|_]",
"[_|_|_]",
"[*%(200,600)image|_|*%(300,600)content|_|_]",
"[_|_|_|_|_]", "[_|_|_|_|_]",
"[_|_|_|_|_]", "[_|_|_|_|_]",
"[_|_|_|_|_]", "[_|_|_|_|_]",

@ -65,6 +65,13 @@ One Word
* Text will go over image * Text will go over image
* Image will stretch to fill * Image will stretch to fill
--- ---
{"layout": "image_left"}
# Specific Positions
![image](assets/sample_bg.jpg)
* !(assets/sample_bg.jpg)
* Text will go over image
* Image will stretch to fill
---
# Hot Reload # Hot Reload
* It watches the file and * It watches the file and
reloads when it changes reloads when it changes

@ -12,7 +12,7 @@ enum {
}; };
#line 93 "..//src/md_parser.rl" #line 101 "..//src/md_parser.rl"
@ -20,20 +20,20 @@ enum {
static const char _Parser_actions[] = { static const char _Parser_actions[] = {
0, 1, 0, 1, 1, 1, 2, 1, 0, 1, 0, 1, 1, 1, 2, 1,
3, 1, 4, 1, 5, 1, 6, 1, 3, 1, 4, 1, 5, 1, 6, 1,
7, 1, 8, 1, 9, 2, 0, 4, 7, 1, 8, 1, 9, 1, 10, 2,
2, 0, 8, 2, 4, 0, 2, 5, 0, 4, 2, 0, 9, 2, 4, 0,
8, 2, 8, 0, 3, 0, 4, 8, 2, 5, 9, 2, 9, 0, 3, 0,
3, 4, 0, 8, 3, 5, 0, 8, 4, 9, 3, 4, 0, 9, 3, 5,
3, 5, 8, 0, 4, 5, 0, 4, 0, 9, 3, 5, 9, 0, 4, 5,
8 0, 4, 9
}; };
static const char _Parser_key_offsets[] = { static const char _Parser_key_offsets[] = {
0, 0, 1, 2, 3, 4, 5, 6, 0, 0, 1, 2, 3, 4, 5, 6,
7, 8, 17, 18, 19, 29, 33, 37, 7, 8, 17, 18, 19, 29, 33, 37,
47, 48, 48, 49, 51, 54, 58, 62, 47, 49, 49, 50, 52, 56, 61, 62,
65, 67, 69, 70, 74, 78, 88, 89, 65, 69, 73, 76, 78, 80, 81, 85,
90, 99 89, 99, 100, 101, 110
}; };
static const char _Parser_trans_keys[] = { static const char _Parser_trans_keys[] = {
@ -43,38 +43,39 @@ static const char _Parser_trans_keys[] = {
45, 123, 125, 9, 13, 10, 32, 9, 45, 123, 125, 9, 13, 10, 32, 9,
13, 10, 32, 9, 13, 10, 32, 33, 13, 10, 32, 9, 13, 10, 32, 33,
35, 42, 45, 123, 125, 9, 13, 40, 35, 42, 45, 123, 125, 9, 13, 40,
41, 10, 41, 32, 9, 13, 10, 32, 91, 41, 10, 41, 65, 90, 97, 122,
9, 13, 10, 32, 9, 13, 32, 9, 93, 65, 90, 97, 122, 40, 32, 9,
13, 10, 45, 10, 45, 10, 10, 32, 13, 10, 32, 9, 13, 10, 32, 9,
9, 13, 10, 32, 9, 13, 10, 32, 13, 32, 9, 13, 10, 45, 10, 45,
33, 35, 42, 45, 123, 125, 9, 13, 10, 10, 32, 9, 13, 10, 32, 9,
125, 125, 10, 32, 33, 35, 42, 123, 13, 10, 32, 33, 35, 42, 45, 123,
125, 9, 13, 10, 32, 33, 35, 42, 125, 9, 13, 125, 125, 10, 32, 33,
123, 125, 9, 13, 0 35, 42, 123, 125, 9, 13, 10, 32,
33, 35, 42, 123, 125, 9, 13, 0
}; };
static const char _Parser_single_lengths[] = { static const char _Parser_single_lengths[] = {
0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1,
1, 7, 1, 1, 8, 2, 2, 8, 1, 7, 1, 1, 8, 2, 2, 8,
1, 0, 1, 2, 1, 2, 2, 1, 2, 0, 1, 2, 0, 1, 1, 1,
2, 2, 1, 2, 2, 8, 1, 1, 2, 2, 1, 2, 2, 1, 2, 2,
7, 7 8, 1, 1, 7, 7
}; };
static const char _Parser_range_lengths[] = { static const char _Parser_range_lengths[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1,
0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 2, 2, 0, 1,
0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1,
1, 1 1, 0, 0, 1, 1
}; };
static const unsigned char _Parser_index_offsets[] = { static const unsigned char _Parser_index_offsets[] = {
0, 0, 2, 4, 6, 8, 10, 12, 0, 0, 2, 4, 6, 8, 10, 12,
14, 16, 25, 27, 29, 39, 43, 47, 14, 16, 25, 27, 29, 39, 43, 47,
57, 59, 60, 62, 65, 68, 72, 76, 57, 60, 61, 63, 66, 69, 73, 75,
79, 82, 85, 87, 91, 95, 105, 107, 78, 82, 86, 89, 92, 95, 97, 101,
109, 118 105, 115, 117, 119, 128
}; };
static const char _Parser_indicies[] = { static const char _Parser_indicies[] = {
@ -85,45 +86,49 @@ static const char _Parser_indicies[] = {
23, 24, 25, 1, 1, 20, 19, 27, 23, 24, 25, 1, 1, 20, 19, 27,
26, 26, 16, 27, 28, 28, 17, 29, 26, 26, 16, 27, 28, 28, 17, 29,
20, 22, 23, 24, 25, 1, 1, 20, 20, 22, 23, 24, 25, 1, 1, 20,
19, 30, 1, 31, 33, 32, 34, 33, 19, 30, 31, 1, 32, 34, 33, 35,
32, 35, 35, 1, 38, 37, 37, 36, 34, 33, 36, 36, 1, 38, 37, 37,
18, 37, 37, 36, 39, 39, 1, 1, 1, 30, 1, 39, 39, 1, 42, 41,
40, 16, 18, 41, 17, 42, 1, 44, 41, 40, 18, 41, 41, 40, 43, 43,
43, 43, 16, 44, 45, 45, 17, 46, 1, 1, 44, 16, 18, 45, 17, 46,
10, 12, 13, 14, 47, 1, 1, 10, 1, 48, 47, 47, 16, 48, 49, 49,
9, 1, 48, 49, 48, 52, 51, 53, 17, 50, 10, 12, 13, 14, 51, 1,
54, 55, 1, 1, 51, 50, 11, 10, 1, 10, 9, 1, 52, 53, 52, 56,
12, 13, 14, 15, 1, 10, 9, 0 55, 57, 58, 59, 1, 1, 55, 54,
11, 10, 12, 13, 14, 15, 1, 10,
9, 0
}; };
static const char _Parser_trans_targs[] = { static const char _Parser_trans_targs[] = {
2, 0, 3, 4, 5, 6, 7, 8, 2, 0, 3, 4, 5, 6, 7, 8,
9, 10, 27, 29, 16, 20, 23, 30, 9, 10, 30, 32, 16, 23, 26, 33,
11, 11, 12, 10, 13, 15, 16, 20, 11, 11, 12, 10, 13, 15, 16, 23,
23, 24, 14, 15, 14, 15, 17, 18, 26, 27, 14, 15, 14, 15, 17, 20,
18, 19, 12, 21, 11, 22, 21, 21, 18, 18, 19, 12, 21, 21, 22, 24,
25, 26, 33, 28, 29, 28, 29, 24, 11, 25, 24, 24, 28, 29, 36, 31,
31, 32, 10, 27, 29, 16, 20, 23 32, 31, 32, 27, 34, 35, 10, 30,
32, 16, 23, 26
}; };
static const char _Parser_trans_actions[] = { static const char _Parser_trans_actions[] = {
1, 0, 0, 0, 11, 0, 0, 0, 1, 0, 0, 0, 11, 0, 0, 0,
15, 33, 24, 36, 17, 17, 17, 1, 17, 35, 26, 38, 19, 19, 19, 1,
5, 0, 9, 1, 1, 21, 0, 0, 5, 0, 9, 1, 1, 23, 0, 0,
0, 1, 5, 9, 0, 27, 0, 1, 0, 1, 5, 9, 0, 29, 0, 0,
0, 13, 0, 3, 1, 1, 0, 7, 1, 0, 15, 0, 1, 0, 13, 3,
5, 0, 19, 5, 9, 0, 40, 33, 1, 1, 0, 7, 5, 0, 21, 5,
0, 0, 48, 44, 52, 30, 30, 30 9, 0, 42, 35, 0, 0, 50, 46,
54, 32, 32, 32
}; };
static const int Parser_start = 1; static const int Parser_start = 1;
static const int Parser_first_final = 33; static const int Parser_first_final = 36;
static const int Parser_error = 0; static const int Parser_error = 0;
static const int Parser_en_main = 1; static const int Parser_en_main = 1;
#line 96 "..//src/md_parser.rl" #line 104 "..//src/md_parser.rl"
bool Parser::parse(const std::string& input) { bool Parser::parse(const std::string& input) {
@ -139,14 +144,14 @@ bool Parser::parse(const std::string& input) {
last = DECK; last = DECK;
#line 134 "..//src/md_parser.cpp" #line 139 "..//src/md_parser.cpp"
{ {
cs = Parser_start; cs = Parser_start;
} }
#line 111 "..//src/md_parser.rl" #line 119 "..//src/md_parser.rl"
#line 137 "..//src/md_parser.cpp" #line 142 "..//src/md_parser.cpp"
{ {
int _klen; int _klen;
unsigned int _trans; unsigned int _trans;
@ -272,34 +277,42 @@ _match:
case 6: case 6:
#line 50 "..//src/md_parser.rl" #line 50 "..//src/md_parser.rl"
{ {
std::string cell = input.substr(start - begin, p - start);
fmt::println("CELL {}", cell);
config["image_cell"] = cell;
}
break;
case 7:
#line 56 "..//src/md_parser.rl"
{
std::string image = input.substr(start - begin, p - start); std::string image = input.substr(start - begin, p - start);
fmt::println("IMAGE image={}, start={}, length={}", fmt::println("IMAGE image={}, start={}, length={}",
image, start - begin, p - start); image, start - begin, p - start);
config["image"] = image; config["image"] = image;
} }
break; break;
case 7: case 8:
#line 57 "..//src/md_parser.rl" #line 63 "..//src/md_parser.rl"
{ {
last = PLAIN; last = PLAIN;
fmt::println("----- START"); fmt::println("----- START");
} }
break; break;
case 8: case 9:
#line 62 "..//src/md_parser.rl" #line 68 "..//src/md_parser.rl"
{ {
title.clear(); title.clear();
content.clear(); content.clear();
} }
break; break;
case 9: case 10:
#line 67 "..//src/md_parser.rl" #line 73 "..//src/md_parser.rl"
{ {
deck->slides.emplace_back(title, content, config, deck->config); deck->slides.emplace_back(title, content, config, deck->config);
config.clear(); config.clear();
} }
break; break;
#line 279 "..//src/md_parser.cpp" #line 291 "..//src/md_parser.cpp"
} }
} }
@ -312,7 +325,7 @@ _again:
_out: {} _out: {}
} }
#line 112 "..//src/md_parser.rl" #line 120 "..//src/md_parser.rl"
bool good = pe - p == 0; bool good = pe - p == 0;

@ -47,6 +47,12 @@ enum {
} }
} }
action cell {
std::string cell = input.substr(start - begin, fpc - start);
fmt::println("CELL {}", cell);
config["image_cell"] = cell;
}
action image { action image {
std::string image = input.substr(start - begin, fpc - start); std::string image = input.substr(start - begin, fpc - start);
fmt::println("IMAGE image={}, start={}, length={}", fmt::println("IMAGE image={}, start={}, length={}",
@ -75,12 +81,14 @@ enum {
pound = '#' %title; pound = '#' %title;
asterisk = '*' %enum; asterisk = '*' %enum;
bang = '!'; bang = '!';
at = '@';
dash = '-' %enum; dash = '-' %enum;
json = ('{'|'}'); json = ('{'|'}');
other = ^(bang|pound|asterisk|eol|json) %plain; other = ^(bang|pound|asterisk|eol|json) %plain;
content = (any+ -- eol) >mark %content; content = (any+ -- eol) >mark %content;
image = bang '(' (any+) >mark %image ')' :>> eol; cell = '[' (alpha+) >mark %cell ']';
image = bang cell? '(' (any+) >mark %image ')' :>> eol;
meta = ('{' ( any+ -- '}') '}') >mark %meta; meta = ('{' ( any+ -- '}') '}') >mark %meta;
title = pound space+ content :>> eol; title = pound space+ content :>> eol;
enum = asterisk space+ content :>> eol; enum = asterisk space+ content :>> eol;

@ -40,7 +40,9 @@ void Slide::init(lel::Cell& cell, const std::string& layout) {
$gui.set<guecs::Text>(content, $content_font); $gui.set<guecs::Text>(content, $content_font);
if($config.contains("image")) { if($config.contains("image")) {
$gui.set<guecs::Sprite>(content, {$config["image"]}); std::string image_name = $config["image"];
auto at_cell = $config.contains("image_cell") ? $gui.entity($config["image_cell"]) : content;
$gui.set<guecs::Sprite>(at_cell, {image_name});
} }
$gui.init(); $gui.init();

Loading…
Cancel
Save