Example #1
0
        public string GetTextBeforeOffset(int offset, Atk.TextBoundary boundary_type, out int start_offset, out int end_offset)
        {
            IntPtr raw_ret = atk_text_get_text_before_offset(Handle, offset, (int)boundary_type, out start_offset, out end_offset);
            string ret     = GLib.Marshaller.PtrToStringGFree(raw_ret);

            return(ret);
        }
Example #2
0
        public string GetTextAtOffset(int offset, Atk.TextBoundary boundaryType, out int startOffset, out int endOffset)
        {
            string ret =
                textExpert.GetTextAtOffset(offset, boundaryType, out startOffset, out endOffset);

            return(ret);
        }
Example #3
0
        public string GetTextAtOffset(int offset, Atk.TextBoundary boundary_type, out int start_offset, out int end_offset)
        {
            Console.WriteLine("ATKTEXT: GetTextAtOffset " + offset);
            switch (boundary_type)
            {
            case Atk.TextBoundary.Char:
                Console.WriteLine("char");
                break;

            case Atk.TextBoundary.LineEnd:
                Console.WriteLine("le");
                break;

            case Atk.TextBoundary.LineStart:
                Console.WriteLine("ls");
                break;

            case Atk.TextBoundary.SentenceEnd:
                Console.WriteLine("se");
                break;

            case Atk.TextBoundary.SentenceStart:
                Console.WriteLine("ss");
                break;

            case Atk.TextBoundary.WordEnd:
                Console.WriteLine("we");
                break;

            case Atk.TextBoundary.WordStart:
                Console.WriteLine("ws");
                break;

            default:
                Console.WriteLine("noooo:" + boundary_type.value__);
                start_offset = offset;
                end_offset   = Name.Length;

                //expected NRE, still to determine why:
//Exception in Gtk# callback delegate
//  Note: Applications can use GLib.ExceptionManager.UnhandledException to handle the exception.
//System.NullReferenceException: Object reference not set to an instance of an object
//  at atkSharpHelloWorld.HelloButton.GetTextAtOffset (Int32 offset, TextBoundary boundary_type, System.Int32& start_offset, System.Int32& end_offset) [0x00000]
//  at Atk.TextAdapter.GetTextAtOffsetCallback (IntPtr text, Int32 offset, Int32 boundary_type, System.Int32& start_offset, System.Int32& end_offset) [0x00000]
//   at GLib.ExceptionManager.RaiseUnhandledException(System.Exception e, Boolean is_terminal)
//   at Atk.TextAdapter.GetTextAtOffsetCallback(IntPtr text, Int32 offset, Int32 boundary_type, Int32 ByRef start_offset, Int32 ByRef end_offset)
//   at Atk.TextAdapter.GetTextAtOffsetCallback(IntPtr , Int32 , Int32 , Int32 ByRef , Int32 ByRef )
//   at GLib.MainLoop.g_main_loop_run(IntPtr )
//   at GLib.MainLoop.g_main_loop_run(IntPtr )
//   at GLib.MainLoop.Run()
//   at atkSharpHelloWorld.MainClass.Main(System.String[] args)
                return(Name);
            }

            start_offset = 0;
            end_offset   = 0;
            Console.WriteLine("NRE?");
            return(null);
            //throw new NotImplementedException();
        }
Example #4
0
        public string GetTextBeforeOffset(int offset, Atk.TextBoundary boundaryType, out int startOffset, out int endOffset)
        {
            startOffset = 0;
            endOffset   = 0;
            try {
                switch (boundaryType)
                {
                case Atk.TextBoundary.WordEnd:
                    endOffset   = BackwardToNextSeparator(wordSeparators, offset, false);
                    startOffset = BackwardToNextSeparator(wordSeparators, endOffset, false);
                    return(ReturnTextWrtOffset(startOffset, endOffset));

                case Atk.TextBoundary.WordStart:
                    BackwardToNextSeparator(wordSeparators, offset, out endOffset, out startOffset);
                    startOffset = BackwardToNextSeparator(wordSeparators, startOffset, true);
                    return(ReturnTextWrtOffset(startOffset, endOffset));

                case Atk.TextBoundary.LineEnd:
                    endOffset   = BackwardToNextSeparator(newLineSeparators, offset, false);
                    startOffset = BackwardToNextSeparator(newLineSeparators, endOffset, false);
                    return(ReturnTextWrtOffset(startOffset, endOffset));

                case Atk.TextBoundary.LineStart:
                    BackwardToNextSeparator(newLineSeparators, offset, out endOffset, out startOffset);
                    startOffset = BackwardToNextSeparator(newLineSeparators, startOffset, true);
                    return(ReturnTextWrtOffset(startOffset, endOffset));

                case Atk.TextBoundary.Char:
                    startOffset = offset - 1;
                    endOffset   = offset;
                    return(ReturnTextWrtOffset(startOffset));

                case Atk.TextBoundary.SentenceEnd:
                    endOffset   = BackwardToNextSeparator(sentenceSeparators, offset, false);
                    startOffset = BackwardToNextSeparator(sentenceSeparators, endOffset, false);
                    return(ReturnTextWrtOffset(startOffset, endOffset));

                case Atk.TextBoundary.SentenceStart:
                    BackwardToNextSeparator(sentenceSeparators, offset, out endOffset, out startOffset);
                    startOffset = BackwardToNextSeparator(sentenceSeparators, startOffset, true);
                    return(ReturnTextWrtOffset(startOffset, endOffset));

                default:
                    throw GetNotSupportedBoundary(boundaryType);
                }
            } catch (System.IndexOutOfRangeException) {
                return(String.Empty);
            } finally {
                selectionStartOffset = startOffset;
                selectionEndOffset   = endOffset;
            }
        }
