Skip to content

Commit

Permalink
ted: Un-invert the status bar at the bottom, and cache file's disk ID
Browse files Browse the repository at this point in the history
  • Loading branch information
ry755 committed May 26, 2024
1 parent 155bf3d commit fd4a066
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions applications/ted/TEd.okm
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ MODULE TEd;
cursorShowing: SHORT;
insertMode: CHAR;
fileStruct: ARRAY FILE_STRUCT_SIZE OF CHAR;
fileDiskId: CHAR;

PROCEDURE Main();
VAR charBuffer: CHAR;
Expand Down Expand Up @@ -53,7 +54,8 @@ MODULE TEd;
DrawStatusBar();

IF arg0Ptr THEN
OpenFile(arg0Ptr);
fileDiskId := get_current_disk_id();
OpenFile(arg0Ptr, fileDiskId);
END;

RefreshScreen();
Expand Down Expand Up @@ -88,7 +90,7 @@ MODULE TEd;
RefreshScreen();
ELSIF charBuffer = 111 THEN
(* 'o' pressed, save the file *)
SaveFile(arg0Ptr);
SaveFile(arg0Ptr, fileDiskId);
RefreshScreen();
END;
END;
Expand Down Expand Up @@ -226,7 +228,7 @@ MODULE TEd;
VAR i: INT;
BEGIN
PrintChar(SET_COLOR);
PrintChar(005H);
PrintChar(050H);
PrintChar(0);
PrintChar(MOVE_CURSOR);
PrintChar(0);
Expand Down Expand Up @@ -279,7 +281,7 @@ MODULE TEd;
END;
END;

PROCEDURE OpenFile(fileName: POINTER TO CHAR;);
PROCEDURE OpenFile(fileName: POINTER TO CHAR; diskId: CHAR;);
VAR size: INT;
charBuffer: CHAR;
buffer: ARRAY 128 OF CHAR;
Expand All @@ -289,7 +291,7 @@ MODULE TEd;
RETURN();
END;

IF open(fileName, get_current_disk_id(), PTROF(fileStruct)) = 0 THEN
IF open(fileName, diskId, PTROF(fileStruct)) = 0 THEN
RETURN();
END;

Expand All @@ -312,7 +314,7 @@ MODULE TEd;
END;
END;

PROCEDURE SaveFile(fileName: POINTER TO CHAR;);
PROCEDURE SaveFile(fileName: POINTER TO CHAR; diskId: CHAR;);
VAR i: INT;
length: INT;
buffer: POINTER TO CHAR;
Expand All @@ -323,7 +325,7 @@ MODULE TEd;

buffer := RowsToString(PTROF(length));

IF create(fileName, get_current_disk_id(), PTROF(fileStruct), length) = 0 THEN
IF create(fileName, diskId, PTROF(fileStruct), length) = 0 THEN
PrintChar(SET_COLOR);
PrintChar(005H);
PrintChar(0);
Expand All @@ -339,6 +341,7 @@ MODULE TEd;
PrintChar(0);
PrintChar(24);
Print("failed to save");
free_memory(buffer);
RETURN();
END;

Expand Down

0 comments on commit fd4a066

Please sign in to comment.