/// <summary> /// Insert "()" into the rootbox at the current selection, then back up the selection /// to be between the parentheses. /// </summary> /// <param name="rootb"></param> public static void InsertOptionalItem(IVwRootBox rootb) { rootb.OnChar('('); rootb.OnChar(')'); // Adjust the selection to be between the parentheses. var vwsel = rootb.Selection; var cvsli = vwsel.CLevels(false); // CLevels includes the string property itself, but AllTextSelInfo doesn't need it. cvsli--; int ihvoRoot; int tagTextProp; int cpropPrevious; int ichAnchor; int ichEnd; int ws; bool fAssocPrev; int ihvoEnd; ITsTextProps ttp; var rgvsli = SelLevInfo.AllTextSelInfo(vwsel, cvsli, out ihvoRoot, out tagTextProp, out cpropPrevious, out ichAnchor, out ichEnd, out ws, out fAssocPrev, out ihvoEnd, out ttp); Debug.Assert(ichAnchor == ichEnd); Debug.Assert(ichAnchor > 0); --ichEnd; --ichAnchor; rootb.MakeTextSelection(ihvoRoot, cvsli, rgvsli, tagTextProp, cpropPrevious, ichAnchor, ichEnd, ws, fAssocPrev, ihvoEnd, ttp, true); }
/// <summary> /// Insert "()" into the rootbox at the current selection, then back up the selection /// to be between the parentheses. /// </summary> /// <param name="rootb"></param> public static void InsertOptionalItem(IVwRootBox rootb) { rootb.OnChar((int)'('); rootb.OnChar((int)')'); // Adjust the selection to be between the parentheses. IVwSelection vwsel = rootb.Selection; int cvsli = vwsel.CLevels(false); // CLevels includes the string property itself, but AllTextSelInfo doesn't need it. cvsli--; int ihvoRoot; int tagTextProp; int cpropPrevious; int ichAnchor; int ichEnd; int ws; bool fAssocPrev; int ihvoEnd; ITsTextProps ttp; SelLevInfo[] rgvsli = SelLevInfo.AllTextSelInfo(vwsel, cvsli, out ihvoRoot, out tagTextProp, out cpropPrevious, out ichAnchor, out ichEnd, out ws, out fAssocPrev, out ihvoEnd, out ttp); Debug.Assert(ichAnchor == ichEnd); Debug.Assert(ichAnchor > 0); --ichEnd; --ichAnchor; rootb.MakeTextSelection(ihvoRoot, cvsli, rgvsli, tagTextProp, cpropPrevious, ichAnchor, ichEnd, ws, fAssocPrev, ihvoEnd, ttp, true); }