Open file buffers through command arguments

This commit is contained in:
2025-06-03 17:21:14 +03:00
parent 6b5e6e8996
commit 2f7f483563
2 changed files with 26 additions and 6 deletions
+23 -1
View File
@@ -2,14 +2,36 @@ package main
import (
"log"
"os"
)
func main() {
window, err := CreateWindow(nil)
window, err := CreateWindow()
if err != nil {
log.Fatalf("Failed to create window: %v", err)
}
var initialBuffer *Buffer = nil
if len(os.Args) > 0 {
for _, file := range os.Args[1:] {
b, err := CreateFileBuffer(file)
if err != nil {
PrintMessage(window, "Could not open file: "+file)
continue
}
Buffers[b.Id] = b
if initialBuffer == nil {
initialBuffer = b
}
}
}
if initialBuffer != nil {
delete(Buffers, window.textArea.CurrentBuffer.Id)
window.textArea.CurrentBuffer = initialBuffer
}
for window.screen != nil {
window.Draw()
}