public VisualLineTextSource(VisualLine visualLine)
		{
		}
Esempio n. 2
0
		public void ValidateVisualColumn(VisualLine visualLine)
		{
			if (visualLine == null) {
				throw new ArgumentNullException("visualLine");
			}			
			
			int caretOffset = textView.Document.GetOffset(position);
			int firstOffset = visualLine.FirstDocumentLine.Offset;
			if (position.VisualColumn < 0) {
				position.VisualColumn = visualLine.GetVisualColumn(caretOffset - firstOffset);
			} else {
				int relativeOffset = visualLine.GetRelativeOffset(position.VisualColumn);
				relativeOffset += firstOffset;
				if (relativeOffset != caretOffset) {
					position.VisualColumn = visualLine.GetVisualColumn(caretOffset - firstOffset);
				} else {
					if (position.VisualColumn > visualLine.VisualLength) {
						position.VisualColumn = visualLine.VisualLength;
					}
				}
			}
			
			int newVisualColumn = visualLine.GetNextCaretPosition(position.VisualColumn - 1, false, CaretPositioningMode.Normal);
			if (newVisualColumn < 0) {
				newVisualColumn = visualLine.GetNextCaretPosition(position.VisualColumn + 1, true, CaretPositioningMode.Normal);
			}
			if (newVisualColumn >= 0 && newVisualColumn != position.VisualColumn) {
				int newOffset = visualLine.GetRelativeOffset(newVisualColumn) + firstOffset;
				Position = new TextViewPosition(textView.Document.GetLocation(newOffset), newVisualColumn);
			}
		}
Esempio n. 3
0
		Rect CalcCaretRectangle(VisualLine visualLine)
		{
			ValidateVisualColumn(visualLine);
			
			TextLine textLine = visualLine.GetTextLine(position.VisualColumn);
			double xPos = textLine.GetDistanceFromCharacterHit(new CharacterHit(position.VisualColumn, 0));
			double top = visualLine.GetTextLineVisualTop(textLine);
			double bottom = top + textLine.Height;
			double fontSize = (double)textArea.GetValue(TextBlock.FontSizeProperty);
			
			return new Rect(xPos, bottom - fontSize, SystemParameters.CaretWidth, fontSize);
		}
Esempio n. 4
0
		public VisualLineText(VisualLine parentVisualLine, int length) : base(length, length)
		{
		}
Esempio n. 5
0
		public void Redraw(VisualLine line, DispatcherPriority priority)
		{ 
			//TODO: TextView.Redraw()
			throw new NotImplementedException();
		}
Esempio n. 6
0
		VisualLine BuildVisualLine(DocumentLine documentLine, TextRunProperties textRunProperties, 
			TextParagraphProperties paragraphProperties, VisualLineElementGenerator[] generators, 
			IVisualLineTransformer[] transformers, Size availableSize)
		{
			if (heightTree.GetIsCollapsed(documentLine)) {
				throw new InvalidOperationException();
			}
			
			var visualLine = new VisualLine(documentLine);
			var textSource = new VisualLineTextSource(visualLine) {
				Document = this.Document,
				GlobalTextRunProperties = textRunProperties,
				TextView = this
			};
			visualLine.ConstructVisualElements(textSource, generators);
			visualLine.RunTransformers(textSource, transformers);
			
			int offset = 0;
			TextLineBreak lineBreak = null;
			var textLines = new List<TextLine>();
			while (offset <= visualLine.VisualLength) {
				TextLine tl = textFormatter.FormatLine(textSource, offset, 
					              availableSize.Width, paragraphProperties, lineBreak);
				textLines.Add(tl);
				offset += tl.Length;
				lineBreak = tl.GetTextLineBreak();
			}
			visualLine.SetTextLines(textLines);
			heightTree.SetHeight(visualLine.FirstDocumentLine, visualLine.Height);
			
			return visualLine;
		}