13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/twterm/direct_message_composer.rb', line 13
def compose(recipient)
check_type User, recipient
clear
resetter = proc do
reset_prog_mode
sleep 0.1
Screen.instance.refresh
end
thread = Thread.new do
close_screen
puts "\nCompose new message to @%s:" % recipient.screen_name
CompletionManager.instance.set_default_mode!
loop do
line = (readline('> ', true) || '').strip
break if line.empty?
if line.end_with?('\\')
@text << line.chop.rstrip + "\n"
else
@text << line
break
end
end
puts "\n"
resetter.call
send(recipient) unless text.empty?
end
App.instance.register_interruption_handler do
thread.kill
clear
puts "\nCanceled"
resetter.call
end
thread.join
end
|