Example #5
0
 public string GetTextBeforeOffset(int offset, Atk.TextBoundary boundaryType, out int startOffset, out int endOffset)
 {
     return(textExpert.GetTextBeforeOffset(offset, boundaryType, out startOffset, out endOffset));
 }
Example #6
0
 public string GetTextAtOffset(int offset, Atk.TextBoundary boundaryType, out int startOffset, out int endOffset)
 {
     return(text_helper.GetTextAtOffset(offset, boundaryType, out startOffset, out endOffset));
 }
Example #7
0
 public string GetTextAfterOffset(int offset, Atk.TextBoundary boundary_type, out int start_offset, out int end_offset)
 {
     Console.WriteLine("ATKTEXT: GetTextAfterOffset");
     throw new NotImplementedException();
 }
Example #8
0
 private NotSupportedException GetNotSupportedBoundary(Atk.TextBoundary bType)
 {
     return(new NotSupportedException(
                String.Format("The value {0} is not supported as a Atk.TextBoundary type.",
                              bType)));
 }
Example #9
0
        public string GetTextAtOffset(int offset, Atk.TextBoundary boundaryType, out int startOffset, out int endOffset)
        {
            string text = Text;

            startOffset = 0;
            endOffset   = 0;
            try {
                switch (boundaryType)
                {
                case Atk.TextBoundary.WordEnd:
                    startOffset = BackwardToNextSeparator(wordSeparators, offset, false);
                    endOffset   = ForwardToNextSeparator(wordSeparators, offset, true);
                    return(ReturnTextWrtOffset(startOffset, endOffset));

                case Atk.TextBoundary.WordStart:
                    startOffset = BackwardToNextSeparator(wordSeparators, offset, true);
                    endOffset   = ForwardToNextSeparator(wordSeparators, offset, false);
                    return(ReturnTextWrtOffset(startOffset, endOffset));

                case Atk.TextBoundary.LineEnd:
                    startOffset = BackwardToNextSeparator(newLineSeparators, offset, false);
                    endOffset   = ForwardToNextSeparator(newLineSeparators, offset, true);
                    return(ReturnTextWrtOffset(startOffset, endOffset));

                case Atk.TextBoundary.LineStart:
                    startOffset = BackwardToNextSeparator(newLineSeparators, offset, true);
                    endOffset   = ForwardToNextSeparator(newLineSeparators, offset, false);
                    return(ReturnTextWrtOffset(startOffset, endOffset));

                case Atk.TextBoundary.SentenceEnd:
                    startOffset = BackwardToNextSeparator(sentenceSeparators, offset, false);
                    endOffset   = ForwardToNextSeparator(sentenceSeparators, offset, true);

                    int testEndOffset, nextEndOffset;
                    ForwardToNextSeparator(softSentenceSeparators, startOffset, out testEndOffset, out nextEndOffset);
                    if (testEndOffset == endOffset)
                    {
                        endOffset = nextEndOffset;
                    }

                    return(ReturnTextWrtOffset(startOffset, endOffset));

                case Atk.TextBoundary.SentenceStart:
                    startOffset = BackwardToNextSeparator(sentenceSeparators, offset, true);
                    endOffset   = ForwardToNextSeparator(sentenceSeparators, offset, false);
                    return(ReturnTextWrtOffset(startOffset, endOffset));

                case Atk.TextBoundary.Char:
                    startOffset = offset;
                    if (startOffset < 0)
                    {
                        startOffset = text.Length;
                        endOffset   = text.Length;
                    }
                    else if (offset >= text.Length)
                    {
                        endOffset = offset;
                    }
                    else
                    {
                        endOffset = offset + 1;
                    }
                    return(ReturnTextWrtOffset(offset));

                default:
                    throw GetNotSupportedBoundary(boundaryType);
                }
            } catch (System.IndexOutOfRangeException) {
                return(String.Empty);
            } finally {
                selectionStartOffset = startOffset;
                selectionEndOffset   = endOffset;
            }
        }