Helper class with caret-related methods.
		/// <summary>
		/// Creates a new TextArea instance.
		/// </summary>
		protected TextArea(TextView textView)
		{
			if (textView == null)
				throw new ArgumentNullException("textView");
			this.textView = textView;
			this.Options = textView.Options;
			textView.SetBinding(TextView.DocumentProperty, new Binding(DocumentProperty.Name) { Source = this });
			textView.SetBinding(TextView.OptionsProperty, new Binding(OptionsProperty.Name) { Source = this });
			
			textView.Services.AddService(typeof(TextArea), this);
			
			leftMargins.Add(new LineNumberMargin { TextView = textView, TextArea = this } );
			leftMargins.Add(new Line {
			                	X1 = 0, Y1 = 0, X2 = 0, Y2 = 1,
			                	StrokeDashArray = { 0, 2 },
			                	Stretch = Stretch.Fill,
			                	Stroke = Brushes.Gray,
			                	StrokeThickness = 1,
			                	StrokeDashCap = PenLineCap.Round,
			                	Margin = new Thickness(2, 0, 2, 0)
			                });
			
			textView.LineTransformers.Add(new SelectionColorizer(this));
			textView.InsertLayer(new SelectionLayer(this), KnownLayer.Selection, LayerInsertionPosition.Replace);
			
			caret = new Caret(this);
			caret.PositionChanged += (sender, e) => RequestSelectionValidation();
			
			this.DefaultInputHandler = new TextAreaDefaultInputHandler(this);
			this.ActiveInputHandler = this.DefaultInputHandler;
		}
Beispiel #2
0
		/// <summary>
		/// Creates a new TextArea instance.
		/// </summary>
		protected TextArea(TextView textView)
		{
			if (textView == null)
				throw new ArgumentNullException("textView");
			this.textView = textView;
			this.Options = textView.Options;
			
			selection = emptySelection = new EmptySelection(this);
			
			textView.Services.AddService(typeof(TextArea), this);
			
			textView.LineTransformers.Add(new SelectionColorizer(this));
			textView.InsertLayer(new SelectionLayer(this), KnownLayer.Selection, LayerInsertionPosition.Replace);
			
			caret = new Caret(this);
			caret.PositionChanged += (sender, e) => RequestSelectionValidation();
			caret.PositionChanged += CaretPositionChanged;
			AttachTypingEvents();
			ime = new ImeSupport(this);
			
			leftMargins.CollectionChanged += leftMargins_CollectionChanged;
			
			this.DefaultInputHandler = new TextAreaDefaultInputHandler(this);
			this.ActiveInputHandler = this.DefaultInputHandler;
		}
		void AttachEvents()
		{
			document = this.TextArea.Document;
			caret = this.TextArea.Caret;
			if (document != null)
				document.Changed += document_Changed;
			if (caret != null)
				caret.PositionChanged += caret_PositionChanged;
			this.Closed += OnClosed;
		}
 CompletionData[] EmptySuggestion(Caret caret)
 {
   if (caret.Column == 1)
   {
     return new[]
              {new CompletionData {Text = "specification", DescriptionText = "Define a specification for a specific module", AddSpaceAfterInsertion = true}}
       ;
   }
   return new[]
            {
              new CompletionData {Text = "requires", DescriptionText = "Requires a particular module", AddSpaceAfterInsertion = true},
              new CompletionData {Text = "same_machine_as", DescriptionText = "Needs to be on the same machine as the specified module", AddSpaceAfterInsertion = true},
              new CompletionData {Text = "users_per_machine", DescriptionText = "Can support the specified amount of users", AddSpaceAfterInsertion = true},
              new CompletionData {Text = "min_cpu_count", DescriptionText = "Minimum number of cpus required", AddSpaceAfterInsertion = true},
                  new CompletionData {Text = "min_memory", DescriptionText = "Minimum ammount of memory required", AddSpaceAfterInsertion = true}
            };
 }
