gnuplot.py (TeXmacs-2.1.1-src) | : | gnuplot.py (TeXmacs-2.1.2-src) | ||
---|---|---|---|---|
skipping to change at line 22 | skipping to change at line 22 | |||
import os | import os | |||
from subprocess import Popen, PIPE, STDOUT | from subprocess import Popen, PIPE, STDOUT | |||
from .graph import Graph | from .graph import Graph | |||
from ..protocol import * | from ..protocol import * | |||
from ..compat import * | from ..compat import * | |||
class Gnuplot(Graph): | class Gnuplot(Graph): | |||
def __init__(self, name = "gnuplot"): | def __init__(self, name = "gnuplot"): | |||
super(Gnuplot, self).__init__() | super(Gnuplot, self).__init__() | |||
self.name = name | self.name = name | |||
self.width = 600 | ||||
self.default_output = "svg" | self.default_output = "svg" | |||
self.default_width = "0.8par" | ||||
def greet(self): | def greet(self): | |||
if len(self.message) == 0: | if len(self.message) == 0: | |||
try: | try: | |||
p = Popen([self.name, "-V"], stdout=PIPE) | p = Popen([self.name, "-V"], stdout=PIPE) | |||
ret, err = p.communicate() | ret, err = p.communicate() | |||
# WARN: The Version Info is in stderr | # WARN: The Version Info is in stderr | |||
if (p.returncode == 0): | if (p.returncode == 0): | |||
self.message = ret.decode() | self.message = ret.decode() | |||
except OSError: | except OSError: | |||
skipping to change at line 83 | skipping to change at line 83 | |||
code_file.write(self.pre_code) | code_file.write(self.pre_code) | |||
code_file.write(code) | code_file.write(code) | |||
cmd = [self.name, "-c", code_path] | cmd = [self.name, "-c", code_path] | |||
p = Popen(cmd, stderr=PIPE) | p = Popen(cmd, stderr=PIPE) | |||
out, err = p.communicate() | out, err = p.communicate() | |||
if (p.returncode == 0): | if (p.returncode == 0): | |||
flush_file (image) | flush_file (image) | |||
else: | else: | |||
flush_verbatim (err.decode()) | flush_verbatim (err.decode()) | |||
def main_loop(self): | ||||
# Main session loop. | ||||
while True: | ||||
line = tm_input() | ||||
if not line: | ||||
continue | ||||
if line[0] == DATA_COMMAND: | ||||
# TODO: Handle completions | ||||
continue | ||||
else: | ||||
lines = [] | ||||
for x in line.split('~'): | ||||
lines.append(x) | ||||
while line != "<EOF>": | ||||
line = tm_input() | ||||
for x in line.split('~'): | ||||
lines.append(x) | ||||
text = '\n'.join(lines[:-1]) | ||||
self.eval(text) | ||||
End of changes. 3 change blocks. | ||||
1 lines changed or deleted | 1 lines changed or added |