[前][次][番号順一覧][スレッド一覧]

ruby-changes:37263

From: nobu <ko1@a...>
Date: Tue, 20 Jan 2015 12:14:32 +0900 (JST)
Subject: [ruby-changes:37263] nobu:r49344 (trunk): redmine-backporter.rb: like Readline.readline

nobu	2015-01-20 12:14:21 +0900 (Tue, 20 Jan 2015)

  New Revision: 49344

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=49344

  Log:
    redmine-backporter.rb: like Readline.readline
    
    * tool/redmine-backporter.rb (readline): rename and add optional
      argument prompt, like Readline.readline.

  Modified files:
    trunk/tool/redmine-backporter.rb
Index: tool/redmine-backporter.rb
===================================================================
--- tool/redmine-backporter.rb	(revision 49343)
+++ tool/redmine-backporter.rb	(revision 49344)
@@ -195,16 +195,17 @@ def more(sio) https://github.com/ruby/ruby/blob/trunk/tool/redmine-backporter.rb#L195
   end
 end
 
-def mygets
+def readline(prompt = '')
   console = IO.console
   ly, lx = console.winsize
-  cls = "\r" + (" " * lx) + "\r> "
+  cls = "\r" + (" " * lx) + "\r" + prompt
+  console.print prompt
+  console.flush
   line = ''
   while 1
     case c = console.getch
     when "\r", "\n"
       puts
-      line << c
       return line
     when "\C-?", "\b" # DEL/BS
       print "\b \b" if line.chop!
@@ -258,13 +259,11 @@ puts "Backporter #{VERSION}".color(bold: https://github.com/ruby/ruby/blob/trunk/tool/redmine-backporter.rb#L259
 @issue = nil
 @changesets = nil
 while true
-  print '> '
   begin
-    l = mygets
+    l = readline '> '
   rescue Interrupt
     break
   end
-  l.strip! if l
   case l
   when 'ls'
     uri = URI(REDMINE_BASE+'/projects/ruby-trunk/issues.json?'+URI.encode_www_form(@query))

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]