diff --git a/src/common/editor/editor.ts b/src/common/editor/editor.ts index 0eabf8d..9299fd6 100644 --- a/src/common/editor/editor.ts +++ b/src/common/editor/editor.ts @@ -57,10 +57,23 @@ export class Editor { } private drawRows(): void { + this.drawPlaceholderRows(); + } + + private drawPlaceholderRows(): void { for (let y = 0; y < this.#screenRows; y++) { - if (y === this.#screenRows / 3) { + if (y === Math.trunc(this.#screenRows / 2)) { const message = `Kilo editor -- version ${VERSION}`; - this.#buffer.append(truncate(message, this.#screenCols)); + const messageLen = (message.length > this.#screenCols) ? this.#screenCols : message.length; + let padding = Math.trunc((this.#screenCols - messageLen) / 2); + if (padding > 0) { + this.#buffer.append('~'); + padding -= 1; + + this.#buffer.append(' '.repeat(padding)); + } + + this.#buffer.append(truncate(message, messageLen)); } else { this.#buffer.append('~'); }