Giter VIP home page Giter VIP logo

matlab-schemer's Introduction

MATLAB FileExchange

MATLAB Schemer

This MATLAB package makes it easy to change the color scheme (a.k.a. theme) of the MATLAB display and GUI.

You can use Schemer to import a predefined color scheme, transfer your color settings between installations, or create your own color scheme.

A collection of color schemes is available in the schemes folder. Samples of these can be seen in schemes/README.md, and browsed in the folder schemes/screenshots. This is a static subtree copy of the contents of the repository matlab-schemes.

MATLAB Schemer logo

Importing a color scheme

Color schemes can be easily imported by running schemer_import at the MATLAB command prompt, without needing any inputs. This will open a GUI to select the file to import the color scheme from.

When importing a color scheme, most of the settings will change immediately. However, some settings will require MATLAB to be restarted:

  • Variable highlighting colours
  • Wavy underlines for errors
  • Wavy underlines for warnings

For more details, see the documentation on the function schemer_import, available with help schemer_import.

Transferring a color scheme between MATLAB installations

If you are using a personalised color scheme in MATLAB, you may wish to save it for yourself so you can re-implement it easily if you reintall MATLAB. Or you may wish to transfer your personalised color scheme from one machine to another. This section describes the steps relevant in either scenario.

On the source machine, run schemer_export to save a temporary color scheme file, and then transfer this file to the destination machine.

When importing the new color scheme, instead of running schemer_import without any inputs, you should run schemer_import(true). This passes a flag to tell the function to not only import the colour preferences, but to also import your boolean settings (such as whether to highlight the current cell/line, etc) from the file you exported from the source installation.

Reverting to the MATLAB default color scheme

Should you wish to revert to the set of colours which MATLAB ships with, you should run schemer_import('schemes/default.prf').

This will import the MATLAB default theme from the stylesheet default.prf which comes as part of Schemer.

To restore the out-of-the-box state for boolean settings (such as whether to highlight the current line) in addition to the colours, run schemer_import('schemes/default.prf', true).

You may be tempted to instead revert the colours by clicking the Restore Default Colors buttons in the Color pane of the MATLAB preferences. However, this will be less effective than importing the default colours through Schemer because these buttons will not reset all the MATLAB colour preferences. (There is no reset button for the Editor display preferences pane, nor for the other language syntax supported by MATLAB, which is available in the Editor Languages panel.)

Creating a color scheme for others to use

When creating a color scheme to share with the rest of the world, it is recommended to ensure colours are chosen appropriately for all possible settings, even if they are not enabled.

For example, if you are creating a dark colour scheme, you may have cell highlighting disabled but it would still be ill-advised to leave the background highlight colour for cell displays as the default pale beige because other users may have this setting enabled.

Exporting through the GUI

If you have made a custom color scheme using the MATLAB GUI to pick the colours, you can export the new color scheme with schemer_export.

Please note, this requires you to have visited all relevant panes of the Preferences window at least once since MATLAB was installed, even if the settings have not been changed from the default. See the help for schemer_export for more details.

Porting a theme from a different editor

If you are converting a color scheme designed for another editor into a MATLAB stylesheet, you may find it easier to start with a duplicate of the template stylesheet develop/template_scheme.prf and copy the colours into this.

To understand which colour settings the parameter names correspond to, you can refer to the annotated screenshot, develop/annotated_default.png.

Annotated screenshot

The values for each colour in the .prf stylesheet must be recorded as single RGB integers, with each colour channel in 8-bit (0-255), R as big endian, and a opaque alpha channel. Because the format for RGB colours in Java allows for an alpha channel and the integers are signed, all the colours you record in your .prf file should be negative, spanning the range -16777216 (black, [0,0,0]) to -1 (white, [255,255,255]).

The text file for your pre-existing theme will typically specify its colous in hexadecimal format, or in terms of R, G, B values. You will need to convert the colours from this format into the format which MATLAB preference files use to specify colours instead. The Schemer package comes with a utility function develop/color2javaRGBint.m to help make this easier. See the color2javaRGBint documentation for more details.

