Skip to content

Commit

Permalink
Fix examples
Browse files Browse the repository at this point in the history
  • Loading branch information
mischnic committed Apr 28, 2018
1 parent 6386588 commit f3dd4eb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
13 changes: 6 additions & 7 deletions examples/event-loop.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict';
const http = require('http');
const os = require('os');
const libui = require('..');

let setIntervalHandle = null;
Expand All @@ -20,7 +21,7 @@ const setIntervalMs = new libui.UiSlider(0, 1000);
setIntervalMs.onChanged(setIntervalChanged);
setIntervalMs.value = 0;

const sliderLabel = new libui.UiLabel("0");
const sliderLabel = new libui.UiLabel('0');

sliderbox.append(setIntervalMs, 1);
sliderbox.append(sliderLabel, 0);
Expand Down Expand Up @@ -54,14 +55,12 @@ win.onClosing(() => {
win.show();
libui.startLoop();

const linebreak = process.platform === "win32" ? '\r\n' : '\n';

function logAppend(line) {
const lines = log.text.split("\n");
if (lines.length > 20) {
log.text = lines.slice(1).join(linebreak);
const lines = log.text.split('\n');
if (lines.length > 25) {
log.text = lines.slice(1).join(os.EOL);
}
log.append(line + linebreak);
log.append(line + os.EOL);
}

function setIntervalChanged() {
Expand Down
15 changes: 8 additions & 7 deletions examples/node-pad.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ let currentFileName = '';
function newFile() {
editor.text = '';
currentFileName = '';
status.text = 'Not saved';
}

function openFile() {
Expand All @@ -39,7 +40,7 @@ function openFile() {
err.stack);
}
editor.text = content;
status.text = `Open ${filename}`;
status.text = filename;
currentFileName = filename;
});
}
Expand All @@ -48,14 +49,14 @@ function openFile() {
function saveFileAs() {
const filename = libui.UiDialogs.saveFile(win);
if (filename) {
currentFileName = filename;
writeFile(currentFileName, editor.text, err => {
if (err) {
return libui.UiDialogs.msgBoxError(
win,
'Error while writing file',
err.stack);
}
currentFileName = filename;
});
}
}
Expand Down Expand Up @@ -87,10 +88,10 @@ menu([
label: 'Open',
click: openFile
},
{
label: 'Close current tab',
click: () => {}
},
// {
// label: 'Close current tab',
// click: () => {}
// },
{
label: 'Save',
click: saveFile
Expand Down Expand Up @@ -140,7 +141,7 @@ win = window(
tab(
{stretchy: true},
(editor = multilineEntry({stretchy: true, tabTitle: 'New file'}))),
(status = label({stretchy: false, text: 'File not changed'})));
(status = label({stretchy: false, text: 'Not saved'})));

win.show();
libui.startLoop();

0 comments on commit f3dd4eb

Please sign in to comment.