diff options
| author | Julie Lala <jules@okfoc.us> | 2014-11-30 16:53:50 -0500 |
|---|---|---|
| committer | Julie Lala <jules@okfoc.us> | 2014-11-30 16:53:50 -0500 |
| commit | 7d80be2bf7bfb65719dff6437959509e12487078 (patch) | |
| tree | 9f9a0455bae61f165d3ad98a2fb624edcee9458f /js/clipboard.js | |
| parent | 4f2f5dc5580359bba21150af3ce5d34ad14b3ab4 (diff) | |
import ascii art
Diffstat (limited to 'js/clipboard.js')
| -rw-r--r-- | js/clipboard.js | 32 |
1 files changed, 29 insertions, 3 deletions
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 +})() + + |
