当前位置: 首页>>代码示例>>C#>>正文


C# TextBuffer.GetText方法代码示例

本文整理汇总了C#中Gtk.TextBuffer.GetText方法的典型用法代码示例。如果您正苦于以下问题:C# TextBuffer.GetText方法的具体用法?C# TextBuffer.GetText怎么用?C# TextBuffer.GetText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Gtk.TextBuffer的用法示例。


在下文中一共展示了TextBuffer.GetText方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetSqlStatementAtCursor

        // Execute first SQL statement at cursor
        public string GetSqlStatementAtCursor(TextBuffer sqlTextBuffer, out TextIter iter)
        {
            TextIter start_iter, end_iter, insert_iter;
            TextIter match_start1, match_end1, match_start2, match_end2;
            TextIter begin_iter, finish_iter;
            string text = String.Empty;
            int char_count = 0;
            TextMark insert_mark;

            insert_mark = sqlTextBuffer.InsertMark;
            insert_iter = sqlTextBuffer.GetIterAtMark (insert_mark);
            start_iter = sqlTextBuffer.GetIterAtOffset (0);

            char_count = sqlTextBuffer.CharCount;
            end_iter = sqlTextBuffer.GetIterAtOffset (char_count);
            iter = end_iter;

            match_start1 = sqlTextBuffer.GetIterAtOffset (0);
            match_end1 = sqlTextBuffer.GetIterAtOffset (char_count);
            match_start2 = sqlTextBuffer.GetIterAtOffset (0);
            match_end2 = sqlTextBuffer.GetIterAtOffset (char_count);

            begin_iter = sqlTextBuffer.GetIterAtOffset (0);
            finish_iter = sqlTextBuffer.GetIterAtOffset (char_count);

            if (start_iter.IsEnd == false)
            {
                if (insert_iter.BackwardSearch (";", TextSearchFlags.TextOnly,
                        out match_start1, out match_end1, start_iter) == true) {
                    begin_iter = match_start1;
                    begin_iter.ForwardChars (1);
                }

                if (insert_iter.ForwardSearch (";",	TextSearchFlags.TextOnly,
                        out match_start2, out match_end2, end_iter) == true) {
                    finish_iter = match_end2;
                    finish_iter.BackwardChars (1);
                }
                iter = finish_iter;
                text = sqlTextBuffer.GetText (begin_iter, finish_iter, false);

                // FIXME: for this to work.  GetSqlStatement has to rewritten to be line-based
                if (text.Length > 0) {
                    // search does not work if what you are searching for is
                    // at the end of the buffer,
                    // this compensates for this
                    int j = text.Length;
                    int cont = 1;
                    for(int i = text.Length - 1; cont == 1 && i >= 0; i--) {
                        char ch = text[i];
                        switch(ch) {
                        case ' ':
                        case ';':
                            j--;
                            break;
                        default:
                            cont = 0;
                            break;
                        }
                    }

                    if (j != text.Length) {
                        string t = text.Substring(0, j);
                        text = t;
                    }
                }
            }

            return text;
        }
开发者ID:slluis,项目名称:monodevelop-prehistoric,代码行数:71,代码来源:SqlQueryView.cs

示例2: GetNextSqlStatement

        // get next SQL statement.  Requires GetSqlStatementAtCursor having been called first
        public string GetNextSqlStatement(TextBuffer sqlTextBuffer, ref TextIter iter)
        {
            TextIter start_iter, end_iter;
            TextIter match_start2, match_end2;
            TextIter finish_iter;
            string text = String.Empty;
            int char_count = 0;

            char_count = sqlTextBuffer.CharCount;
            end_iter = sqlTextBuffer.GetIterAtOffset (char_count);
            if (iter.IsEnd == false) {
                iter.ForwardChars (1);
                if (sqlTextBuffer.GetText (iter, end_iter, false).Equals (";"))
                    iter.ForwardChars (1);
            }

            if (iter.IsEnd == true)
                return "";

            start_iter = iter;
            match_start2 = iter;
            match_end2 = sqlTextBuffer.GetIterAtOffset (char_count);
            finish_iter = sqlTextBuffer.GetIterAtOffset (char_count);

            if (start_iter.IsEnd == false) {
                if (iter.ForwardSearch (";", TextSearchFlags.TextOnly,
                        out match_start2, out match_end2, end_iter) == true) 	{
                    finish_iter = match_end2;
                    finish_iter.BackwardChars (1);
                }

                text = sqlTextBuffer.GetText (iter, finish_iter, false);
                iter = finish_iter;

                if(text.Length > 0) {
                    // search does not work if what you are searching for is
                    // at the end of the buffer,
                    // this compensates for this
                    int j = text.Length;
                    int cont = 1;
                    for(int i = text.Length - 1; cont == 1 && i >= 0; i--) {
                        char ch = text[i];
                        switch(ch) {
                        case ' ':
                        case ';':
                            j--;
                            break;
                        default:
                            cont = 0;
                            break;
                        }
                    }

                    if(j != text.Length) {
                        string t = text.Substring(0, j);
                        text = t;
                    }
                }
            }

            return text;
        }
开发者ID:slluis,项目名称:monodevelop-prehistoric,代码行数:63,代码来源:SqlQueryView.cs


注:本文中的Gtk.TextBuffer.GetText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。