From 7d80be2bf7bfb65719dff6437959509e12487078 Mon Sep 17 00:00:00 2001 From: Julie Lala Date: Sun, 30 Nov 2014 16:53:50 -0500 Subject: import ascii art --- js/clipboard.js | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) (limited to 'js/clipboard.js') diff --git a/js/clipboard.js b/js/clipboard.js index 97261bc..5354771 100644 --- a/js/clipboard.js +++ b/js/clipboard.js @@ -36,14 +36,14 @@ var clipboard = (function () { focus() clipboard.importing = true import_button.style.display = "inline-block" - export_button.style.display = format_group.display = "none" + export_button.style.display = format_group.style.display = "none" import_textarea.value = "" }, export_mode: function () { focus() clipboard.importing = false import_button.style.display = "none" - export_button.style.display = format_group.display = "inline-block" + export_button.style.display = format_group.style.display = "inline-block" clipboard.export_data() }, import_data: function () { @@ -51,6 +51,30 @@ var clipboard = (function () { lines = data.split("\n") var width = lines.reduce(function(a,b){ return Math.max(a, b.length) }) var height = lines.length + if (width > 200) { + return alert("input too wide") + } + if (height > 200) { + return alert("input too tall") + } + canvas.clear() + lines.forEach(function(line, y){ + var row = canvas.aa[y] + if (! row) return + for (var x = 0; x < line.length; x++) { + var lex = row[x] + if (! lex) return + lex.char = line[x] + lex.fg = brush.bg + lex.build() + } + }) +// var pasted_region = new Matrix (width, height, function(x,y){ +// var lex = new Lex (x,y) +// lex.char = lines[y][x] || " " +// lex.build() +// return lex +// }) }, export_data: function () { var output @@ -76,4 +100,6 @@ var clipboard = (function () { return exports -})() \ No newline at end of file +})() + + -- cgit v1.2.3-70-g09d2