Initial switch to using $EDITOR
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
import curses
|
import curses
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
import tempfile
|
||||||
|
import os
|
||||||
|
|
||||||
import praw.errors
|
import praw.errors
|
||||||
|
|
||||||
@@ -234,7 +236,6 @@ class SubmissionPage(BasePage):
|
|||||||
Add a comment on the submission if a header is selected.
|
Add a comment on the submission if a header is selected.
|
||||||
Reply to a comment if the comment is selected.
|
Reply to a comment if the comment is selected.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if not self.reddit.is_logged_in():
|
if not self.reddit.is_logged_in():
|
||||||
show_notification(self.stdscr, ["Login to reply"])
|
show_notification(self.stdscr, ["Login to reply"])
|
||||||
return
|
return
|
||||||
@@ -244,33 +245,20 @@ class SubmissionPage(BasePage):
|
|||||||
curses.flash()
|
curses.flash()
|
||||||
return
|
return
|
||||||
|
|
||||||
# Fill the bottom half of the screen with the comment box
|
curses.endwin()
|
||||||
n_rows, n_cols = self.stdscr.getmaxyx()
|
|
||||||
box_height = n_rows // 2
|
|
||||||
attr = curses.A_BOLD | Color.CYAN
|
|
||||||
|
|
||||||
for x in range(n_cols):
|
fd, filename = tempfile.mkstemp(prefix="rtv_comment-");
|
||||||
y = box_height - 1
|
os.system('%s %s' % (os.getenv('EDITOR'), filename))
|
||||||
# http://bugs.python.org/issue21088
|
|
||||||
if (sys.version_info.major,
|
|
||||||
sys.version_info.minor,
|
|
||||||
sys.version_info.micro) == (3, 4, 0):
|
|
||||||
x, y = y, x
|
|
||||||
|
|
||||||
self.stdscr.addch(y, x, curses.ACS_HLINE, attr)
|
with os.fdopen(fd, 'r') as comment_file:
|
||||||
|
comment_text = comment_file.read()
|
||||||
|
|
||||||
prompt = 'Enter comment: ESC to cancel, Ctrl+g to submit'
|
curses.doupdate()
|
||||||
scol = max(0, (n_cols // 2) - (len(prompt) // 2))
|
|
||||||
self.stdscr.addnstr(box_height-1, scol, prompt, n_cols-scol, attr)
|
|
||||||
self.stdscr.refresh()
|
|
||||||
|
|
||||||
window = self.stdscr.derwin(n_rows-box_height, n_cols, box_height, 0)
|
|
||||||
window.attrset(Color.CYAN)
|
|
||||||
|
|
||||||
comment_text = text_input(window, allow_resize=False)
|
|
||||||
if comment_text is None:
|
if comment_text is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if data['type'] == 'Submission':
|
if data['type'] == 'Submission':
|
||||||
data['object'].add_comment(comment_text)
|
data['object'].add_comment(comment_text)
|
||||||
|
|||||||
Reference in New Issue
Block a user