~ubuntu-branches/ubuntu/feisty/monodevelop/feisty

« back to all changes in this revision

Viewing changes to Unused/ICSharpCode.TextEditor/src/Actions/HomeEndActions.cs

  • Committer: Bazaar Package Importer
  • Author(s): Sebastian Dröge
  • Date: 2006-08-18 00:51:23 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20060818005123-5iit07y0j7wjg55f
Tags: 0.11+svn20060818-0ubuntu1
* New SVN snapshot
  + Works with Gtk# 2.9.0
* debian/control:
  + Updated Build-Depends
* debian/patches/use_nunit2.2.dpatch,
  debian/patches/use_real_libs.dpatch:
  + Updated
* debian/patches/versioncontrol_buildfix.dpatch:
  + Fix build failure in the version control addin

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// <file>
 
2
//     <copyright see="prj:///doc/copyright.txt"/>
 
3
//     <license see="prj:///doc/license.txt"/>
 
4
//     <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
 
5
//     <version value="$version"/>
 
6
// </file>
 
7
 
 
8
using System;
 
9
using System.Drawing;
 
10
 
 
11
using MonoDevelop.TextEditor.Document;
 
12
 
 
13
namespace MonoDevelop.TextEditor.Actions 
 
14
{
 
15
        public class Home : AbstractEditAction
 
16
        {
 
17
                public override void Execute(TextArea textArea)
 
18
                {
 
19
                        LineSegment curLine = textArea.Document.GetLineSegment(textArea.Caret.Line);
 
20
                        
 
21
                        if (TextUtilities.IsEmptyLine(textArea.Document, curLine)) {
 
22
                                if (textArea.Caret.Column != 0) {
 
23
                                        textArea.Caret.Column = 0;
 
24
                                } else  {
 
25
                                        textArea.Caret.Column = curLine.Length;
 
26
                                }
 
27
                        } else {
 
28
                                int firstCharOffset = TextUtilities.GetFirstNonWSChar(textArea.Document, curLine.Offset);
 
29
                                int firstCharColumn = firstCharOffset - curLine.Offset;
 
30
                                
 
31
                                if (textArea.Caret.Column == firstCharColumn) {
 
32
                                        textArea.Caret.Column  = 0;
 
33
                                } else {
 
34
                                        textArea.Caret.Column  = firstCharColumn;
 
35
                                }
 
36
                        }
 
37
                        
 
38
                        textArea.SetDesiredColumn();
 
39
                }
 
40
        }
 
41
        
 
42
        public class End : AbstractEditAction
 
43
        {
 
44
                public override void Execute(TextArea textArea)
 
45
                {
 
46
                        LineSegment curLine = textArea.Document.GetLineSegment(textArea.Caret.Line);
 
47
                        if (textArea.Caret.Column != curLine.Length) {
 
48
                                textArea.Caret.Column = curLine.Length;
 
49
                                textArea.SetDesiredColumn();
 
50
                        }
 
51
                }
 
52
        }
 
53
        
 
54
        
 
55
        public class MoveToStart : AbstractEditAction
 
56
        {
 
57
                public override void Execute(TextArea textArea)
 
58
                {
 
59
                        if (textArea.Caret.Line != 0 || textArea.Caret.Column != 0) {
 
60
                                textArea.Caret.Position = new Point(0, 0);
 
61
                                textArea.SetDesiredColumn();
 
62
                        }
 
63
                }
 
64
        }
 
65
        
 
66
        
 
67
        public class MoveToEnd : AbstractEditAction
 
68
        {
 
69
                public override void Execute(TextArea textArea)
 
70
                {
 
71
                        Point endPos = textArea.Document.OffsetToPosition(textArea.Document.TextLength);
 
72
                        if (textArea.Caret.Position != endPos) {
 
73
                                textArea.Caret.Position = endPos;
 
74
                                textArea.SetDesiredColumn();
 
75
                        }
 
76
                }
 
77
        }
 
78
}