Ejemplo n.º 1
0
        private void OnEngineModified(object?sender, EventArgs e)
        {
            string?markup = SecurityElement.Escape(engine.ToString());

            if (engine.Underline)
            {
                markup = string.Format("<u>{0}</u>", markup);
            }

            switch (engine.Alignment)
            {
            case TextAlignment.Right:
                Layout.Alignment = Pango.Alignment.Right;
                break;

            case TextAlignment.Center:
                Layout.Alignment = Pango.Alignment.Center;
                break;

            case TextAlignment.Left:
                Layout.Alignment = Pango.Alignment.Left;
                break;
            }

            Layout.FontDescription = engine.Font;

            Layout.SetMarkup(markup);
        }
Ejemplo n.º 2
0
        public void PerformEnter ()
        {
            var engine = new TextEngine (new List<string> () { "foo", "bar" });
            engine.SetCursorPosition (new TextPosition (1, 1), true);
            engine.PerformEnter ();

            Assert.AreEqual (3, engine.LineCount);
            Assert.AreEqual (LinesToString (new string[] {"foo", "b", "ar" }),
                             engine.ToString());
            Assert.AreEqual (new TextPosition (2, 0), engine.CurrentPosition);
        }
Ejemplo n.º 3
0
        public void DeleteSelection ()
        {
            var engine = new TextEngine (new List<string> () { "это тест", "это еще один тест" });
            engine.SetCursorPosition (new TextPosition (0, 2), true);
            engine.PerformDown (true);
            engine.PerformDelete ();

            Assert.AreEqual (1, engine.LineCount);
            Assert.AreEqual (LinesToString (new string[] { "это еще один тест" }),
                             engine.ToString ());
            Assert.AreEqual (new TextPosition (0, 2), engine.CurrentPosition);
        }
Ejemplo n.º 4
0
        public void DeleteMultiLineSelection ()
        {
            var engine = new TextEngine (new List<string> () { "line 1", "line 2", "line 3" });
            engine.SetCursorPosition (new TextPosition (0, 2), true);
            engine.PerformDown (true);
            engine.PerformDown (true);
            engine.PerformDelete ();

            Assert.AreEqual (1, engine.LineCount);
            Assert.AreEqual (LinesToString (new string[] { "line 3" }),
                             engine.ToString ());
        }
Ejemplo n.º 5
0
        private void OnEngineModified(object sender, EventArgs e)
        {
            string markup = SecurityElement.Escape(engine.ToString());

            if (engine.Underline)
            {
                markup = string.Format("<u>{0}</u>", markup);
            }

            switch (engine.Alignment)
            {
            case TextAlignment.Right:
                Layout.Alignment = Pango.Alignment.Right;
                break;

            case TextAlignment.Center:
                Layout.Alignment = Pango.Alignment.Center;
                break;

            case TextAlignment.Left:
                Layout.Alignment = Pango.Alignment.Left;
                break;
            }

            var font = Pango.FontDescription.FromString(
                string.Format("{0} {1}", engine.FontFace, engine.FontSize));

            // Forces font variants to be rendered properly
            // (e.g. this will use "Ubuntu Condensed" instead of "Ubuntu").
            font.Family            = engine.FontFace;
            font.Weight            = engine.Bold ? Pango.Weight.Bold : Pango.Weight.Normal;
            font.Style             = engine.Italic ? Pango.Style.Italic : Pango.Style.Normal;
            Layout.FontDescription = font;

            Layout.SetMarkup(markup);
        }