Skip to content

Commit 9b50bdb

Browse files
shreyamalviyapreetmishra
authored andcommitted
core/keys/views: Introduce EditHistoryView for edit history.
This, essentially, lays the groundwork for 'edit history' feature.
1 parent b1a104f commit 9b50bdb

File tree

3 files changed

+37
-2
lines changed

3 files changed

+37
-2
lines changed

zulipterminal/config/keys.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,12 @@
205205
'help_text': 'View message information',
206206
'key_category': 'msg_actions',
207207
}),
208+
('EDIT_HISTORY', {
209+
'keys': {'d'},
210+
'help_text': 'View edit history from message information box',
211+
'excluded_from_random_tips': True,
212+
'key_category': 'msg_actions',
213+
}),
208214
('STREAM_DESC', {
209215
'keys': {'i'},
210216
'help_text': 'View stream description',

zulipterminal/core.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
from zulipterminal.ui import Screen, View
1616
from zulipterminal.ui_tools.utils import create_msg_box_list
1717
from zulipterminal.ui_tools.views import (
18-
HelpView, MsgInfoView, NoticeView, PopUpConfirmationView, StreamInfoView,
18+
EditHistoryView, HelpView, MsgInfoView, NoticeView, PopUpConfirmationView,
19+
StreamInfoView,
1920
)
2021
from zulipterminal.version import ZT_VERSION
2122

@@ -124,6 +125,10 @@ def show_stream_info(self, color: str, name: str, desc: str) -> None:
124125
def popup_with_message(self, text: str, width: int, height: int) -> None:
125126
self.show_pop_up(NoticeView(self, text, width, height), "NOTICE")
126127

128+
def show_edit_history(self, msg: Any) -> None:
129+
self.show_pop_up(EditHistoryView(self, msg),
130+
'Edit History (up/down scrolls)')
131+
127132
def search_messages(self, text: str) -> None:
128133
# Search for a text in messages
129134
self.model.index['search'].clear()

zulipterminal/ui_tools/views.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import urwid
77

88
from zulipterminal.config.keys import (
9-
HELP_CATEGORIES, KEY_BINDINGS, is_command_key,
9+
HELP_CATEGORIES, KEY_BINDINGS, is_command_key, keys_for_command,
1010
)
1111
from zulipterminal.helper import Message, asynch, match_user
1212
from zulipterminal.ui_tools.boxes import PanelSearchBox
@@ -904,6 +904,9 @@ def __init__(self, controller: Any, msg: Message) -> None:
904904
('Date & Time', time.ctime(msg['timestamp'])[:-5]),
905905
('Sender', msg['sender_full_name']),
906906
('Sender\'s Email ID', msg['sender_email']),
907+
('Edit History',
908+
'Press ' + ', '.join(map(repr, keys_for_command('EDIT_HISTORY')))
909+
+ ' to view'),
907910
('Reactions', reactions if msg['reactions'] else '---None---'),
908911
])
909912

@@ -925,3 +928,24 @@ def __init__(self, controller: Any, msg: Message) -> None:
925928
for index, (field, data) in enumerate(msg_info.items())]
926929

927930
super().__init__(controller, msg_info_content, 'MSG_INFO')
931+
932+
def keypress(self, size: urwid_Size, key: str) -> str:
933+
if is_command_key('EDIT_HISTORY', key):
934+
self.controller.show_edit_history(self.msg)
935+
return super().keypress(size, key)
936+
937+
938+
class EditHistoryView(PopUpView):
939+
def __init__(self, controller: Any, msg: Any) -> None:
940+
self.controller = controller
941+
self.msg = msg
942+
self.width = 64
943+
self.height = 0
944+
super().__init__(controller, [], 'MSG_INFO')
945+
946+
def keypress(self, size: urwid_Size, key: str) -> str:
947+
if (is_command_key('GO_BACK', key)
948+
or is_command_key('EDIT_HISTORY', key)):
949+
self.controller.show_msg_info(self.msg)
950+
return key
951+
return super().keypress(size, key)

0 commit comments

Comments
 (0)