How to set background color(s) of Textmate 2? - textmate2

As shown in the above screen shot, the background of code (inside <? ... ?>) is different from the area outside PHP code. How can I change the background color of PHP code?
For example, if I change the language to Perl, the color is same inside and outside code:

Themes provide foreground, background and a font style (such as bold) to scopes.
A scope is defined in the languages grammar. These are available for each language under "Bundles" -> "Edit Bundles" -> [Language] -> "Language Grammars" -> [Language].
For your question specifically, you could place the cursor on the php line and press Control + Command + T then search for Copy or Show scope:
text.html.php
meta.embedded.block.php
source.php
keyword.operator.class.php
attr.os-version.10.8.5
attr.untitled
This shows that the scope you're looking for is called text.html.php or meta.embedded.block.php. Its probably not source.php because that would apply to the entire document.
Now all you need to do is modify the theme, you can tell what your current theme is via "View" -> "Themes", Then edit it with: "Bundles" -> "Edit Bundles" -> Themes -> Themes -> [theme]
I suspect you'd like to add or change something like this, though these colors are horrible.
{
name = 'PHP: Variables Safer Globals';
scope = 'meta.embedded.block.php';
settings = {
foreground = '#00FF00';
background = '#FF0000';
};
}

Related

JupyterLab/debugger - Adjust variable list

I started working with the debugger in JupyterLab. In general, it is working, but the variable list is quite long and full os some kind of system variables. Looking at the official tutorials, there are only the "python variables" visible.
Does anyone have an idea? Thanks in advance!
picture
You can go to the Settings menu → Advanced Settings Editor → Debugger and then adjust the variableFilters setting in the User Preferences (right panel) to you liking:
Remember to press save.
Edit: as some users appear to come here for a copy-paste answer (which I never recommend - do not paste code you do not understand!), here is a little snippet that will eliminate a lot of noise from IPython history:
{
"variableFilters": {
"xpython": [
"_",
"quit",
"exit",
"debugpy",
"get_ipython",
"_i",
"_ii",
"_iii",
"_ih",
"_oh",
"_dh",
"Out",
"In",
"_i1",
"_i2",
"_i3",
"_i4",
"_i5",
"_i6",
"_i7",
"_i8",
"_i9",
"_i10",
"_i11",
"_i12",
"_i13",
"_i14",
"_i15",
"_i16",
"_i17",
"_i18",
"_i19",
"_i20",
]
}
}

How to develop a custom keyboard in Brightscript?

I'm trying to create a custom keyboard in Brightscript. I found Youtube and Netflix are using their own keyboard layout.And the Roku's keyboard is kinda different. Not clean like Youtube and Netflix. From Roku's Brightscript documentation, I found this
The default appearance of a Keyboard node is very transparent,
allowing the keyboard to pick up most of its color from what is
rendered underneath it. The appearance can be customized by changing
the keyboardBitmapUri and other fields.
keyboardBitmapUri - Specifies the URI of an image file to be loaded to replace the default keyboard image drawn underneath the key label and icons.Note that this image must be carefully designed so that the key positions match the default image. Template images for SD, HD and FHD resolutions are provided below.
Is there any sample code to do like these keyboard layouts?
Netflix Keyboard
Youtube Keyboard
I was using a keyboard dialog with the following code
sub showdialog()
screen = CreateObject("roKeyboardScreen")
port = CreateObject("roMessagePort")
screen.SetMessagePort(port)
screen.SetTitle("Search Screen")
screen.SetText("default")
screen.SetDisplayText("enter text to search")
screen.SetMaxLength(8)
screen.AddButton(1, "finished")
screen.AddButton(2, "back")
screen.Show()
while true
msg = wait(0, screen.GetMessagePort())
print "message received"
if type(msg) = "roKeyboardScreenEvent"
if msg.isScreenClosed()
return
else if msg.isButtonPressed() then
print "Evt:"; msg.GetMessage ();" idx:"; msg.GetIndex()
if msg.GetIndex() = 1
searchText = screen.GetText()
print "search text: "; searchText
return
endif
endif
endif
end while
end sub
If you have any suggestion, let me know.
Netflix and YouTube almost certainly are not using roKeyboardScreen. If you want to customize roKeyboardScreen, use the templates given - with the layout as provided.
You can always create your own custom keyboard, take a look at this example that I have developed. It's a custom keypad (for numeric entry) the code is available under MIT license at:
https://github.com/lvcabral/RokuNumericKeypad

How to enable line number upon start-up in jupyter-vim-binding?

I'm using jupyter-vim-binding. I can toggle line numbers with C-o, Shift-L. How can I enable line number upon start-up (i.e. when creating a new code cell)? I'm aware of the customization js file but I'm afraid of breaking the current setup, so would like answers from more seasoned users.
The Jupyter Notebook docs show an example to change the default indentation of code cells. You can follow the instructions on that page, but instead pass the lineNumbers argument:
var cell = Jupyter.notebook.get_selected_cell();
var config = cell.config;
var patch = {
CodeCell:{
cm_config:{lineNumbers:true}
}
}
config.update(patch)
You should still be able to toggle line-numbers with the jupyter-vim-binding shortcut.

Defining scope for custom Sublime Text 2 snippets

