From 02477d3f165c6aefea2aeb1f5fc81e5617cf31cf Mon Sep 17 00:00:00 2001 From: mooinglemur Date: Mon, 11 Mar 2024 12:41:19 -0700 Subject: [PATCH] [X16EDIT] sync from upstream (#296) --- x16-edit/.git-commit | 2 +- x16-edit/file.inc | 27 +++++++++++++++++++++++++-- x16-edit/help.txt | 8 ++++---- x16-edit/help_short.txt | 2 +- 4 files changed, 31 insertions(+), 8 deletions(-) diff --git a/x16-edit/.git-commit b/x16-edit/.git-commit index e6490f5b..610d11c5 100644 --- a/x16-edit/.git-commit +++ b/x16-edit/.git-commit @@ -1 +1 @@ -ba1b4ae4455429fb64debe536dcb07cfc9fbe60f +7ebc2ecedd1370131c78cc7291540c5f73a3b7ee diff --git a/x16-edit/file.inc b/x16-edit/file.inc index 0bedd863..8203664e 100644 --- a/x16-edit/file.inc +++ b/x16-edit/file.inc @@ -274,7 +274,30 @@ io_err: bra close_file eof: - jsr writebuf + ;Check if file ends with newline + ldx index + beq :+ ;Empty buffer, add final newline + lda file_buf-1,x + cmp #LF ;Last char is LF, no need to add final newline + beq :+++ + cmp #CR ;Last char is CR, no need to add final newline + beq :+++ + + ;Write buffer to file, and add final newline +: jsr writebuf + + ldx file_linebreak_encoding + beq :+ ;newline=LF + lda #CR + jsr KERNAL_CHROUT + cpx #1 ;newline=CR + beq close_file +: lda #LF + jsr KERNAL_CHROUT + bra close_file + + ;File ends with newline, just write buffer to file +: jsr writebuf close_file: lda #1 @@ -1023,4 +1046,4 @@ file_ioerr_10: .segment "RAMCODE3" file_buf: .res 256 -.CODE \ No newline at end of file +.CODE diff --git a/x16-edit/help.txt b/x16-edit/help.txt index 1f728956..35ce0391 100644 --- a/x16-edit/help.txt +++ b/x16-edit/help.txt @@ -25,14 +25,14 @@ available via a function key. ^D Set current device number ^T Set text color (default white) ^B Set background color (default blue) -^M Show memory usage (1 bank=251 bytes of text) +^M Show memory usage (1 block=251 bytes of text) ^SPACE Insert non-breaking space ^1..9 Set tab width -^ENTER Set line break encoding +^RETURN Set line break encoding ^F Programming toolbox (ROM only) -X16 Edit, Copyright 2020-2023, Stefan Jakobsson. +X16 Edit, Copyright 2020-2024, Stefan Jakobsson. Released under the BSD 2-Clause license, available in -the enclosed "license" file. \ No newline at end of file +the enclosed "license" file. diff --git a/x16-edit/help_short.txt b/x16-edit/help_short.txt index 4f4d08f8..585011c7 100644 --- a/x16-edit/help_short.txt +++ b/x16-edit/help_short.txt @@ -11,7 +11,7 @@ N =New B=Backgr color K =Cut M=Mem free DEL =Del Ln C=Copy 1..9=Tab w U=Uncut/paste -ENT =Ln brk enc +RET =Ln brk enc X16 Edit, (c) Stefan Jakobsson, released under BSD 2-Clause