Example #1
0
        public LoginDialog(SqlSharpGtk sqlSharpGtk)
        {
            sqlSharp = sqlSharpGtk;

            grid          = new DataGrid();
            providerCombo = ComboBox.NewText();

            PopulateProviders();
            PopulateAppSettings();

            CreateGui();

            SetStatusBarText("Ready.");
        }
Example #2
0
        void DebugText(TextIter iter_start, TextIter iter_end,
                       string debugMessage)
        {
#if DEBUG
            string text = sqlTextBuffer.GetText(
                iter_start, iter_end, false);
            string msg =
                "[DEBUG-TEXT]: " +
                debugMessage +
                " (" +
                text +
                ")";
            SqlSharpGtk.DebugWriteLine(msg);
#endif // DEBUG
        }
Example #3
0
        // Private Methods

        void OnTextChanged(object o, EventArgs args)
        {
            if (tab != null)
            {
                tab.label.Text = tab.basefilename + " *";
            }

            SqlSharpGtk.DebugWriteLine("[[[[[ Syntax Hi-Light Text BEGIN ]]]]]");

            if (use_hi_lighting == true)
            {
                SyntaxHiLightText();
            }

            SqlSharpGtk.DebugWriteLine("[[[[[ Syntax Hi-Light Text END   ]]]]]\n");
        }
Example #4
0
        public void SetColumnValue(TreeIter iter, int column, byte[] value)
        {
            string svalue = SqlSharpGtk.GetHexString(value);

            SetColumnValue(iter, column, svalue);
        }
