diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/basic-app.js | 10 | ||||
-rw-r--r-- | examples/command-line-interface.js (renamed from examples/interfacer-command-line.js) | 13 | ||||
-rw-r--r-- | examples/label.js | 5 | ||||
-rw-r--r-- | examples/list-scroll-form.js | 16 | ||||
-rw-r--r-- | examples/telnet-interface.js (renamed from examples/interfacer-telnet.js) | 23 |
5 files changed, 36 insertions, 31 deletions
diff --git a/examples/basic-app.js b/examples/basic-app.js index bf8aa41..c4027d1 100644 --- a/examples/basic-app.js +++ b/examples/basic-app.js @@ -6,14 +6,14 @@ // - Sending a quit-app request via Control-C // // This script cannot actually be used on its own; see the examples on -// interfacers (interfacer-command-line.js and inerfacer-telnet.js) for a +// interfaces (command-line-interface.js and telnet-interface.js) for a // working demo. -const Pane = require('../ui/Pane') -const FocusElement = require('../ui/form/FocusElement') -const TextInput = require('../ui/form/TextInput') +import {TextInput} from 'tui-lib/ui/controls' +import {Pane} from 'tui-lib/ui/presentation' +import {FocusElement} from 'tui-lib/ui/primitives' -module.exports = class AppElement extends FocusElement { +export default class AppElement extends FocusElement { constructor() { super() diff --git a/examples/interfacer-command-line.js b/examples/command-line-interface.js index 1da6adf..ba1d936 100644 --- a/examples/interfacer-command-line.js +++ b/examples/command-line-interface.js @@ -1,11 +1,12 @@ -const Root = require('../ui/Root') -const CommandLineInterfacer = require('../util/CommandLineInterfacer') -const AppElement = require('./basic-app') +import {Root} from 'tui-lib/ui/primitives' +import {CommandLineInterface} from 'tui-lib/util/interfaces' -const interfacer = new CommandLineInterfacer() +import AppElement from './basic-app.js' -interfacer.getScreenSize().then(size => { - const root = new Root(interfacer) +const clInterface = new CommandLineInterface() + +clInterface.getScreenSize().then(size => { + const root = new Root(clInterface) root.w = size.width root.h = size.height diff --git a/examples/label.js b/examples/label.js index b8992d2..f9599c6 100644 --- a/examples/label.js +++ b/examples/label.js @@ -1,7 +1,8 @@ // An example of basic label usage. -const ansi = require('../util/ansi') -const Label = require('../ui/Label') +import {Label} from 'tui-lib/ui/presentation' + +import * as ansi from 'tui-lib/util/ansi' const label1 = new Label('Hello, world!') const label2 = new Label('I love labels.') diff --git a/examples/list-scroll-form.js b/examples/list-scroll-form.js index c015ddb..fc319a6 100644 --- a/examples/list-scroll-form.js +++ b/examples/list-scroll-form.js @@ -1,13 +1,13 @@ -const ansi = require('../util/ansi') -const Root = require('../ui/Root') -const CommandLineInterfacer = require('../util/CommandLineInterfacer') -const ListScrollForm = require('../ui/form/ListScrollForm') -const Button = require('../ui/form/Button') +import {Root} from 'tui-lib/ui/primitives' +import {Button, ListScrollForm} from 'tui-lib/ui/controls' -const interfacer = new CommandLineInterfacer() +import {CommandLineInterface} from 'tui-lib/util/interfaces' +import * as ansi from 'tui-lib/util/ansi' -interfacer.getScreenSize().then(size => { - const root = new Root(interfacer) +const clInterface = new CommandLineInterface() + +clInterface.getScreenSize().then(size => { + const root = new Root(clInterface) root.w = size.width root.h = size.height diff --git a/examples/interfacer-telnet.js b/examples/telnet-interface.js index d7aad43..319786f 100644 --- a/examples/interfacer-telnet.js +++ b/examples/telnet-interface.js @@ -1,23 +1,26 @@ // Telnet demo: -// - Basic telnet socket handling using the TelnetInterfacer +// - Basic telnet socket handling using the TelnetInterface // - Handling client's screen size // - Handling socket being closed by client // - Handling cleanly closing the socket by hand -const net = require('net') -const Root = require('../ui/Root') -const TelnetInterfacer = require('../TelnetInterfacer') -const AppElement = require('./basic-app') +import net from 'node:net' + +import {Root} from 'tui-lib/ui/primitives' + +import {TelnetInterface} from 'tui-lib/util/interfaces' + +import AppElement from './basic-app.js' const server = new net.Server(socket => { - const interfacer = new TelnetInterfacer(socket) + const telnetInterface = new TelnetInterface(socket) - interfacer.getScreenSize().then(size => { - const root = new Root(interfacer) + telnetInterface.getScreenSize().then(size => { + const root = new Root(telnetInterface) root.w = size.width root.h = size.height - interfacer.on('resize', newSize => { + telnetInterface.on('resize', newSize => { root.w = newSize.width root.h = newSize.height root.fixAllLayout() @@ -31,7 +34,7 @@ const server = new net.Server(socket => { appElement.on('quitRequested', () => { if (!closed) { - interfacer.cleanTelnetOptions() + telnetInterface.cleanTelnetOptions() socket.write('Goodbye!\n') socket.end() clearInterval(interval) |