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

ruby-changes:37258

From: naruse <ko1@a...>
Date: Tue, 20 Jan 2015 11:26:06 +0900 (JST)
Subject: [ruby-changes:37258] naruse:r49339 (trunk): * tool/redmine-backporter.rb (mygets): to support Backspace

naruse	2015-01-20 11:25:48 +0900 (Tue, 20 Jan 2015)

  New Revision: 49339

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

  Log:
    * tool/redmine-backporter.rb (mygets): to support Backspace
      implement gets by itself.

  Modified files:
    trunk/ChangeLog
    trunk/tool/redmine-backporter.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 49338)
+++ ChangeLog	(revision 49339)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Jan 20 11:23:47 2015  NARUSE, Yui  <naruse@r...>
+
+	* tool/redmine-backporter.rb (mygets): to support Backspace
+	  implement gets by itself.
+
 Tue Jan 20 02:54:11 2015  Zachary Scott  <e@z...>
 
         * file.c: NotImplementedError is raised if birthtime is unavailable.
Index: tool/redmine-backporter.rb
===================================================================
--- tool/redmine-backporter.rb	(revision 49338)
+++ tool/redmine-backporter.rb	(revision 49339)
@@ -195,6 +195,33 @@ def more(sio) https://github.com/ruby/ruby/blob/trunk/tool/redmine-backporter.rb#L195
   end
 end
 
+def mygets
+  console = IO.console
+  ly, lx = console.winsize
+  cls = "\r" + (" " * lx) + "\r> "
+  line = ''
+  while 1
+    case c = console.getch
+    when "\r"
+      puts
+      line << c
+      return line
+    when "\x07", "\b" # DEL/BS
+      print "\b"
+      line.chop!
+    when "\x15" # C-u
+      print cls
+      line.clear
+    when "\x04" # C-d
+      return nil if line.empty?
+      line << c
+    else
+      print c
+      line << c
+    end
+  end
+end
+
 def mergeinfo
   `svn propget svn:mergeinfo #{RUBY_REPO_PATH}`
 end
@@ -234,7 +261,7 @@ puts "Backporter #{VERSION}".color(bold: https://github.com/ruby/ruby/blob/trunk/tool/redmine-backporter.rb#L261
 while true
   print '> '
   begin
-    l = gets
+    l = mygets
   rescue Interrupt
     break
   end

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

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