Example #5
0
        /* is word a SQL keyword? */
        bool IsTextSQL(string text, int begin, int end)
        {
            string keyword = "";

            int i;
            int text_len;

            if (text.Equals(String.Empty))
            {
                return(false);
            }

            if (begin < 0)
            {
                return(false);
            }

            if (end < 2)
            {
                return(false);
            }

            if (begin >= end)
            {
                return(false);
            }

            text_len = end - begin;
            if (text_len < 1)
            {
                return(false);
            }

#if DEBUG
            SqlSharpGtk.DebugWriteLine("IsTextSQL - " +
                                       "begin: " + begin.ToString() +
                                       " end: " + end.ToString() +
                                       " text_len: " + text_len);
            SqlSharpGtk.DebugWriteLine("[TEXT BEGIN]");
            SqlSharpGtk.DebugWriteLine(text);
            SqlSharpGtk.DebugWriteLine("[TEXT END  ]");
#endif // DEBUG

            for (i = 0; sql_keywords[i] != String.Empty; i++)
            {
                if (text_len == sql_keywords[i].Length)
                {
                    SqlSharpGtk.DebugWriteLine(
                        "Test length: " + text_len +
                        " keyword: " + keyword);

                    try {
                        keyword = text.Substring(begin, text_len);
                    }
                    catch (ArgumentOutOfRangeException a) {
                        Console.WriteLine("Internal Error: SqlSharpGtk: text.Substring() ArgumentOutOfRange");
                    }

                    keyword = keyword.ToUpper();

                    if (keyword.Equals(sql_keywords [i]))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Example #6
0
        void SyntaxHiLightText()
        {
            TextIter start_iter, end_iter,
                     iter, insert_iter;
            TextIter match_start1, match_end1,
                     match_start2, match_end2;
            int    char_count = 0;
            int    hyphen = 0, single_quotes = 0;
            string text = String.Empty;
            int    i = 0, start_con = 0, end_con = 0;
            //int line = 0;
            //int freecomment_count = 0;
            int      start_word = -1;
            TextMark insert_mark;
            char     ch = ' ';

            insert_mark = sqlTextBuffer.InsertMark;
            sqlTextBuffer.GetIterAtMark(out insert_iter, insert_mark);
            //line = insert_iter.Line;

            /* get the starting and ending text iterators */
            sqlTextBuffer.GetIterAtOffset(out start_iter, 0);
            char_count = sqlTextBuffer.CharCount;
            sqlTextBuffer.GetIterAtOffset(out end_iter, char_count);

            SqlSharpGtk.DebugWriteLine("char_count: " + char_count);

            /* since line is not same - redo all */
            //if (line != line_last_changed) {
            /* remove all previously applied tags */
            sqlTextBuffer.RemoveAllTags(start_iter, end_iter);

            /* apply the entire buffer to the normaltext tag */
            sqlTextBuffer.ApplyTag(normaltext_tag, start_iter, end_iter);
            //}
            //else { /* just worry about current insertion line */
            //	/* get start iter */
            //	if (insert_iter.StartsLine () == true) {
            //		start_iter = insert_iter;
            //	}
            //	else {
            //		start_iter = insert_iter;
            //		start_iter.LineOffset = 0;
            //	}
            //	/* get end iter */
            //	end_iter.ForwardToLineEnd ();
            //	char_count = start_iter.CharsInLine;
            //
            //	/* remove all previously applied tags */
            //	sqlTextBuffer.RemoveAllTags (start_iter, end_iter);
            //
            //	/* apply the entire buffer to the normaltext tag */
            //	sqlTextBuffer.ApplyTag (normaltext_tag,
            //		start_iter, end_iter);
            //
            //	/* get the starting and ending text iterators */
            //	sqlTextBuffer.GetIterAtOffset (out start_iter, 0);
            //	char_count = sqlTextBuffer.CharCount;
            //	sqlTextBuffer.GetIterAtOffset (out end_iter, char_count);
            //}

            /*  ------------------------------------
             *  Free Comments (sort of like c style)
             *  ------------------------------------
             *  except in SQL, a c like comment occurs within
             *  a SQL statement
             */
            match_start1 = start_iter;         // dummy
            match_end1   = end_iter;           // dummy
            match_start2 = start_iter;         // dummy
            match_end2   = end_iter;           // dummy

            while (start_iter.IsEnd == false)
            {
                // FIXME: match_start1, match_end1, end_iter
                //        need to be set to have ref in front
                //        Problem with TextIter's ForwardSearch()
                //        in GTK# (not GTK+)
                if (start_iter.ForwardSearch(
                        "/*",
                        TextSearchFlags.TextOnly,
                        out match_start1,
                        out match_end1,
                        end_iter) == true)
                {
                    /* beginning of free comment found */
                    //freecomment_count++;
                    // FIXME: fix match_start2, match_end2, end_iter
                    //        with ref if front
                    if (match_end1.ForwardSearch(
                            "*/",
                            TextSearchFlags.TextOnly,
                            out match_start2,
                            out match_end2,
                            end_iter) == true)
                    {
                        // ending of free comment found,
                        // now hi-light comment
                        sqlTextBuffer.ApplyTag(
                            freecomment_tag,
                            match_start1,
                            match_end2);
                        match_end2.ForwardChars(1);
                        start_iter = match_end2;
                    }
                    else
                    {
                        // if no end found,
                        // hi-light to the end,
                        // to let the user know
                        // the ending asterisk slash is missing
                        ApplyTag(
                            freecomment_tag,
                            normaltext_tag,
                            match_start1,
                            end_iter);
                        break;
                    }
                }
                else
                {
                    break;
                }
            }

            /* if free comments is different than last time,
             * invalidate line_last_changed - causes
             * a complete redo (instead hi-lighting just the current line -
             * do the whole buffer)
             * THIS IS JUST AN ATTEMPT FOR SPEED
             */
            //if (freecomment_count != last_freecomment_count) {
            //	line_last_changed = -1;
            //}

            /*********************************************************************
            * See if the following needs hi-lighting:
            * - Line Comments (sort of like C++ slash slash comments
            *   but uses hypen hyphen and it is based at the beginning of a line)
            * - Single-Quoted Constants ( WHERE COL1 = 'ABC' )
            * - SQL keywords (SELECT, FROM, WHERE, UPDATE, etc)
            *********************************************************************/
            //if (line != line_last_changed) {
            sqlTextBuffer.GetIterAtOffset(out start_iter, 0);
            //}
            //else {
            //	if (insert_iter.StartsLine () == true) {
            //		start_iter = insert_iter;
            //	}
            //	else {
            //		start_iter = insert_iter;
            //		start_iter.LineOffset = 0;
            //	}
            //}

            // get starting and ending iters
            // and character count of line
            char_count = sqlTextBuffer.CharCount;
            sqlTextBuffer.GetIterAtOffset(out end_iter, char_count);

            // for each line, look for:
            // line comments, constants, and keywoards
            do
            {
                iter = start_iter;
                iter.ForwardToLineEnd();
                text = sqlTextBuffer.GetText(
                    start_iter, iter, false);

                // look for line comment
                char_count = start_iter.CharsInLine;
                hyphen     = 0;
                for (i = 0; i < char_count - 1; i++)
                {
                    switch (text[i])
                    {
                    case '-':
                        if (hyphen == 1)
                        {
                            hyphen = 2;
                            // line comment found
                            i = char_count;

                            ApplyTag(
                                linecomment_tag,
                                normaltext_tag,
                                start_iter,
                                iter);
                        }
                        else
                        {
                            hyphen = 1;
                        }
                        break;

                    case ' ':
                        // continue
                        break;

                    default:
                        // this line is not line commented
                        i = char_count;                         // break out of for loop
                        break;
                    }
                }
                // if not line commented,
                // look for singled quoted constants
                // and keywords
                if (hyphen < 2)
                {
                    if (start_iter.IsEnd == true)
                    {
                        break;                         // break out of for loop
                    }
                    start_word    = -1;
                    single_quotes = 0;

                    LookForSingleQuotesAndWords(
                        ref start_iter,
                        text, char_count,
                        ref start_word,
                        ref single_quotes,
                        ref start_con,
                        ref end_con);
                }
            } while (start_iter.ForwardLine() == true);


            // POOR ATTEMPTS AT SPEED - last_freecomment_count
            // and line_last_changed
            //
            //last_freecomment_count = freecomment_count;
            //line_last_changed = line;
        }
Example #7
0
 public LoginDialog(SqlSharpGtk sqlSharpGtk)
 {
     sqlSharp = sqlSharpGtk;
     CreateGui();
 }