~ubuntu-branches/ubuntu/maverick/monodevelop/maverick

« back to all changes in this revision

Viewing changes to src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/TextEditor.cs

  • Committer: Bazaar Package Importer
  • Author(s): Jo Shields
  • Date: 2010-07-05 13:00:05 UTC
  • mfrom: (1.2.8 upstream) (1.3.9 experimental)
  • Revision ID: james.westby@ubuntu.com-20100705130005-d6hp4k5gcn1xkj8c
Tags: 2.4+dfsg-1ubuntu1
* debian/patches/remove_support_for_moonlight.patch,
  debian/patches/dont_add_moonlight_to_core_addins.patch,
  debian/control:
  + Enable support for Moonlight
* debian/rules:
  + Ensure Moonlight addin isn't shipped in main MonoDevelop package by
    mistake

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
 
29
29
using System;
30
30
using MonoDevelop.Ide.Gui.Content;
31
 
using MonoDevelop.Projects.Gui.Completion;
 
31
using MonoDevelop.Ide.CodeCompletion;
 
32
using Mono.TextEditor.Highlighting;
 
33
using System.Collections.Generic;
32
34
 
33
35
namespace MonoDevelop.Ide.Gui
34
36
{
131
133
                        remove { textBuffer.TextChanged -= value; }
132
134
                }
133
135
                
 
136
                public event EventHandler CursorPositionChanged {
 
137
                        add { textBuffer.CaretPositionSet += value; }
 
138
                        remove { textBuffer.CaretPositionSet -= value; }
 
139
                }
 
140
                
134
141
                public int CursorPosition { 
135
142
                        get { return textBuffer.CursorPosition; }
136
143
                        set { textBuffer.CursorPosition = value; }
329
336
                
330
337
                public int SearchChar (int startPos, char searchChar)
331
338
                {
332
 
                        bool isInString = false, isInChar = false;
 
339
                        bool isInString = false, isInChar = false, isVerbatimString = false;
333
340
                        bool isInLineComment  = false, isInBlockComment = false;
334
341
                        
335
342
                        for (int pos = startPos; pos < TextLength; pos++) {
338
345
                                        case '\r':
339
346
                                        case '\n':
340
347
                                                isInLineComment = false;
 
348
                                                if (!isVerbatimString)
 
349
                                                        isInString = false;
341
350
                                                break;
342
351
                                        case '/':
343
352
                                                if (isInBlockComment) {
351
360
                                                                isInBlockComment = true;
352
361
                                                }
353
362
                                                break;
 
363
                                        case '\\':
 
364
                                                if (isInChar || (isInString && !isVerbatimString))
 
365
                                                        pos++;
 
366
                                                break;
 
367
                                        case '@':
 
368
                                                if (!(isInString || isInChar || isInLineComment || isInBlockComment) && pos + 1 < TextLength && GetCharAt (pos + 1) == '"') {
 
369
                                                        isInString = true;
 
370
                                                        isVerbatimString = true;
 
371
                                                        pos++;
 
372
                                                }
 
373
                                                break;
354
374
                                        case '"':
355
 
                                                if (!(isInChar || isInLineComment || isInBlockComment)) 
356
 
                                                        isInString = !isInString;
 
375
                                                if (!(isInChar || isInLineComment || isInBlockComment)) {
 
376
                                                        if (isInString && isVerbatimString && pos + 1 < TextLength && GetCharAt (pos + 1) == '"') {
 
377
                                                                pos++;
 
378
                                                        } else {
 
379
                                                                isInString = !isInString;
 
380
                                                                isVerbatimString = false;
 
381
                                                        }
 
382
                                                }
357
383
                                                break;
358
384
                                        case '\'':
359
385
                                                if (!(isInString || isInLineComment || isInBlockComment)) 
369
395
                        }
370
396
                        return -1;
371
397
                }
 
398
                
 
399
                public static string[] GetCommentTags (string fileName)
 
400
                {
 
401
                        //Document doc = IdeApp.Workbench.ActiveDocument;
 
402
                        string loadedMimeType = DesktopService.GetMimeTypeForUri (fileName);
 
403
                        
 
404
                        SyntaxMode mode = null;
 
405
                        foreach (string mt in DesktopService.GetMimeTypeInheritanceChain (loadedMimeType)) {
 
406
                                mode = SyntaxModeService.GetSyntaxMode (mt);
 
407
                                if (mode != null)
 
408
                                        break;
 
409
                        }
 
410
                        
 
411
                        if (mode == null)
 
412
                                return null;
 
413
                        
 
414
                        List<string> ctags;
 
415
                        if (mode.Properties.TryGetValue ("LineComment", out ctags) && ctags.Count > 0) {
 
416
                                return new string [] { ctags [0] };
 
417
                        }
 
418
                        List<string> tags = new List<string> ();
 
419
                        if (mode.Properties.TryGetValue ("BlockCommentStart", out ctags))
 
420
                                tags.Add (ctags [0]);
 
421
                        if (mode.Properties.TryGetValue ("BlockCommentEnd", out ctags))
 
422
                                tags.Add (ctags [0]);
 
423
                        if (tags.Count == 2)
 
424
                                return tags.ToArray ();
 
425
                        else
 
426
                                return null;
 
427
                }
 
428
                
372
429
                /*
373
430
                public void GotoMatchingBrace ()
374
431
                {