summaryrefslogtreecommitdiff
path: root/graphics/asymptote/drawverbatim.h
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /graphics/asymptote/drawverbatim.h
Initial commit
Diffstat (limited to 'graphics/asymptote/drawverbatim.h')
-rw-r--r--graphics/asymptote/drawverbatim.h63
1 files changed, 63 insertions, 0 deletions
diff --git a/graphics/asymptote/drawverbatim.h b/graphics/asymptote/drawverbatim.h
new file mode 100644
index 0000000000..186dc54442
--- /dev/null
+++ b/graphics/asymptote/drawverbatim.h
@@ -0,0 +1,63 @@
+/*****
+ * drawverbatim.h
+ * John Bowman 2003/03/18
+ *
+ * Add verbatim postscript to picture.
+ *****/
+
+#ifndef DRAWVERBATIM_H
+#define DRAWVERBATIM_H
+
+#include "drawelement.h"
+
+namespace camp {
+
+enum Language {PostScript,TeX};
+
+class drawVerbatim : public drawElement {
+private:
+ Language language;
+ string text;
+ bool userbounds;
+ pair min,max;
+ bool havebounds;
+public:
+ drawVerbatim(Language language, const string& text) :
+ language(language), text(text), userbounds(false), havebounds(false) {}
+
+ drawVerbatim(Language language, const string& text, pair min,
+ pair max) :
+ language(language), text(text), userbounds(true), min(min), max(max),
+ havebounds(false) {}
+
+ virtual ~drawVerbatim() {}
+
+ void bounds(bbox& b, iopipestream& tex, boxvector&, bboxlist&) {
+ if(havebounds) return;
+ havebounds=true;
+ if(language == TeX)
+ tex << text << "%" << newl;
+ if(userbounds) {
+ b += min;
+ b += max;
+ }
+ }
+
+ bool islabel() {
+ return language == TeX;
+ }
+
+ bool draw(psfile *out) {
+ if(language == PostScript) out->verbatimline(text);
+ return true;
+ }
+
+ bool write(texfile *out, const bbox&) {
+ if(language == TeX) out->verbatimline(stripblanklines(text));
+ return true;
+ }
+};
+
+}
+
+#endif