[Prime-cvs] CVS update: suikyo/ruby/src

Back to archive index

Hiroyuki Komatsu komat****@users*****
2004年 12月 23日 (木) 16:37:25 JST


Index: suikyo/ruby/src/suikyo-composer.rb
diff -u suikyo/ruby/src/suikyo-composer.rb:1.8 suikyo/ruby/src/suikyo-composer.rb:1.9
--- suikyo/ruby/src/suikyo-composer.rb:1.8	Tue Dec 14 17:21:09 2004
+++ suikyo/ruby/src/suikyo-composer.rb	Thu Dec 23 16:37:25 2004
@@ -1,6 +1,6 @@
 # suikyo-composer.rb: Preedition composer using Suikyo.
 # This library is for input methods such as PRIME.
-# $Id: suikyo-composer.rb,v 1.8 2004/12/14 08:21:09 komatsu Exp $
+# $Id: suikyo-composer.rb,v 1.9 2004/12/23 07:37:25 komatsu Exp $
 #
 # Copyright (C) 2004 Hiroyuki Komatsu <komat****@taiya*****>
 #     All rights reserved.
@@ -47,9 +47,9 @@
 class SuikyoComposerData
   attr_reader :position, :head_chunk, :tail_chunk, :typing_mode
   def initialize (position, head_chunk, tail_chunk, typing_mode)
-    @position     = position
-    @head_chunk   = head_chunk
-    @tail_chunk   = tail_chunk
+    @position    = position
+    @head_chunk  = head_chunk
+    @tail_chunk  = tail_chunk
     @typing_mode = typing_mode
   end
 end
@@ -86,6 +86,37 @@
     @hybrid_typing = false
   end
 
+#   def SuikyoComposer::copy (composer)
+#     new_composer = SuikyoComposer.new( composer.get_table(),
+#                                        composer.get_reverse_table() )
+#     (head_chunk, tail_chunk) = composer.chunk_copy()
+#     new_composer.set_composer(head_chunk, tail_chunk, composerposition
+#   end
+
+  ## This copys its chunks and returns a pair of the head and the tail.
+  def chunk_copy ()
+    new_head_chunk = SuikyoCharChunk.new()
+    new_tail_chunk = SuikyoCharChunk.new_next(new_head_chunk)
+    new_chunk = new_head_chunk
+
+    orig_chunk = @head_chunk
+    until orig_chunk.chunk_next == @tail_chunk do
+      orig_chunk = orig_chunk.chunk_next
+      new_chunk = SuikyoCharChunk.new_next(new_chunk)
+      new_chunk.conversion = orig_chunk.conversion.dup()
+      new_chunk.original   = orig_chunk.original.dup()
+      new_chunk.pending    = orig_chunk.pending.dup()
+    end
+
+    return [new_head_chunk, new_tail_chunk]
+  end
+
+#   def set_composer (head_chunk, tail_chunk, position = 0)
+#     @position = position
+#     @head_chunk = head_chunk
+#     @tail_chunk = tail_chunk
+#   end
+
   def reset_composer ()
     @position = 0
     @head_chunk = SuikyoCharChunk.new()
@@ -97,11 +128,18 @@
       @suikyo.table.loadfile(table, table_path)
     }
   end
+  def get_table ()
+    retur****@suiky*****
+  end
+
   def set_reverse_table (tables, table_path = nil)
     tables.each { | table |
       @suikyo_reverse.table.loadfile(table, table_path)
     }
   end
+  def get_reverse_table ()
+    return @suikyo_reverse.table
+  end
 
   def set_table_entry (input, output, pending = nil, unescape = true)
     @suikyo.table.set(input, output, pending, unescape)
@@ -116,13 +154,33 @@
 
   ## This method sets the current status to the undo buffer.
   def undo_set ()
-    data = SuikyoComposerData.new(@position, @head_chunk, @tail_chunk,
+    (head_chunk, tail_chunk) = chunk_copy()
+    data = SuikyoComposerData.new(@position, head_chunk, tail_chunk,
                                   @typing_mode)
 #    @undo_data.push(data)
     @undo_data = [data]
   end
   private :undo_set
 
+  ## This copys its chunks and returns a pair of the head and the tail.
+  def chunk_copy ()
+    new_head_chunk = SuikyoCharChunk.new()
+    new_tail_chunk = SuikyoCharChunk.new_next(new_head_chunk)
+    new_chunk = new_head_chunk
+
+    orig_chunk = @head_chunk
+    until orig_chunk.chunk_next == @tail_chunk do
+      orig_chunk = orig_chunk.chunk_next
+      new_chunk = SuikyoCharChunk.new_next(new_chunk)
+      new_chunk.conversion = orig_chunk.conversion.dup()
+      new_chunk.original   = orig_chunk.original.dup()
+      new_chunk.pending    = orig_chunk.pending.dup()
+    end
+
+    return [new_head_chunk, new_tail_chunk]
+  end
+  private :chunk_copy
+
   ## This method reads the @undo_data and sets them to the current status.
   ## If @undo_data contains no data this return false.
   def undo ()
@@ -262,6 +320,9 @@
       return -1
     end
 
+    # Setting an undo data.
+#    undo_set()
+
     ## Position is the beginning of the chunk list.
     if chunk == @head_chunk then
       chunk = SuikyoCharChunk.new_next(chunk)


Prime-cvs メーリングリストの案内
Back to archive index