From b1b442b23a432dfe4b3063d9e693f08fd9115697 Mon Sep 17 00:00:00 2001 From: EKNr1 Date: Mon, 9 Dec 2024 18:11:46 +0100 Subject: [PATCH] Set new file default content to a single byte full of zeros so that the cursor doesn't leave replace mode. --- file.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/file.py b/file.py index 60c89e1..073db5a 100644 --- a/file.py +++ b/file.py @@ -1,7 +1,7 @@ #!/usr/bin/python3 import os.path -from PyQt6.QtWidgets import QFileDialog, QTabWidget +from PyQt6.QtWidgets import QFileDialog from editor import BitEditor MAX_FILE_SIZE = 262144 # 2^18 @@ -22,7 +22,10 @@ class FileActions: if dialog.exec(): self.open_multiple_files(dialog.selectedFiles()) - def create_file(self, content: bin=b""): + def create_file(self, content: bytes=(0).to_bytes(1)): + # open a dialog where the user can choose a new filepath and create an empty file at that path + # bytes=(0).to_bytes(1) creates a byte with only zeros in it + file_path, extension = QFileDialog.getSaveFileName( caption="New File", directory=self.app.utils.home_path,