*** empty log message ***
[m17n/m17n-lib-cs.git] / MInputMethod.cs
index da10788..d08f7c2 100644 (file)
@@ -559,7 +559,10 @@ namespace M17N.Input
         }
        public virtual int CharAt (Context ic)
         {
-          return ic.preedit[Position (ic)];
+          int pos = Position (ic);
+
+          return ((pos >= 0 && pos < ic.preedit.Length) ? ic.preedit[pos]
+                  : -1);
         }
 
        public override string ToString ()
@@ -647,7 +650,7 @@ namespace M17N.Input
 
         public PredefinedSurround (MSymbol name) : base (name)
           {
-            if (! int.TryParse (((string) name).Substring (2), out distance))
+            if (! int.TryParse (((string) name).Substring (1), out distance))
               throw new Exception ("Invalid marker name: " + name);
             if (distance > 0)
               distance--;
@@ -2292,7 +2295,7 @@ namespace M17N.Input
                                               Xex.Term[] args)
     {
       return new Xex.Term (((Context) domain.context).GetSurroundingText == null
-                          ? 0 : 1);
+                          ? -2 : -1);
     }
 
     public override string ToString ()
@@ -2724,6 +2727,8 @@ namespace M17N.Input
 
       private bool handle_key ()
       {
+       Console.WriteLine ("{0}:key='{1}'", state.name,
+                          new MText (keys.keyseq[key_head].ToChar ()));
        Keymap sub = keymap.Lookup (keys, ref key_head);
 
        if (sub != keymap)