我想找'';'位置在多文本框中当前光标位置之后的字符。不是全部';'就在当前光标位置之后。
目前我的工作如下。检查每行';'字符im循环,如果它发现退出循环。我应该怎么写'if'命令,如果有更简单的方法,请与我分享;
Inductive Cat := cons_cat (O : Type) (M : O -> O -> Type).
Definition ob (c : Cat) :=
match c with cons_cat o _ => o end.
Definition morph (c : Cat) : ob c -> ob c -> Type :=
match c with cons_cat _ m => m end.
Inductive Functor
(A B : Cat)
: Type :=
cons_functor
(ob_fn : ob A -> ob B)
(morph_fn : forall {c d : ob A}, morph A c d -> morph B (ob_fn c) (ob_fn d)).
Definition ob_fn {A B : Cat} (f : Functor A B) : ob A -> ob B :=
match f with cons_functor f' _ => f' end.
Definition morph_fn {A B : Cat} {c d : ob A} (f : Functor A B)
: morph A c d -> morph B (ob_fn f c) (ob_fn f d) :=
match f with cons_functor _ f' => f' c d end.
Theorem functor_decompose {A B : Cat} {o fm gm} : cons_functor A B o fm = cons_functor A B o gm -> fm = gm.
intros H.
assert (forall c d, @morph_fn A B c d (cons_functor A B o fm) = @morph_fn A B c d (cons_functor A B o gm)).
intros.
rewrite H.
答案 0 :(得分:2)
我想找到';'位置在多文本框中当前光标位置之后的字符。
您可以使用IndexOf
来实现此目标。
var nextCharIndex = this.uteSQL.Text.IndexOf(";", uteSQL.SelectionStart);
如果要查找找到的字符的行索引,可以执行以下操作。
var nextCharIndex = this.uteSQL.Text.IndexOf(";", uteSQL.SelectionStart);
var lineIndexOfChar = nextCharIndex < 0
? -1
: this.uteSQL.Text.Substring(0, nextCharIndex)
.Split(new [] { Environment.NewLine }, StringSplitOptions.None).Length - 1;
答案 1 :(得分:0)
int line = uteSQL.Text.Take(uteSQL.SelectionStart).Count('\n'.Equals) + 1;
int index = uteSQL.Text.IndexOf(';', uteSQL.SelectionStart);
int column = index - uteSQL.Text.LastIndexOf('\n', index);