Simple Directory listing








Directory listing

The directory listing is designed to fit on a small screen so it usually lists just filenames and not very many at that. The cursor position is marked using a method different from that used to mark highlighting. For example, a different background shade for highlights and foreground shade for the cursor.




File size display

Display size in bytes, Kbytes or Mbytes. Sized to fit in a 6-char field. K and M units are 2^10 and 2^20 scale.

: #n            \ n u --
Display n as u digits.

: ##            \ n --
Display n as two or more digits.

: 10^n          \ n -- 10^n
Generate 10^n.

: _size         \ u scale c -- int 0
Show size split in int and frac parts.

: (size)        \ u -- addr len
Convert file size using 6 chars or less

: .size         ( u -- ) (size) type ;
Display file size.




File date and time

: unp           \ u bits -- field u'
Unpack the low bits bits of u as field with the shifted accumulator u'.

: .filedate     \ u --
Prints a 16-bit date in yyyy.mm.dd format.

: .filetime     \ u --
Prints a 16-bit time in hh:mm:ss format.

: d-date        ( -- )  24 dir[] uaLEw@ .filedate  ;
Display file date.

: d-time        ( -- )  22 dir[] uaLEw@ .filetime  ;
Display file time.




Display operations

: >pos          \ +n --
Place cursor on current line to column n if possible.

: d-name        ( -- )  dfullname type  ;
Display filename.

: d-size        \ --
Display file size or "folder".

: zcurs         \ --
Zero cursor position.

variable dirmode  \ -- addr
Set non-zero to get detailed directory listing.

variable +Dirs  \ -- addr
Set non-zero to display directories in listings.

: _dirline      \ row -- row
Display filename on one line.

: _dir          \ live? -- #lines
Display short list of file names.

: dirfine       \ --
Display detailed listing for one entry.

: delete        \ --
Deletes the highlighted file and repaints the directory.

: dir           \ --
Standard directory listing.