summaryrefslogtreecommitdiff
path: root/markdown.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'markdown.cpp')
-rw-r--r--markdown.cpp21
1 files changed, 14 insertions, 7 deletions
diff --git a/markdown.cpp b/markdown.cpp
index a7c1312..e61601d 100644
--- a/markdown.cpp
+++ b/markdown.cpp
@@ -1,5 +1,9 @@
#include <stdio.h>
+#include <fstream>
+#include <iterator>
+#include <string>
+
#include <GL/glew.h>
#include <GLFW/glfw3.h>
@@ -51,8 +55,11 @@ static void resized(GLFWwindow *, int width, int height)
g_window_size.y = static_cast<float>(height);
}
-int main(int, char **)
+int main(int argc, char ** argv)
{
+ if (2 != argc)
+ return 1;
+
glfwSetErrorCallback(glfw_error_callback);
if (!glfwInit())
return 1;
@@ -84,6 +91,11 @@ int main(int, char **)
ImGui_ImplGlfw_InitForOpenGL(window, true);
ImGui_ImplOpenGL3_Init(glsl_version);
+ std::ifstream in;
+ in.open(argv[1]);
+ std::string text(std::istreambuf_iterator<char>(in), {});
+ in.close();
+
while (!glfwWindowShouldClose(window))
{
glfwPollEvents();
@@ -98,12 +110,7 @@ int main(int, char **)
nullptr,
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoBackground | ImGuiWindowFlags_NoSavedSettings
);
- static const char * text =
- "# Hello world!\n" // 15
- "Lorem ipsum dolor\n" // 18 33
- " * sit\n" // 7 40
- " * amet\n"; // 8 48
- markdown(text, text + 48);
+ markdown(text.data(), text.data() + text.size());
ImGui::End();
ImGui::Render();