Esempio n. 1
0
        internal override void InsertText(InsertionPoint ip, string input)
        {
            MultiAccessor.set_String(m_ws, ((MlsClientRun)ParaBox.Source.ClientRuns[ClientRunIndex]).Tss);
            var bldr = MultiAccessor.get_String(m_ws).GetBldr();
            // Where there is a choice, we want the new text to have the properties of the neighbor
            // character that the IP is most closely associated with.
            ITsTextProps props;

            if (ip.StringPosition > 0 && ip.AssociatePrevious)
            {
                props = bldr.get_PropertiesAt(ip.StringPosition - 1);
            }
            else
            {
                props = bldr.get_PropertiesAt(ip.StringPosition);                 // might be the lim, but that's OK.
            }
            if (ip.StyleToBeApplied != null)
            {
                var propsBldr = props.GetBldr();
                propsBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, ip.StyleToBeApplied.Name);
                props = propsBldr.GetTextProps();
            }

            // Enhance JohnT: there may possibly be some special caes, e.g., where the indicated character
            // is an ORC linked to certain kinds of data or a verse number, where we don't want to copy all
            // the properties.
            bldr.Replace(ip.StringPosition, ip.StringPosition, input, props);
            MultiAccessor.set_String(m_ws, bldr.GetString());
        }
Esempio n. 2
0
 internal override void Delete(InsertionPoint start, InsertionPoint end)
 {
     if (CanDelete(start, end))
     {
         MultiAccessor.set_String(m_ws, ((MlsClientRun)ParaBox.Source.ClientRuns[ClientRunIndex]).Tss);
         var bldr   = MultiAccessor.get_String(m_ws).GetBldr();
         int newPos = start.StringPosition;
         bldr.Replace(newPos, end.StringPosition, "", null);
         MultiAccessor.set_String(m_ws, bldr.GetString());
     }
 }
Esempio n. 3
0
        internal override void ApplyStyle(InsertionPoint start, InsertionPoint end, string style)
        {
            if (!CanApplyStyle(start, end, style))
            {
                return;
            }

            MultiAccessor.set_String(m_ws, ((MlsClientRun)ParaBox.Source.ClientRuns[ClientRunIndex]).Tss);
            var bldr   = MultiAccessor.get_String(m_ws).GetBldr();
            int newPos = start.StringPosition;

            bldr.SetStrPropValue(newPos, end.StringPosition, (int)FwTextPropType.ktptNamedStyle, style);
            MultiAccessor.set_String(m_ws, bldr.GetString());
        }
Esempio n. 4
0
        public void MlsRuns()
        {
            string           part1 = "abc def";
            IViewMultiString mls   = new MultiAccessor(wsEn, wsEn);

            mls.set_String(wsEn, tsf.MakeString(part1, wsEn));
            AssembledStyles styles    = new AssembledStyles();
            MlsClientRun    clientRun = new MlsClientRun(mls, styles.WithWs(wsEn));

            Assert.AreEqual(1, clientRun.UniformRunCount);
            Assert.AreEqual(part1, clientRun.UniformRunText(0));
            AssembledStyles style1 = clientRun.UniformRunStyles(0);

            Assert.AreEqual(wsEn, style1.Ws);
            Assert.AreEqual(0, clientRun.UniformRunStart(0));
            Assert.AreEqual(part1.Length, clientRun.UniformRunLength(0));

            string     part2 = " ghi";
            ITsStrBldr bldr  = mls.get_String(wsEn).GetBldr();

            bldr.Replace(part1.Length, part1.Length, part2, ttpFrn);
            IViewMultiString multibldr = new MultiAccessor(wsEn, wsEn);

            multibldr.set_String(wsFrn, bldr.GetString());
            MlsClientRun clientRun2 = new MlsClientRun(multibldr, styles.WithWs(wsFrn));

            Assert.AreEqual(2, clientRun2.UniformRunCount);
            Assert.AreEqual(part1, clientRun2.UniformRunText(0));
            Assert.AreEqual(part2, clientRun2.UniformRunText(1));
            style1 = clientRun2.UniformRunStyles(0);
            Assert.AreEqual(wsEn, style1.Ws);
            AssembledStyles style2 = clientRun2.UniformRunStyles(1);

            Assert.AreEqual(wsFrn, style2.Ws);
            Assert.AreEqual(0, clientRun2.UniformRunStart(0));
            Assert.AreEqual(part1.Length, clientRun2.UniformRunLength(0));
            Assert.AreEqual(part1.Length, clientRun2.UniformRunStart(1));
            Assert.AreEqual(part2.Length, clientRun2.UniformRunLength(1));
        }