Setting colours for additional languages

MATLAB supports syntax highlighting for several languanges in addition to its own. Currently these languages are MuPAD, TLC, VRML, C/C++, Java, VHDL, Verilog, and XML/HTML. The colours used for the syntax highlighting of all these languages can be set in the Languages subpanel of the Editor/Debugger pane in the Preferences window.

Typically, one will want to make a color scheme which has colours in these languages which match the colours of the analogous MATLAB syntax. By default, this is the behaviour which Schemer will perform.

Without specifying any inputs to schemer_export, an exported color scheme file will contain only the colours used for MATLAB syntax highlighting and no other languages, since it is expected that users will typically not set the colours for any of these languages. When this is loaded with schemer_import, the missing colours for additional languages are automatically completed based on the MATLAB syntax.

If you do customise the colours for the additional language syntax highlighting, you can export this by setting an appropriate flag, such as schemer_export(3). For more details, see the schemer_export documentation.

If you are designing a color scheme and are very detail-oriented, you may like to do the following.

  1. Configure the colours for the MATLAB syntax first in the Preferences > Colors panel and Programming Tools subpanel, along with Editor/Debugger > Display preference pane for the Current line highlighting and Right-hand text limit.
  2. Export the colorscheme with schemer_export('tmp.prf',1), excluding additional language syntax from the export.
  3. Load the colorscheme with schemer_import('tmp.prf'), which overwrites the syntax for the additional languages with automatically inferred colours.
  4. Open up the panel Preferences > Editor/Debugger > Languages and inspect the quality of the colorscheme in the addition languages.
  5. Fix or improve any perceived issues with the colorscheme in the Languages panel.
  6. Export the colorscheme again, but this time with schemer_export(3) to include the customised colours for the additional languages.

Adding your scheme to this package

If you are particularly proud of your new color scheme (and why wouldn't you be) and would like to to share it with the world as part of the matlab-schemer package, this is possible!

Please head over to our daughter repository, matlab-schemes, which holds the master copy of the color schemes issued here as part of Schemer in the schemes directory.

If you fork matlab-schemes, add your .prf file and issue a pull request, the new scheme will be reviewed and added to the repository. This content is then mirrored here using git subtree. For more details, see our CONTRIBUTING.md.

Addendum

Requirements

Please note that Schemer requires MATLAB to be run with Java support enabled.

Further information

For details on how the method was implemented, see this Undocumented Matlab article.

matlab-schemer's People

Contributors

dkearn avatar scottclowe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

matlab-schemer's Issues

Supported Matlab versions?

Hi Scott!

Quick question: What versions of Matlab does matlab-schemer support? I'm thinking of playing around with this and maybe making a PR, and I'm wondering which language features I can use and what versions of Matlab I need to test against.

Cheers,
Andrew

Don't import faulty color schemes

Similarly to #3, if a color scheme has the same colour for the text as the background, we should not import it. Instead just give a warning and return, or generate an error.

Taskbar and window color are unchanged

The description of the Schemer function is that it modifies the color scheme of "the MATLAB display and GUI". The window, taskbar, and individual tabs are all part of the MATLAB GUI. In fact, aside from the "display" insets, they comprise the GUI in its entirety.

Is this a bug, a non-default option, or an oversell of the functionality?

I would be happy to be wrong, but at this point this schemer seems a bit of a bait and switch. The color contrast of dark-mode color schemes against the white GUI is eye-straining in and of itself. Thank you for implementing a method to revert to default.

Make icon

Need a nice icon for on MATLAB FEX.

This will demonstrate the colours schemes currently available in scottclowe/matlab-schemes.

How to make new scheme persistent?

I am new to Matlab and to matlab-schemer. I am running Matlab 2022b_r3 on Linux (Linux Mint 21.1 Xfce, based on Ubuntu 22.04 LTS). I have managed to use matlab-schemer to switch from the Matlab default color scheme to the cobalt scheme, but when I close Matlab and restart it, the color scheme has reverted to the Matlab default light color scheme. Is there a way to make the matlab-schemer cobalt scheme persistent so that Matlab starts up with the cobalt scheme?

App Designer Editor Incompatibility

First of all, I'd like to thank you for your efforts ๐Ÿ‘ , I love dark schemes โค
I have encountered incompatibility with the App Designer Editor in MATLAB.
I think the new App Designer Editor was out of the scope once you started making the schemer.
App Designer Editor isn't affected by the schemer except for line highlighting, I had to disable it. I'll post some pictures if someone else encounters the same problem.

App Designer Editor while in "Default" scheme :

default

Problem occurs while in "Dark" schemes with Current Line Highlight enabled :
darkmode_withLine

Disabling Current Line Highlight solves it for now:

highlight_current_line

DarkwithoutLine

Using Octave, not working.

It reported this error:
'com' undefined near line 537 column 17
error: called from
schemer_import>main at line 537 column 17
schemer_import at line 176 column 26

please help, thanks,

Debug highlighting is hard to read using Cobalt

When debugging using Cobalt scheme, jumping over called functions in tha call stack, at stop lines you see something like this:

image

image

which is quite hard to read. Could you please fix this?

Thank you.

Smaller logo

The logo would work better on FileExchange if it were smaller, as then a higher resolution version would be displayed and visitors would be able to see the text.

R2016a and later: "Validation sections" syntax highlighting ?

Hi Scott,

Thank you so much for implementing and sharing this repository, it's very appreciated! I'm working in R2018a, and having trouble finding the *.prf color setting for Matlab's so-called "Validation sections":

Preferences / Colors / MATLAB syntax highlighting colors / Validation sections

Within classdef files, this controls the color of per-property class type declarations, as explained here. I believe property validation was introduced into Matlab in R2016a.

Please let me know your thoughts on adding support for this, within the schemer *.prf files?

Thanks,
Brad

Support for additional languages

MATLAB supports syntax highlighting for a few other languages, including Java, C++ and XML. Currently these colours are not saved or set by matlab_schemer, but there is no reason why they should not be.

In fact, since these other languages take their main background and text colours from the MATLAB colours, they do not render correctly when the colour scheme is changed to a dark theme.

Since it is desirable for the colours for common syntax such as commands, comments, etc to match across the languages for any given theme, the colours should be assigned with sharing across these.

I don't expect that users who are creating a colour scheme will define the colours for all languages, so by default colours for other languages should be taken from the MATLAB syntax, but it should be possible for users to override them with custom language syntax colours.

Support for bold/italic of Java method

There is a setting to control whether methods in Java should be displayed in Bold, Plain or Italic text. This needs to loaded if present in the settings file, and exported if the Java language panel is available.

Warn if colour scheme cannot be exported

The code really needs to give a warning if the user has not visited all the preference panels.

Currently, the problem is a value is returned by the java getPrefs function even if the value is not available - it is just the wrong value is returned. But I can check if all the values from a panel are returned as black -16777216, and if so assume the panel is not being exported correctly.

Warn if non-Color panels are unvisited

We should check if panels other than the first Color preference pane have actually been initialised. This can be done by comparing the preferences set in that pane and seeing if they are all black.

Support VRML/X3DV syntax

New language VRML/X3DV (virtual reality modelling) syntax highlighting was added to MATLAB by MathWorks in the 2016a release.

The following steps will need to completed:

  • Create sample.wrl and/or sample.x3dv samples to demonstrate syntax highlighting in action.
  • Identify the code names in matlab.prf corresponding to the new colour settings.
  • Add exporting of this language to schemer_export (enabled when additional languages enabled, and version is at least M2016a)
  • Add the default settings for VRML colours to default.prf
  • Add importing of this language from .prf to schemer_import, using inheritance from MATLAB (.m) syntax highlighting colours when the VRML settings are omitted

Import hex values

I expect a reasonable number of people will want to create a new color scheme based on an existing one implemented for a different editor.

At the moment people can port the color scheme across by manually choosing how to map the between the entities in the two formats and converting any hexadecimal colours with color2javaRGBint. However, having to convert all the colours into RGB integer format one at a time is tedious. Also, it becomes hard to keep track of what colour the value encodes.

It would make it much easier for users to simply copy over the hexadecimal values into the template prf file. Not only would such a thing be much faster, it will also make porting a colour scheme more accessible.

This will make the format incompatible with the actual MATLAB .prf format (which does not have any hexadecimal values), but this can be fixed by importing the color scheme and exporting it again with schemer_export. After the hex values are successfully imported, the colour values will be exported into RGB int format instead.

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/28132465-import-hex-values?utm_campaign=plugin&utm_content=tracker%2F19271142&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F19271142&utm_medium=issues&utm_source=github).

Intallation

Can someone tell me exactly what to do. I can't get it to work

Create function to upload schemes to a central server

It would be easier for Matlab users unfamiliar with GitHub to upload any schemes they create without leaving the Matlab environment.

To this end, it might be worthwhile setting up a server which can hold and serve the Matlab schemes, and a function which can upload them to the server using a simple UI running in Matlab.

Export colours which are only present in some MATLAB versions

Mathworks adds support for new languages, etc every so often. We need a way to check whether the colours exist to be exported in the version currently being run.

This could be done by checking if the version number (or better yet, release date) is higher than a threshold. Or for collections of colours which were added at the same time, checking whether they are all black. In the later case, the solution is similar to #5.

bug in develop\sample.m

In develop\sample.m fprintf(fid, '%d unterminated\n, i); is not properly terminated. this can accuse issues in mcc (code compilation)

Easily set included schemes without file browser

I was confused at first because there weren't clear instructions on what to do to apply one of the included schemes. I didn't know that I needed to navigate to ~\Matlab\Add-Ons\Collections\MATLAB Schemer\scottclowe-matlab-schemer-2156bb9\schemes to find a file to load.

My suggestion would be to add support for quickly setting the included schemes via an API like schemer_import('monokai') and the function automatically loads the included file.

Version check for Additional Languages

We should check if the user is exporting from a version of MATLAB which supports the language being exported due to the following scenario:

  • User is in older version of MATLAB which does not support all the languages in the most up to date version. (Language ABC is not included in their version.)
  • User imports scheme X which contains additional languages, with every language specified in the .prf file (including ABC). Now user has settings saved in matlab.prf for languages which their GUI will not present.
  • User designs a new scheme for MATLAB syntax.
  • User ignores advised instructions for the creation of a scheme with additional languages (which specify to create MATLAB syntax, export, import, fix additional languages) and designs the additional languages colours without importing the MATLAB syntax as a base.
  • User exports the colour scheme to Y.prf, with additional languages included. The exported scheme will have colours for ABC from scheme X because these settings will exist in matlab.prf, but they do not match the background etc specified for their scheme, Y.
  • User distributes their scheme, Y. Others import it into up-to-date MATLAB. Colours for ABC syntax do not work.

This scenario will presumably happen eventually, but it is not a high priority. I anticipate the majority of designers will not do anything for the Additional Languages.

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Compatible with New Desktop for MATLAB (Beta) Add-On?

Hello,

I enjoy using your schemer to implement the dracula color scheme. However it seems this package is not compatible with the new desktop. I tried reenabling dracula (which functioned in vanilla matlab) but it doesn't seem to work anymore in the new dark mode desktop.

Does anyone else encounter this problem or is it something local on my end that is causing my theme to no longer load on the dark mode desktop? The matlab developers mentioned it uses a different engine based on Matlab Online if that offers any insight.

Thank you!

Not working with live script (.mlx)

Hello,
First of all, thank you for the color schemes. As I run the dark mode, it seems to be ignoring the live scripts. The live scripts are still unchanged (regular white background). It would be helpful if you may address this.

Matlab r2017a Programming Tools Preferences

At least these variables don't seem to exist in r2017a anymore:
ColorsUseMLintAutoFixBackground
Editor.VariableHighlighting.Automatic
Editor.NonlocalVariableHighlighting
EditorCodepadHighVisible
EditorCodeBlockDividers
Editorhighlight-caret-row-boolean

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.