Ejemplo n.º 1
0
Archivo: text.cs Proyecto: kwanboy/mcs
        //-------------------------------------------------
        //  truncate_wrap
        //-------------------------------------------------
        void truncate_wrap()
        {
            char32_t elipsis = 0x2026;

            // for now, lets assume that we're only truncating the last character
            UInt32 truncate_position = m_current_line.character_count() - 1;
            var    truncate_char     = m_current_line.character(truncate_position);

            // copy style information
            char_style style = truncate_char.style;

            // copy source information
            source_info source;

            source.start = truncate_char.source.start + truncate_char.source.span;
            source.span  = 0;

            // figure out how wide an elipsis is
            float elipsis_width = get_char_width(elipsis, style.size);

            // where should we really truncate from?
            while (truncate_position > 0 && m_current_line.character(truncate_position).xoffset + elipsis_width > width())
            {
                truncate_position--;
            }

            // truncate!!!
            m_current_line.truncate(truncate_position);

            // and append the elipsis
            m_current_line.add_character(elipsis, style, source);

            // take note that we are truncating; supress new characters
            m_truncating = true;
        }
Ejemplo n.º 2
0
Archivo: text.cs Proyecto: kwanboy/mcs
        //-------------------------------------------------
        //  word_wrap
        //-------------------------------------------------
        void word_wrap()
        {
            // keep track of the last line and break
            line   last_line  = m_current_line;
            UInt32 last_break = m_last_break;

            // start a new line with the same justification
            start_new_line(last_line.justify(), last_line.character(last_line.character_count() - 1).style.size);

            // find the begining of the word to wrap
            UInt32 position = last_break;

            while (position + 1 < last_line.character_count() && is_space_character(last_line.character(position).character))
            {
                position++;
            }

            // transcribe the characters
            for (UInt32 i = position; i < last_line.character_count(); i++)
            {
                var ch = last_line.character(i);
                m_current_line.add_character(ch.character, ch.style, ch.source);
            }

            // and finally, truncate the last line
            last_line.truncate(last_break);
        }
Ejemplo n.º 3
0
        //-------------------------------------------------
        //  word_wrap
        //-------------------------------------------------
        void word_wrap()
        {
            // keep track of the last line and break
            line   last_line  = m_current_line;
            size_t last_break = m_last_break != 0 ? m_last_break : (last_line.character_count() - 1);

            // start a new line with the same justification
            start_new_line(last_line.character(last_line.character_count() - 1).style.size);

            // find the beginning of the word to wrap
            size_t position = last_break;

            while ((last_line.character_count() > position) && is_space_character(last_line.character(position).character))
            {
                position++;
            }

            // carry over justification
            if (last_line.right_justify_start() <= position)
            {
                m_current_line.set_justification(text_justify.RIGHT);
            }
            else if (last_line.center_justify_start() <= position)
            {
                m_current_line.set_justification(text_justify.CENTER);
            }

            // transcribe the characters
            for (size_t i = position; i < last_line.character_count(); i++)
            {
                if (last_line.right_justify_start() == i)
                {
                    m_current_line.set_justification(text_justify.RIGHT);
                }
                else if (last_line.center_justify_start() == i)
                {
                    m_current_line.set_justification(text_justify.CENTER);
                }

                var ch = last_line.character(i);
                m_current_line.add_character(this, ch.character, ch.style, ch.source);
            }

            // and finally, truncate the previous line and adjust spacing
            last_line.truncate(last_break);
            last_line.align_text(this);
        }