Set new file default content to a single byte full of zeros so that the cursor doesn't leave replace mode.

This commit is contained in:
The Wobbler 2024-12-09 18:11:46 +01:00
parent b2afa06ee1
commit b1b442b23a

View file

@ -1,7 +1,7 @@
#!/usr/bin/python3 #!/usr/bin/python3
import os.path import os.path
from PyQt6.QtWidgets import QFileDialog, QTabWidget from PyQt6.QtWidgets import QFileDialog
from editor import BitEditor from editor import BitEditor
MAX_FILE_SIZE = 262144 # 2^18 MAX_FILE_SIZE = 262144 # 2^18
@ -22,7 +22,10 @@ class FileActions:
if dialog.exec(): if dialog.exec():
self.open_multiple_files(dialog.selectedFiles()) 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( file_path, extension = QFileDialog.getSaveFileName(
caption="New File", caption="New File",
directory=self.app.utils.home_path, directory=self.app.utils.home_path,