Comments (1)
The following patch implements hl_group_set events:
diff --git a/src/render/Redraw.ts b/src/render/Redraw.ts
index f1e659a..bd86e1a 100644
--- a/src/render/Redraw.ts
+++ b/src/render/Redraw.ts
@@ -7,6 +7,7 @@ import { Grid } from "./Grid";
const defaultColors = { background: 16777215, foreground: 0 };
const grids: Grid[] = [];
const highlights: HighlightArray = [{ background: "#FFFFFF", foreground: "#000000" }];
+let highlightsNames: string[][] = [];
const cursorStyles: string[] = [];
const nvimCursorStyle = document.getElementById("nvim_cursor_style");
const nvimHighlightStyle = document.getElementById("nvim_highlight_style");
@@ -80,9 +81,9 @@ const redrawFuncs = {
defaultColors.background = bg;
highlights[0].background = toHexCss(defaultColors.background);
}
- nvimHighlightStyle.innerText = toCss(highlights);
+ nvimHighlightStyle.innerText = toCss(highlights, highlightsNames);
},
- flush: (elem: HTMLElement) => nvimHighlightStyle.innerText = toCss(highlights),
+ flush: (elem: HTMLElement) => nvimHighlightStyle.innerText = toCss(highlights, highlightsNames),
grid_clear: (elem: HTMLElement, selector: string, [id]: [number]) => grids[id].clear(),
grid_cursor_goto: (elem: HTMLElement, selector: string, [id, y, x]: GotoUpdate) => {
grids[id].cursor_goto(x, y);
@@ -149,6 +150,12 @@ const redrawFuncs = {
highlights[id].undercurl = undercurl;
highlights[id].underline = underline;
},
+ hl_group_set: (elem: HTMLElement, selector: string, [hlName, hlId]: [string, number]) => {
+ if (highlightsNames[hlId] === undefined) {
+ highlightsNames[hlId] = [];
+ }
+ highlightsNames[hlId].push(hlName);
+ },
mode_change: (elem: HTMLElement, selector: string, [modename, modeid]: [string, number]) => {
const modePrefix = "nvim_mode_";
Array.from(elem.classList)
@@ -249,6 +256,9 @@ export function onRedraw(nvimFunctions: any,
selector: string) {
events.forEach(evt => {
const [name, ...evts]: [keyof typeof redrawFuncs, any] = evt;
+ if (name === "hl_group_set") {
+ highlightsNames = [];
+ }
if (redrawFuncs[name] !== undefined) {
evts.forEach((args) => redrawFuncs[name](elem, selector, args, nvimFunctions, extCmdline, extMessages));
}
diff --git a/src/utils/CSSUtils.ts b/src/utils/CSSUtils.ts
index 90b43ce..accf509 100644
--- a/src/utils/CSSUtils.ts
+++ b/src/utils/CSSUtils.ts
@@ -94,14 +94,16 @@ export function toHexCss(n: number) {
return "#" + (new Array(6 - str.length)).fill("0").join("") + str;
}
-export function toHighlightClassName(n: number) {
+export function toHighlightClassName(n: number | string) {
return "nvim_highlight_" + n;
}
-export function toCss(highlights: HighlightArray) {
+export function toCss(highlights: HighlightArray, highlightsNames: string[][]) {
const bg = highlights[0].background;
const fg = highlights[0].foreground;
+ // ???: Having everything on one line is critical for performance. We
+ // should try to understand why and perhaps report a bug to Mozilla.
return highlights.reduce((css, elem, id) => css +
- `.${toHighlightClassName(id)}{background: ${elem.background || bg};color:${elem.foreground || fg};font-style:${elem.italic ? "italic" : "normal"};font-weight:${elem.bold ? "bold" : "normal"};text-decoration-line:${(elem.undercurl || elem.underline) ? "underline" : (elem.strikethrough ? "line-through" : "none")};text-decoration-style:${elem.undercurl ? "wavy" : "solid"};}`
+ `.${toHighlightClassName(id)}${highlightsNames[id] !== undefined ? ("," + highlightsNames[id].map(n => "." + toHighlightClassName(n)).join(",")) : ""}{background: ${elem.background || bg};color:${elem.foreground || fg};font-style:${elem.italic ? "italic" : "normal"};font-weight:${elem.bold ? "bold" : "normal"};text-decoration-line:${(elem.undercurl || elem.underline) ? "underline" : (elem.strikethrough ? "line-through" : "none")};text-decoration-style:${elem.undercurl ? "wavy" : "solid"};}`
, "");
}
Unfortunately it makes Firenvim much slower (not very surprising given how bad I abuse the DOM). hl_group_set
events will thus be implemented when Firenvim switches to Webgl. Since it's not a crucial feature, I'll close this issue.
from firenvim.
Related Issues (20)
- Uninstallation only removes binary in WSL but not files and registry keys on Windows host HOT 1
- Unexpected directory created on Windows host after installation on Windows host side HOT 1
- "Neovim died without answering" HOT 11
- Detect potential AppArmor issues on `firenvim#install()` HOT 1
- using in note-taking App HOT 9
- Firenvim conflict with Github "Review changes" text box HOT 4
- "Unexpected output. Run nvim --headless and ensure it prints nothing." HOT 5
- Completion menu not correctly cleared, leading to screen corruption. HOT 10
- Is it possible to support firefox mobile? HOT 4
- Add explanation on how to use it with snap / flatpak HOT 1
- Firenvim has started reporting "neovim is not responding" HOT 8
- [Bug] `nvim.exe` process is not killed when closing `Firenvim` `Neovim` instance HOT 4
- Review/update recovery instructions in wiki HOT 1
- [Feature Request] pass eval_js result to lua functions HOT 2
- "TypeError: nvim.call_atomic is not a function" on Nvim HEAD HOT 3
- [feature]: extend `selector`'s behavior to choose elements HOT 2
- Empty lines are sometimes doubled when editing text box in Firefox
- Neovim plugin version (0.2.15) and browser addon version (0.2.16) do not match. HOT 9
- Is there a way to have Google Apps Script autocomplete? HOT 3
- Add table of content to README HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from firenvim.