While trying to write my own snippets for Sublime Text 2, I ran into the following two problems:
Finding scope keys. I figured out that I can look through my packages one by one and find references to a declared "scope" property. For example in ~/Library/Application Support/Sublime Text 2/Packages/JavaScript/Comments.tmPreferences (a file in my HTML package) there's these two lines:
<key>scope</key>
<string>source.js</string>
So if I want my current snippet to work on javascript files, I define my scope like:
<scope>source.js</scope>
I'm assuming all these scope keys are defined on-the-fly based on what Packages I have installed. Does Sublime Text build a list anywhere that I can more easily reference? Perusing through a bunch of package files seems overly tedious.
Defining multiple scope properties. This I've figured out, and the following line allows my snippet to work in both HTML and JavaScript files.
<scope>text.html, source.js</scope>
Here is a list of scopes to use in Sublime Text 2 snippets -
ActionScript: source.actionscript.2
AppleScript: source.applescript
ASP: source.asp
Batch FIle: source.dosbatch
C#: source.cs
C++: source.c++
Clojure: source.clojure
CoffeeScript: source.coffee
CSS: source.css
D: source.d
Diff: source.diff
Erlang: source.erlang
Go: source.go
GraphViz: source.dot
Groovy: source.groovy
Haskell: source.haskell
HTML: text.html(.basic)
JSP: text.html.jsp
Java: source.java
Java Properties: source.java-props
Java Doc: text.html.javadoc
JSON: source.json
Javascript: source.js
BibTex: source.bibtex
Latex Log: text.log.latex
Latex Memoir: text.tex.latex.memoir
Latex: text.tex.latex
LESS: source.css.less
TeX: text.tex
Lisp: source.lisp
Lua: source.lua
MakeFile: source.makefile
Markdown: text.html.markdown
Multi Markdown: text.html.markdown.multimarkdown
Matlab: source.matlab
Objective-C: source.objc
Objective-C++: source.objc++
OCaml campl4: source.camlp4.ocaml
OCaml: source.ocaml
OCamllex: source.ocamllex
Perl: source.perl
PHP: source.php
Regular Expression(python): source.regexp.python
Python: source.python
R Console: source.r-console
R: source.r
Ruby on Rails: source.ruby.rails
Ruby HAML: text.haml
SQL(Ruby): source.sql.ruby
Regular Expression: source.regexp
RestructuredText: text.restructuredtext
Ruby: source.ruby
SASS: source.sass
Scala: source.scala
Shell Script: source.shell
SQL: source.sql
Stylus: source.stylus
TCL: source.tcl
HTML(TCL): text.html.tcl
Plain text: text.plain
Textile: text.html.textile
XML: text.xml
XSL: text.xml.xsl
YAML: source.yaml
If anything is missing, add it in this gist https://gist.github.com/4705378.
View Current Scope of Cursor Position
Place your cursor in the file where you wish to know the scope.
Use this keyboard-shortcut:
Windows: ctrl+shift+alt+p
Mac: ctrl+shift+p
The current scope will be displayed in the left side of the status bar on Windows, or in a popup window on Mac.
Use these as the <scope> key in your foo.sublime-snippet file.
The returned scopes are listed generic to specific. Choose the scope(s) which best "scoped" the snippet to where it should be available to tab trigger.
There's a package called Scope Hunter, by Isaac Muse, which is really helpful for this.
It can show you the scope under any cursor in a document, which I've found really helpful when debugging my own snippets. Sometimes it's very detailed; a sample scope from my frontmost document:
Scope: text.tex.latex
meta.function.environment.list.latex
meta.function.environment.general.latex
meta.function.environment.math.latex
string.other.math.block.environment.latex
meta.group.braces.tex
meta.space-after-command.latex
(Wrapped for ease of reading)
I wouldn't have been able to find that if I spent a week picking SL2 apart, but this package gets it in seconds. Highly recommended.
This level of detail also means that you can define snippets in a very granular way, if you want. For example, the meta.function.environment.list.latex corresponds broadly to lists in LaTeX, so I have a snippet that inserts a new \item when I press super+enter in a list environment, but nobody else. I can target snippets much more effectively than with blind guesswork.
The source code is in Github, or you can install it through Package Control.
Actually, you can use the Ctrl+Alt+Shift+P (without using Scope Hunter) and it will show you the scope on the bottom bar on the left side right after the Col/Line information. It's pretty small print but it's there.
To answer, #1, look in the syntax's .tmLanguage file, look for the key: scopeName. This is what the syntax uses for the snippet's scope value.
For example, an excerpt from nathos / sass-textmate-bundle
<key>scopeName</key>
<string>source.sass</string>
So you would use source.sass in your snippet.
Here is more info on defining a syntax

Height of tab (JTabbedPane) does not change

As the title says, the height of my tabs is not increasing as it should, my code looks like this:
JTabbedPane jtp = new JTabbedPane();
JLabel iconInTab = new JLabel(new ImageIcon("myImage.png"));
iconInTab.setPreferredSize(new Dimension(100,80)); // is the size of my Image, I've also try to do this using getSize
jtp.addTab(null,new JPanel());
jtp.setTabComponentAt(0,iconInTab);
I've also try this using html but it did not work either:
jtp.addTab("<html><p><p><p></html>",new ImageIcon("myImage.png"),new JPanel());
with the first code the problem is not the change of the size horizontally (the width change correctly), the problem is only on the height, with the second code, if I add multiple lines inside the html code, the text appear incomplete (just show the middle line) (also the width behaves as expected, the problem is the height). . .
why is this happening? or how could I get this done?
Note: S.O.: Mac OS X 10.8.1
Solved!!! The problem was that the default UI over MAC OS X (com.apple.laf.AquaTabbedPaneContrastUI), you only need to change it to the basicTabbedPaneUI (or the one of your preference), in my particular case I need to extend this class (it was a pain in the *, because what I wanted was really complex) to get the look & feel that I was expecting, if you have the same trouble just do this before adding your tabs:
myTabbedPane.setUI(new BasicTabbedPaneUI());
Note: Checking the default UI of your TabbedPane, may solve many different problems.

Resources