Beispiel #5
0
        /// <summary>
        /// Creates a new TextArea instance.
        /// </summary>
        protected TextArea(TextView textView)
        {
            if (textView == null)
                throw new ArgumentNullException(nameof(textView));
            this.textView = textView;
            Options = textView.Options;

            selection = emptySelection = new EmptySelection(this);

            textView.Services.AddService(typeof(TextArea), this);
            textView.InsertLayer(new SelectionLayer(this), KnownLayer.Selection, LayerInsertionPosition.Replace);

            caret = new Caret(this);
            caret.PositionChanged += (sender, e) => RequestSelectionValidation();

            leftMargins.CollectionChanged += leftMargins_CollectionChanged;

            DefaultInputHandler = new TextAreaDefaultInputHandler(this);
            ActiveInputHandler = DefaultInputHandler;
        }
        /// <summary>
        /// Creates a new TextArea instance.
        /// </summary>
        protected TextArea(TextView textView)
        {
            if (textView == null)
            {
                throw new ArgumentNullException("textView");
            }
            this.textView = textView;
            this.Options  = textView.Options;

            selection = emptySelection = new EmptySelection(this);

            textView.Services.AddService(typeof(TextArea), this);

            textView.LineTransformers.Add(new SelectionColorizer(this));
            textView.InsertLayer(new SelectionLayer(this), KnownLayer.Selection, LayerInsertionPosition.Replace);

            caret = new Caret(this);
            caret.PositionChanged += (sender, e) => RequestSelectionValidation();

            leftMargins.CollectionChanged += leftMargins_CollectionChanged;

            this.DefaultInputHandler = new TextAreaDefaultInputHandler(this);
            this.ActiveInputHandler  = this.DefaultInputHandler;
        }
			public CaretAdapter(Caret caret)
			{
				Debug.Assert(caret != null);
				this.caret = caret;
			}
			public CaretAdapter(Caret caret)
			{
				this.caret = caret;
			}
        private void AttachEvents()
        {
            caret = this.TextArea.Caret;

            if (caret != null)
                caret.PositionChanged += caret_PositionChanged;
        }
Beispiel #10
0
        /// <summary>
        /// Creates a new TextArea instance.
        /// </summary>
        protected TextArea(TextView textView)
        {
            if (textView == null)
                throw new ArgumentNullException("textView");
            this.textView = textView;
            this.Options = textView.Options;
            textView.SetBinding(TextView.DocumentProperty, new Binding(DocumentProperty.Name) { Source = this });
            textView.SetBinding(TextView.OptionsProperty, new Binding(OptionsProperty.Name) { Source = this });

            textView.Services.AddService(typeof(TextArea), this);

            textView.LineTransformers.Add(new SelectionColorizer(this));
            textView.InsertLayer(new SelectionLayer(this), KnownLayer.Selection, LayerInsertionPosition.Replace);

            caret = new Caret(this);
            caret.PositionChanged += (sender, e) => RequestSelectionValidation();

            leftMargins.CollectionChanged += leftMargins_CollectionChanged;

            this.DefaultInputHandler = new TextAreaDefaultInputHandler(this);
            this.ActiveInputHandler = this.DefaultInputHandler;
            this.FindOnPageBrush = new SolidColorBrush(Color.FromArgb(0xAF, 0xFF, 0x42, 0x4E));
            this.FindOnPageBorder = new Pen(new SolidColorBrush(Color.FromArgb(0x9F, 0xFF, 0x42, 0x4E)), 2.0);
            this.SelectionBrush = new SolidColorBrush(Color.FromArgb(0xAF, 0x2A, 0x45, 0x79));
            this.SelectionBorder = new Pen(new SolidColorBrush(Color.FromArgb(0x9F, 0x2A, 0x45, 0x79)), 1.0);
        }
		/// <summary>
		/// Will listen to Caret.PositionChanged events and automatically expand folding sections
		/// when the caret is moved into them.
		/// </summary>
		public void ExpandFoldingsWhenCaretIsMovedIntoThem(Caret caret)
		{
			if (helper == null)
				helper = new ExpandFoldingsWhenCaretIsMovedIntoThemHelper(this);
			CaretWeakEventManager.PositionChanged.AddListener(caret, helper);
		}