| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent e1733c5 commit 214e4ca
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,7 +20,6 @@ | |||
| 20 | 20 | from pygments.formatters import TerminalFormatter | |
| 21 | 21 | ||
| 22 | 22 | from wcwidth import wcswidth | |
| 23 | - from math import ceil | ||
| 24 | 23 | ||
| 25 | 24 | import blessings | |
| 26 | 25 | ||
@@ -1009,18 +1008,10 @@ def send_current_block_to_external_editor(self, filename=None): | |||
| 1009 | 1008 | ||
| 1010 | 1009 | def send_session_to_external_editor(self, filename=None): | |
| 1011 | 1010 | """ | |
| 1012 | - Sends entire bpython session to external editor to be edited. Usually bound to F7. | ||
| 1013 | - | ||
| 1014 | - Loops through self.all_logical_lines so that lines aren't wrapped in the editor. | ||
| 1015 | - | ||
| 1011 | + Sends entire bpython session to external editor to be edited. Usually bound to F7. | ||
| 1016 | 1012 | """ | |
| 1017 | 1013 | for_editor = EDIT_SESSION_HEADER | |
| 1018 | - for_editor += "\n".join( | ||
| 1019 | - line[0] if line[1] == INPUT | ||
| 1020 | - else "### " + line[0] | ||
| 1021 | - for line in self.all_logical_lines | ||
| 1022 | - ) | ||
| 1023 | - for_editor += "\n" + "### " + self.current_line | ||
| 1014 | + for_editor += self.get_session_formatted_for_file() | ||
| 1024 | 1015 | ||
| 1025 | 1016 | text = self.send_to_external_editor(for_editor) | |
| 1026 | 1017 | if text == for_editor: | |
@@ -1035,7 +1026,7 @@ def send_session_to_external_editor(self, filename=None): | |||
| 1035 | 1026 | current_line = lines[-1][4:] | |
| 1036 | 1027 | else: | |
| 1037 | 1028 | current_line = "" | |
| 1038 | - from_editor = [line for line in lines if line[:3] != "###"] | ||
| 1029 | + from_editor = [line for line in lines if line[:6] != "# OUT:"] | ||
| 1039 | 1030 | if all(not line.strip() for line in from_editor): | |
| 1040 | 1031 | self.status_bar.message( | |
| 1041 | 1032 | _("Session not reevaluated because saved file was blank") | |
@@ -1938,7 +1929,7 @@ def initialize_interp(self): | |||
| 1938 | 1929 | ||
| 1939 | 1930 | def getstdout(self): | |
| 1940 | 1931 | """ | |
| 1941 | - Returns a string of the current bpython session, formatted and wrapped. | ||
| 1932 | + Returns a string of the current bpython session, wrapped, WITH prompts. | ||
| 1942 | 1933 | """ | |
| 1943 | 1934 | lines = self.lines_for_display + [self.current_line_formatted] | |
| 1944 | 1935 | s = ( | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -821,18 +821,18 @@ def line_is_empty(line): | |||
| 821 | 821 | indentation = 0 | |
| 822 | 822 | return indentation | |
| 823 | 823 | ||
| 824 | - def formatforfile(self, session_ouput): | ||
| 824 | + def get_session_formatted_for_file(self): | ||
| 825 | 825 | """Format the stdout buffer to something suitable for writing to disk, | |
| 826 | 826 | i.e. without >>> and ... at input lines and with "# OUT: " prepended to | |
| 827 | - output lines.""" | ||
| 827 | + output lines and "### " prepended to current line""" | ||
| 828 | 828 | ||
| 829 | 829 | def process(): | |
| 830 | 830 | for line, lineType in self.all_logical_lines: | |
| 831 | 831 | if lineType == LineTypeTranslator.INPUT: | |
| 832 | 832 | yield line | |
| 833 | 833 | elif line.rstrip(): | |
| 834 | - yield "# OUT: %s" % (line,) | ||
| 835 | - | ||
| 834 | + yield "# OUT: %s" % line | ||
| 835 | + yield "###: %s" % self.current_line | ||
| 836 | 836 | return "\n".join(process()) | |
| 837 | 837 | ||
| 838 | 838 | def write2file(self): | |
@@ -872,7 +872,7 @@ def write2file(self): | |||
| 872 | 872 | self.interact.notify(_("Save cancelled.")) | |
| 873 | 873 | return | |
| 874 | 874 | ||
| 875 | - stdout_text = self.formatforfile(self.getstdout()) | ||
| 875 | + stdout_text = self.get_session_formatted_for_file() | ||
| 876 | 876 | ||
| 877 | 877 | try: | |
| 878 | 878 | with open(fn, mode) as f: | |
@@ -889,7 +889,7 @@ def copy2clipboard(self): | |||
| 889 | 889 | self.interact.notify(_("No clipboard available.")) | |
| 890 | 890 | return | |
| 891 | 891 | ||
| 892 | - content = self.formatforfile(self.getstdout()) | ||
| 892 | + content = self.get_session_formatted_for_file() | ||
| 893 | 893 | try: | |
| 894 | 894 | self.clipboard.copy(content) | |
| 895 | 895 | except CopyFailed: | |
| Back | FazBrowse Home | New Git URL |
0 commit comments