https://github.com/munificent/malison
A little terminal emulation package for Dart.
https://github.com/munificent/malison
Last synced: 9 months ago
JSON representation
A little terminal emulation package for Dart.
- Host: GitHub
- URL: https://github.com/munificent/malison
- Owner: munificent
- License: other
- Created: 2014-07-17T03:23:42.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2024-09-29T22:58:50.000Z (over 1 year ago)
- Last Synced: 2025-03-30T06:08:09.288Z (10 months ago)
- Language: Dart
- Homepage: https://pub.dartlang.org/packages/malison
- Size: 125 KB
- Stars: 76
- Watchers: 8
- Forks: 9
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
Malison is a small [Dart][] library for drawing old school ASCII terminals in
the browser. I harvested it from my roguelike game, [Hauberk][] and it's aimed
primarily at web games ASCII graphics. Think of it like curses for the web.
[dart]: https://www.dartlang.org/
[hauberk]: https://github.com/munificent/hauberk
## Using it
Add it to your package's pubspec:
```yaml
dependencies:
malison: any
```
Then use the library:
```dart
import 'dart:html';
import 'package:malison/malison.dart';
void main() {
// Create or query a element to bind it to.
var canvas = new CanvasElement();
document.body.children.add(canvas);
// Create a new terminal. CanvasTerminal uses your browser's fonts.
// RetroTerminal uses a built in DOS-style Code Page 437 font.
var terminal = new RetroTerminal.dos(80, 40, canvas);
// You can draw strings at given positions.
terminal.writeAt(0, 0, "This is a terminal!");
// You can control the foreground and background color.
terminal.writeAt(0, 1, "This is blue on green", Color.blue, Color.green);
// You can also draw individual glyphs -- character+color units.
terminal.drawGlyph(3, 4, new Glyph.fromCharCode(CharCode.blackHeartSuit,
Color.red, Color.white));
// When you're done drawing, tell it to render all of the changes. It renders
// in batches for performance.
terminal.render();
}
```
## Example
The repo includes a little example web application so you can see it in action.
From the root of repo, run:
```sh
$ dart run build_runner serve
```
Then in your browser of choice, navigate to `http://localhost:8080`.