Prop
Returning properties of the app.
app.prop(“width”)
If the renderer is not terminal, returns the width of this app in pixel.
const app = cm.app();
app.prop("width"); // 640;
If the renderer is terminal, returns the width of this app in cell.
const app = cm.app({ renderer: await cm.terminal() });
app.prop("width"); // 71
app.prop(“height”)
If the renderer is not terminal, returns the height of this app in pixel.
const app = cm.app();
app.prop("height"); // 480;
If the renderer is terminal, returns the height of this app in cell.
const app = cm.app({ renderer: await cm.terminal() });
app.prop("height"); // 26
app.prop(“frameCount”)
Returns the number of frames that have been displayed since this app started. For example, to draw a moving rect:
app.on("update", () =>
app.append(cm.rect, {
x: app.frameCount(),
y: 0,
width: 10,
height: 10,
}),
);
app.prop(“frameCount”)
Returns the number of frames to be displayed per second.
app.prop("frameRate"); // 60
app.prop(“mouseX”)
Returns the x coordinate of the mouse position.
app.prop("mouseX"); // 0
app.prop(“mouseY”)
Returns the y coordinate of the mouse position.
app.prop("mouseY"); // 0
app.prop(“mode”)
Returns the rendering mode of this app, which is only for app with a terminal renderer.
const app = cm.app({ renderer: await cm.terminal() });
app.prop("mode"); // "single"
app.prop(“pixelWidth”)
Returns the computed width of this app in pixel, which is only for app with a terminal renderer.
const app = cm.app({ renderer: await cm.terminal() });
app.prop("pixelWidth"); // 639
app.prop(“pixelHeight”)
Returns the computed height of this app in pixel, which is only for app with a terminal renderer.
const app = cm.app({ renderer: await cm.terminal() });
app.prop("pixelHeight"); // 468;
app.prop(“cellWidth”)
Returns the computed width of the cells in pixel, which is only for app with a terminal renderer.
const app = cm.app({ renderer: await cm.terminal() });
app.prop("cellWidth"); // 9
app.prop(“cellHeight”)
Returns the computed height of the cells in pixel, which is only for app with a terminal renderer.
const app = cm.app({ renderer: await cm.terminal() });
app.prop("cellHeight"); // 18
app.prop(“fontSize”)
Returns the font size used to render text, which is only for app with a terminal renderer.
const app = cm.app({ renderer: await cm.terminal() });
app.prop("fontSize"); // 15
app.prop(“fontFamily”)
Returns the font family used to render text, which is only for app with a terminal renderer.
const app = cm.app({ renderer: await cm.terminal() });
app.prop("fontFamily"); // "courier-new, courier, monospace"
app.prop(“fontWeight”)
Returns the font weight used to render text, which is only for app with a terminal renderer.
const app = cm.app({ renderer: await cm.terminal() });
app.prop("fontWeight"); // "normal"