示例#1
0
        static void StartMultiplierBuilder(ViBuilderContext ctx, ViBuilder nextBuilder)
        {
            int factor     = 1;
            int multiplier = 0;

            ctx.Builder = (ViBuilderContext x) => {
                int c = (int)x.LastKey.Char;
                if (c >= (int)'0' && c <= (int)'9')
                {
                    //don't eat '0' if not preceded by non-zero digit
                    //pass on to interpret as goto line start
                    if (c == (int)'0' && factor == 1)
                    {
                        ctx.Multiplier *= multiplier;
                        ctx.Builder     = nextBuilder;
                        return(ctx.Builder(ctx));
                    }
                    int d = c - (int)'0';
                    multiplier = multiplier * factor + d;
                    factor    *= 10;
                    return(true);
                }
                else
                {
                    ctx.Multiplier *= multiplier;
                    ctx.Builder     = nextBuilder;
                    return(ctx.Builder(ctx));
                }
            };
            ctx.Builder(ctx);
        }
示例#2
0
        public bool Builder(ViBuilderContext ctx)
        {
            Action <ViEditor> a;

            if (actions.TryGetValue(ctx.LastKey, out a))
            {
                ctx.RunAction(a);
                return(true);
            }
            else
            {
                BuilderAction b;
                if (builders.TryGetValue(ctx.LastKey, out b))
                {
                    ctx.Builder = b.Builder;
                    if (b.RunInstantly)
                    {
                        ctx.Builder(ctx);
                    }
                    return(true);
                }
            }
            return(false);
        }
示例#3
0
 static void StartMultiplierBuilder(ViBuilderContext ctx, ViBuilder nextBuilder)
 {
     int factor = 1;
     int multiplier = 0;
     ctx.Builder = (ViBuilderContext x) => {
         int c = (int)x.LastKey.Char;
         if (c >= (int)'0' && c <= (int)'9') {
       //don't eat '0' if not preceded by non-zero digit
       //pass on to interpret as goto line start
       if (c == (int)'0' && factor == 1) {
     ctx.Multiplier *= multiplier;
     ctx.Builder = nextBuilder;
     return ctx.Builder (ctx);
       }
             int d = c - (int)'0';
             multiplier = multiplier * factor + d;
             factor *= 10;
             return true;
         } else {
             ctx.Multiplier *= multiplier;
             ctx.Builder = nextBuilder;
             return ctx.Builder (ctx);
         }
     };
     ctx.Builder (ctx);
 }