Exemplo n.º 1
0
 public GLine(int length)
 {
     Debug.Assert(length > 0);
     _text      = new char[length];
     _firstWord = new GWord(TextDecoration.ClonedDefault(), 0, CharGroup.SingleByte);
     _id        = -1;
 }
Exemplo n.º 2
0
        public GLine Export()
        {
            GWord w = new GWord(_decorations[0] == null? TextDecoration.ClonedDefault() : _decorations[0], 0, GLine.CalcCharGroup(_text[0]));

            GLine line = new GLine(_text, w);

            line.EOLType = _eolType;
            int m = _text.Length;

            for (int offset = 1; offset < m; offset++)
            {
                char ch = _text[offset];
                if (ch == '\0')
                {
                    break;
                }
                else if (ch == GLine.WIDECHAR_PAD)
                {
                    continue;
                }

                TextDecoration dec = _decorations[offset];
                if (_decorations[offset - 1] != dec || w.CharGroup != GLine.CalcCharGroup(ch))
                {
                    if (dec == null)
                    {
                        dec = TextDecoration.ClonedDefault();                               //!!本当はここがnullになっているのはありえないはず。後で調査すること
                    }
                    GWord ww = new GWord(dec, offset, GLine.CalcCharGroup(ch));
                    w.Next = ww;
                    w      = ww;
                }
            }
            return(line);
        }
Exemplo n.º 3
0
 public void Clear()
 {
     for (int i = 0; i < _text.Length; i++)
     {
         _text[i] = '\0';
     }
     _firstWord = new GWord(TextDecoration.ClonedDefault(), 0, CharGroup.SingleByte);
 }
Exemplo n.º 4
0
        //indexの位置の表示を反転した新しいGLineを返す
        //inverseがfalseだと、GWordの分割はするがDecorationの反転はしない。ヒクヒク問題の対処として実装。
        internal GLine InverseCaret(int index, bool inverse, bool underline)
        {
            ExpandBuffer(index + 1);
            if (_text[index] == WIDECHAR_PAD)
            {
                index--;
            }
            GLine ret = new GLine(_text, null);

            ret.ID      = _id;
            ret.EOLType = _eolType;

            GWord w          = _firstWord;
            int   nextoffset = 0;

            while (w != null)
            {
                nextoffset = WordNextOffset(w);
                if (w.Offset <= index && index < nextoffset)
                {
                    //!!tailから順に連結した方が効率はよい
                    if (w.Offset < index)
                    {
                        GWord head = new GWord(w.Decoration, w.Offset, w.CharGroup);
                        ret.Append(head);
                    }

                    TextDecoration dec = (TextDecoration)w.Decoration.Clone();
                    if (inverse)
                    {
                        //色つきキャレットのサポート
                        dec.ToCaretStyle();
                    }
                    if (underline)
                    {
                        dec.Underline = true;
                    }
                    GWord mid = new GWord(dec, index, w.CharGroup);
                    ret.Append(mid);

                    if (index + CalcDisplayLength(_text[index]) < nextoffset)
                    {
                        GWord tail = new GWord(w.Decoration, index + CalcDisplayLength(_text[index]), w.CharGroup);
                        ret.Append(tail);
                    }
                }
                else
                {
                    ret.Append(w.StandAloneClone());
                }

                w = w.Next;
            }

            //!!この、キャレット位置にスペースを入れるのはInverseとは違う処理であるから分離すること
            if (nextoffset <= index)
            {
                while (nextoffset <= index)
                {
                    Debug.Assert(nextoffset < ret.Text.Length);
                    ret.Text[nextoffset++] = ' ';
                }
                TextDecoration dec = TextDecoration.ClonedDefault();
                if (inverse)
                {
                    dec.ToCaretStyle();
                }
                if (underline)
                {
                    dec.Underline = true;
                }
                ret.Append(new GWord(dec, index, CharGroup.SingleByte));
            }

            return(ret);
        }