Document.lineAtScope

Returns the line text at the given position. The memory content may be modified by the setContent method by other code in the same context or in a different context.

The overload taking in a position just calls the overload taking a line with the line being the position's line.

Contains the line terminator, if it exists.

  1. auto lineAtScope(Position position)
  2. auto lineAtScope(uint line)
    struct Document
    scope const inout
    lineAtScope
    (
    uint line
    )

Examples

		void assertEqual(A, B)(A a, B b)
		{
			import std.conv : to;

			assert(a == b, a.to!string ~ " is not equal to " ~ b.to!string);
		}

		Document doc;
		doc.setContent(`abc
hellö world
how åre
you?`);
		assertEqual(doc.lineAt(Position(0, 0)), "abc\n");
		assertEqual(doc.lineAt(Position(0, 100)), "abc\n");
		assertEqual(doc.lineAt(Position(1, 3)), "hellö world\n");
		assertEqual(doc.lineAt(Position(2, 0)), "how åre\n");
		assertEqual(doc.lineAt(Position(3, 0)), "you?");
		assertEqual(doc.lineAt(Position(3, 8)), "you?");
		assertEqual(doc.lineAt(Position(4, 0)), "");
	

See Also

lineAt to get the same content, but with duplicated memory, so it can be stored for later use.

Meta