Editors show a status line - the file name, a modified marker, and where you are. Today you render one, a single width-filling line that reports the editor's state at a glance.
Render a status line showing the file name, a modified marker when dirty, and the cursor's line position, padded to the given width.
The status line is the strip of information every editor keeps at the bottom of
the screen: what file you are in, whether it has unsaved changes, and where the
cursor sits. You build it as a single string of exactly the screen width, with the
left side - the file name, plus a [modified] marker when the dirty flag is set
The layout trick is the padding: fill the gap between the left and right sides
with enough spaces to push the position flush against the right edge, so the whole
line lands on the exact width. That is why the dirty and clean versions have
different amounts of space but the same total length - the [modified] text eats
into the padding, not the width. This reuses the dirty flag directly and gives the
viewport its finishing touch: a frame of text, a placed cursor, and a status line
that tells you where you are.
func (e *Editor) StatusLine(name string, cols int) string {left := nameif e.Dirty { left += " [modified]" }right := fmt.Sprintf("%d/%d", e.Row+1, e.Buf.LineCount())pad := cols - len(left) - len(right) // spaces between the two sidesreturn left + strings.Repeat(" ", pad) + right}