Skip to content

Latest commit

 

History

16 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tiny68kIDE

Tiny68kIDE is a small classic 68k Mac editor prototype built with Retro68. It targets System 7-era Macintosh environments and currently focuses on a simple editable text buffer, line numbers, basic syntax highlighting, scrollbars, file open/save, and selectable LF/CRLF save mode.

Now back to the first couple of words in this readme. It is supposed to be small, it's supposed to be able to run on very little ram and fit even the smallest disks. If you go through the commits and actually try compiling from various commits you'll see I really tried to keep both the binary small and the memory impact small. In the last iterations I focused on the performance and made the highlighting actually optional. Slow machines like my Mac Plus really do make a difference in performance if the toggle is off.

I would welcome any improvements, additions or simply any issues or pull requests to make this even better replacement to the modern editors full of distractions.

A very important disclaimer: This was written with a great help of various LLMs as I am quite rusty in C (last time really I wrote C with confidence was more than 15 years ago). If I found a piece of code that would work I often asked the LLM to help me annotate it so I understand why or how a thing works. (and it definitely helped me with grammar and stylistic.

Building

The normal build command is:

make build

This runs build_68k.sh, which configures CMake with the Retro68 toolchain and builds into build-68k.

Useful commands:

make build
make clean

The build script defaults to:

~/Retro68-build/toolchain/m68k-apple-macos/cmake/retro68.toolchain.cmake

Override paths with:

RETRO68_PREFIX=/path/to/Retro68-build/toolchain make build
TOOLCHAIN_FILE=/path/to/retro68.toolchain.cmake make build
BUILD_DIR=/tmp/tiny68kide-build make build
JOBS=4 make build

Source Layout

src/main.c owns the classic Mac application shell:

  • Toolbox startup and shutdown
  • Main editor window, menus, event loop, and command dispatch
  • File open/save dialogs
  • Scrollbar layout and resize handling
  • Status bar drawing and the LF/CRLF toggle

src/about.c owns the About window:

  • Opens a normal closable document-style window
  • Draws the About contents
  • Tracks whether a Toolbox WindowPtr belongs to the About window

src/editor.c owns the editor core:

  • Text buffer stored in a movable Handle
  • Caret movement, blinking, insertion, deletion, and clicks
  • Text drawing, line numbers, and visible viewport state
  • Internal LF-only text storage
  • Save-length calculation and LF/CRLF conversion on copy-out

src/highlight.c owns syntax highlighting:

  • Loads resources/highlight.txt
  • Parses keyword groups
  • Draws highlighted source lines

include/editor.h and include/highlight.h are the public boundaries between these pieces.

Redraw Flow

The app follows the classic Mac pattern:

  1. Code changes state or layout.
  2. It calls InvalRect().
  3. The system later sends updateEvt.
  4. main.c handles updateEvt with BeginUpdate(), redraws, then calls EndUpdate().

For the editor window, drawEditorWindowContents() redraws:

  • Editor text and gutter
  • Status bar
  • Grow icon

Resize handling lives in resizeEditorWindow(). After SizeWindow(), it calls layoutEditorWindow() and invalidates the full editor window so the next update event repaints the new bounds.

Commands

Menu commands and Cmd-key shortcuts both go through AppCommand in src/main.c.

Current commands:

  • About
  • Open
  • Save
  • Syntax Highlighting
  • Help > Syntax Highlighting
  • Help > Opening Files and Directories
  • Toggle Line Endings
  • Quit

This keeps menu handling and keyboard shortcuts from drifting apart.

Plain Text And Highlighting

The editor starts in plain text mode for fast redraws on slower 68k Macs.

Use File > Syntax Highlighting or press Cmd-R to toggle highlighting. When enabled, Tiny68kIDE loads highlight.txt; disabling highlighting frees the loaded token table again.

Use Help > Syntax Highlighting for a short in-app explanation of the toggle and highlight.txt rule format.

Use Help > Opening Files and Directories for a short in-app explanation of File > Open, File > Open Directory, and the left browser pane.

Line Endings

The editor stores text internally with LF line endings.

When a file is opened:

  • CRLF and old Mac CR are normalized to LF internally.
  • The original line-ending style is detected where possible.

When a file is saved:

  • LF mode writes internal text directly.
  • CRLF mode expands each LF to CRLF.
  • editor_get_save_length() reports the required output buffer size before saving.

The current mode is shown in the bottom status bar as LF or CRLF. Click the label, use File > Line Endings, or press Cmd-L to toggle it.

Notes For Future Work

Good next areas to improve:

  • Error reporting for failed open/save operations.
  • Dirty-document tracking and save confirmation on quit/open.
  • Better scrollbar thumb behavior and page-up/page-down amounts.
  • Selection support.
  • Larger-file handling and less full-window redraw.
  • More complete keyboard navigation.

The code is intentionally plain C and fairly direct. When changing behavior, prefer keeping the boundary clear: main.c should handle Toolbox/application concerns, while editor.c should handle text state and drawing.

About

A tiny IDE for 68k based Macs

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages