I'm using the Tern plugin for CodeMirror, which adds intellisense features to the editor (i.e. pops up inline hint-labels).
I want to change the hint-labels style, how to do so?
Tern attaches CSS classnames to the hint box, you can utilize them to style it, e.g.:
.CodeMirror-Tern-tooltip:before {
content: url('http://n5.nabble.com/images/smiley/smiley_thinking.gif');
width: 20px;
height: 20px;
}
… which will result in this:
Related
TL;DR
I need to be able to define specific tokens in the editor as using a certain font feature without forcing it into every type of text present, without resorting to hacky alternatives.
Context:
In Visual Studio Code, you can enable font features using the setting editor.fontLigatures. I made a custom font that adds a totally ordinary OTF Stylistic Set (SS) to represent non-code text, so i can have a regular mono font to display the code, and a more readable, visually different script font to render comments and comment blocks.
To achieve that, i need to target only comments and comment blocks as having the custom stylistic set applied, but i found no way in the settings that lets me specify font features with enough granularity as to only use them for non-code text.
As an example, you can specify italics with this level of granularity using textMateRules settings:
editor.tokenColorCustomizations: {
textMateRules: [
{
"scope": "comment",
"settings": {
"fontStyle": "italic"
}
},
{
"scope": "comment.block",
"settings": {
"fontStyle": "italic"
}
}
]
}
However, i cannot force a stylistic set to be applied.
To solve this issue i use this extension, that allows me to inject arbitrary CSS into the editor.
Currently i insert this code:
/* Set documentation comments style */
.mtk38.mtki,
.mtk39.mtki {
font-family: "MonoLisa Script Nerd Font";
font-size: 1.1em;
font-style: italic;
font-weight: 375;
font-feature-settings: ss02 on;
}
/* Set inline comments style */
.mtk15.mtki {
font-family: "MonoLisa Script Nerd Font";
font-size: 1.2em;
font-style: italic;
font-weight: 200;
font-feature-settings: ss02 on;
}
This achieves the result i wanted (forcing a stylistic set into a specific subset of the editor displayed tokens), but it forces me to fidget with the permissions of the VS Code installation folder, and breaks every update. I could add a hook so every time the system updates, it could automatically manage this process, but all this i'm doing is terribly hacky and i'm sure there must be a "proper" way to achieve what i want.
Here's a concrete example of how this looks
Is there a granular way to set font features in VSCode?
I have this code for my form, it inherits the text color of the theme am using, I want give a different color to the text in the input text bar, I have the form below. Thanks
input{
color: [some color];
}
Try doing it in css. Might want to add a class to the css/input to uniquely identify it and avoid global styles.
This can either go in a css stylesheet or a style tag on the page.
A stylesheet in generally recommended, but a style tag would go above the markup like this
<style>
input{
color: [some color];
}
</style>
I'm using GXT's Info class to display messages/notifications. I'm trying to change the style of my Info class using this :
NotificationInfo info = new NotificationInfo(); // extends Info class
// Configuration
InfoConfig config = new DefaultInfoConfig(title, message);
config.setDisplay(milliseconds);
// Formatting
info.setStyleName("background-color:#f9ff4f;text-align:center;" + "border:0x solid black; padding: 3px; font-size:11px;font-weight: bold;");
info.show(config);
But it's not working! Any Pointers?
Thanks.
This should work... (for GXT3 it does anyway)
info.getElement().applyStyles("background-color:#f9ff4f;text-align:center;" + "border:0x solid black; padding: 3px; font-size:11px;font-weight: bold;");
By the way, if you need to do a similar thing for a gwt widget (that you are using in your GXT app) you can do...
info.getElement().<XElement> cast().applyStyles("background-color:#f9ff4f;text-align:center;" + "border:0x solid black; padding: 3px; font-size:11px;font-weight: bold;");
NOTE: I am not sure about the merits of setting it inline like this, but setting a css style just fails (ok the style is set on element but the actual place you want to change gets rendered in a div in a td in table down the line and the div overrides your the value inherit from the css you set). Best practice is surely to go the full appearances route for GXT3 widgets but that's a lot of work for a small change and so I do use the above sometimes.
Applying styles is only a quick solution and not the best, because GWT CssResource has few advantages than direct CSS applying like minification, validation. As mentioned in another answer the best approach is to create an appearance for including your styles and replace the appearance of the NotificationInfo with your one. I have previously answered to a similar question. Think it will help. https://stackoverflow.com/a/15222404/1293087
I set a margin for a panel in css. Now I need to get the margin width in GWT. How could I do this?
For example, I set a css style for the panel
<ui:binder>
.panel{
margin: 5px;
}
<g:HTMLPanel Ui:field=myPanel styleName="{style.panel}" />
</ui:binder>
In GWT 2.4, how can I retrieve the margin value (5px) in GWT class.
I have tired these, DOM.getIntStyleAttribute(myPanel.getElement(), "margin"),
DOM.getIntStyleAttribute(myPanel.getElement(), "marginWidth"), and myPanel.getElement().getStyle().getMargin(). all of these return 0.
How can I get the margin width then?
Thanks for replying.
Regards
You're looking for the computed style, but are requesting the element style.
If you were to set the style attribute on an element directly, then you could query the element's margin like you tried.
<!-- style can only be set on html elements, not widgets -->
<div ui:field="divElement" style='margin:5px'></div>
divElement.getStyle().getMargin();
From what I could find, GWT does not provide a method for looking up the computed style. You will instead need to rely on an external library. A quick google search for gwt computed style will provide you with a few options.
Alternatively, you could define the margin width as a GWT CSS constant and use a CssResource to access it.
MyPanel.ui.xml
<ui:style field="style" type="com.myproject.client.MyPanel.MyStyle">
#def marginWidth 5px;
.panel{ margin: marginWidth; }
</ui:style>
MyPanel.java
#UiField MyStyle style;
interface MyStyle extends CssResource {
String marginWidth();
}
I'm trying to apply css with GWT Button widget, however I can apply CSS gradient, the "embossed" style of the widget is still there. How can I remove that?
My gwt application is inherting from this theme:
<inherits name='com.google.gwt.user.theme.clean.Clean'/>
Als have tried:
<inherits name='com.google.gwt.user.theme.standard.Standard'/>
I also have tried adding:
.gwt-Button {}
In the main css file that is loaded on the page however the embossed style is still there.
Anyone knows how to remove the embossed style?
Option 1: Not using themes at all
If you don't need the default styles, and generally want to give the page your own style, then it's easiest to completely omit the <inherits> statement for the themes. GWT works very well without using a theme.
(Note: If you still need the (image) resources from the theme, but without injecting the CSS stylesheet into the page, you can inherit com.google.gwt.user.theme.clean.CleanResources instead of com.google.gwt.user.theme.clean.Clean. This way they will still be copied automatically to your war folder.)
Option 2: Selectively turning off theming for buttons
If however you generally want to use a theme, and only need to give some buttons your own style, then an easy solution is calling
button.removeStyleName("gwt-Button");
Note: Instead of removeStyleName() you could also use setStyleName("my-Button").
For convenience (and for easier usage in UiBinder) you may want to derive your own class like
package org.mypackage;
public class MyStyleButton extends Button {
public MyStyleButton(final String html) {
super(html);
removeStyleName("gwt-Button");
}
/* ... override all the other Button constructors similarly ... */
}
Which can then be imported and used in UiBinder like
<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
xmlns:g='urn:import:com.google.gwt.user.client.ui'
xmlns:my='urn:import:org.mypackage'>
...
<my:MyStyleButton>...
Option 3: Actually changing the gwt-Button class attributes
If you want to keep the themed look of the buttons, and only change a few style attributes, then it's also possible to overwrite certain attributes in the predefined style classes with !important (as suggested by #bouhmid_tun). But be careful: The list of attributes might change in the future. Here are all the predefined style classes for .gwt-Button of GWT 2.4.0 for your convenience:
.gwt-Button {
margin: 0;
padding: 5px 7px;
text-decoration: none;
cursor: pointer;
cursor: hand;
font-size:small;
background: url("images/hborder.png") repeat-x 0px -2077px;
border:1px solid #bbb;
border-bottom: 1px solid #a0a0a0;
border-radius: 3px;
-moz-border-radius: 3px;
}
.gwt-Button:active {
border: 1px inset #ccc;
}
.gwt-Button:hover {
border-color: #939393;
}
.gwt-Button[disabled] {
cursor: default;
color: #888;
}
.gwt-Button[disabled]:hover {
border: 1px outset #ccc;
}
To avoid using GWT default style, I just use !important tag in my CSS file. You'll find here an example of doing so : Remove absolute position generated by GWT. Good luck!