emacs-eaf / eaf-browser

A modern, customizable and extensible browser in Emacs
GNU General Public License v3.0
132 stars 26 forks source link

What is the best way to implement a customized option for changing selection color in browser? #14

Closed taquangtrung closed 2 years ago

taquangtrung commented 3 years ago

Hi,

I'm using EAF browser in dark mode, and the current background color of selected is kind of hard to see

emacs-selection

I figured out that it is configured by the code selectionColor: 'auto' at line 357 in node_modules/darkreader/darkreader.js (this file is downloaded after installation)

Can you advise if it is possible to implement a feature in EAF-browser that allows to change this setting in darkreader.js?

For example, here is the screenshot where I set selectionColor: '#ffb012', which is much easier to see the selected text.

emacs-selection-new

I'm not so familar with Node.js, hence not sure if it is possible to implement such feature from the Emacs codebase of EAF-browser.

MatthewZMD commented 3 years ago

Inspect these lines in app/browser/buffer.py:

self.buffer_widget.dark_mode_js = open(os.path.join(os.path.dirname(__file__),
                                                            "node_modules",
                                                            "darkreader",
                                                            "darkreader.js")).read()

This is where the js file is read. Rename to *_raw, then inspect this line:

self.caret_browsing_js = self.caret_browsing_js_raw.replace("%1", cursor_foreground_color).replace("%2", cursor_background_color)

You can simply specify a color when the dark mode is turned on.

taquangtrung commented 3 years ago

@MatthewZMD Thank you for the information. I'll take a look at the code.