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); }
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); }
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); }