Sublime - Change background color based on Build System - sublimetext

There is a question asking how to change background color based on file type, Sublime 2 -changing background color based on file type?.
Something close to this came to my mind. I was thinking in change the background color based on current Sublime Build System. Would it be possible?
For example, Red means Python, Green means LaTeX, Blue means Automatic.

There are some built-in commands to run a specified build system or to set a particular one as the active build system, so you could possibly set an EventListener to listen for the set_build_system command and fire off a plugin to change the current view's background (or all the views in a window, or all views in all windows) when the build system is changed.
Here's a brief proof of concept:
import sublime
import sublime_plugin
class ListenToBuildSystem(sublime_plugin.EventListener):
def on_window_command(self, window, command, args):
if command == "set_build_system":
window.run_command("toggle_minimap")
This toggles the display of the minimap every time the build system is changed.

Related

Event in Netlogo

I use Netlogo 6.0.4, In the interface there is a chooserbutton, which is a set of different colors
I want to change all patches colors when the color changes, i.e. when event happens. As alternative , I can add a button to color patches based on color which was chosen recently, but I prefer not to.
Is there some solution for that
A button pushes a piece of code into the run, but a chooser just selects a particular value of a variable. If you want to control colours during the run with a chooser, then you need to query that variable regularly. Since your question says that you want to change colour when an even happens, then you could simply query the variable when that event occurs.
Alternatively, just have ask patches [ set pcolor patch-color ] in the go procedure (assuming your chooser is called patch-color). Assuming you have the standard NetLogo setup of a go procedure with all your actions and the tick then your patches will be appropriately coloured but there will be a slight delay between the event occurring and the change of colour because it won't update until that code is reached.

How to get correct background and control colors in property pages?

I'm trying to handle background color properly in a dynamically generated property sheet in dynamically generated property pages in win32 api using MFC (though I expect my question is general, and not restricted to MFC, but since my code and examples use it, it's germane to my question anyway).
So we have a:
CPropertySheet
containing multiple
CPropertyPage
I generate the contents of any given page dynamically - from file resources using a custom dialog definition language - all irrelevant other than to say - a list of controls and their coordinates is created within a given page, and the page is resized to accommodate them. This logic is working beautifully.
However, what doesn't work is that the controls and background of each page draws using the dialog default color/brush.
I've tried a number of ways to attempt to force it to draw using the white color/brush that a hard-coded property sheet / page would.
There are two important pieces to this:
Page Background
Control (on the page) background
For #1, I've tried:
acquire the background brush from parent window class (it's dialog bkgrd) (same is true if I do this and ask the tab control)
change the property page to use WS_EX_TRANSPARENT (PreCreateWindow is not called by the framework when generating a page viz PropertySheet::AddPage)
For #2, I've tried:
overriding OnWndMsg / WM_CTLCOLORSTATIC to forward that request to (A) the parent (sheet), and (B) to the tab control (which is what wants the white in the first place).
However, anytime I use any of the above "ask for the background / forward the request" up the chain to either the sheet or the tab control - I get the dialog background color, never the white I'd expect.
Using Spy64, I can see that for a fully hardcoded property sheet / page - that the only discernable differences I can see is that the dialog window created in AddPage (or its moral equivalent) has WS_CHILD instead of mine which has WS_POPUP (the rest of the styles appear to be the same, such as WS_VISIBLE|DS_3DLOOK|DS_FIXEDSYS|DS_SETFONT|DS_CONTROL and WS_EX_CONTROLPARENT.
So, other than the WS_CHILD, I see no significant differences from what I'm creating and from another property sheet that works properly from a standard resource (i.e. hard coded).
I'm also flummoxed as to how this works normally anyway - since forwarding things like the ctrlcolor message doesn't respond correctly - and asking for the windows background colors similar doesn't - then how is it in a standard case the background colors of controls and pages comes out as white, and not dialog background?
Any ideas or help would be appreciated - I'm kind of running out of ideas...
When Visual Styles were added in Windows XP they really wanted to show off this new feature so they made the tab background a gradient (really a stretched image) instead of a single color and this caused problems in old applications that did custom drawing with the dialog brush as the background.
Because of this, only applications with a comctl32 v6 manifest got the new look but there was a problem; old propertysheet shell extensions would load in new applications (including Explorer) and things would look wrong.
To work around this they also require you (or your UI framework) to call EnableThemeDialogTexture(.., ETDT_ENABLETAB) to get the correct tab page look.
As if things are not tricky enough, there is a undocumented requirement that you also need a button or a static control on the page!
If you have custom controls they have to call DrawThemeParentBackground when you draw if they are partially transparent.
Turns out my old code had defined an ON_WM_ERASEBKGND handler - and removing that (and all of my above attempts) makes it work.
So simply doing NOTHING is the correct answer. D'oh!!!
I'm leaving my shame here in case someone else trips on this! [Whoops!]
(Still interested if anyone has deeper insight into how this mechanism works under the hood)

Tkinter entry widget lags while typing. How to update typed text in real time?

Using python3. I'm new to tkinter writing a program with a GUI that takes some input parameters and does some data processing, so it needs entry boxes where I can type numbers in.
I cannot for the life of me figure out how to get the entry boxes to stop lagging, i.e: when a box is clicked on and typed into, the changes made to the text in that entry box don't appear until I click on another button or text box in the window. Functionally, the program still works like this but it's irritating not being able to see what I'm typing and others will eventually use this software.
I've gotten halfway to fixing the problem by putting in event bindings so that key presses trigger an update of the idle tasks. The text now updates while typing, but it's "one letter slow" (a typed letter appears only after the next letter is typed) and this is still not ideal.
Help?
MWE:
from tkinter import *
###Window: 'top'
top = Tk() #make window
top.geometry("670x360") #window size
top.wm_title("Test program for TKinter")#window title
#window and label background colour
bgcol='light sea green'
top.configure(background=bgcol) #set colour
#events to refresh window
def keypress(event):
print('key pressed')
#update all idle widgets (remove text box lag)
top.update_idletasks()
def mouseentry(event):
print('mouse entered text box')
#update all idle widgets (remove text box lag)
top.update_idletasks()
##text entry box
Label(top,background=bgcol, text="").pack() #spacing label
v = StringVar()
e=Entry(top, width=50, textvariable=v)#,height=1)
e.pack()
Label(top,background=bgcol, text="").pack() #spacing label
v.set("a default value")
s = e.get()
e.bind("<Key>",keypress)
e.bind("<Enter>",mouseentry)
#Label displaying text box contents (not working right now, not important)
Label(top,background=bgcol, textvariable=s).pack() #text display label
#make buttons appear on start
top.update()
top.mainloop()
How do I update the entry widget as it is typed? Is there something really simple that I'm overlooking?
Answer to own question:
Mainloop wasn't running in the background (or something) of my python install, for whatever reason, whether run via Anaconda or via the terminal.
Simple reinstall of Anaconda IDE with python3.4 fixed all my issues.

How to add a NSColorPicker to the application's main window?

I'm building an application to generate an array of colors based on a color chosen by the user.
The default on Mac OS X for color selection is to open a NSColorPanel containing multiple NSColorPickers. But, as the color selection process is the main interaction the user will have with the app, it'd be better to avoid the extra clicks and panel-popping in favor of a more straightforward way.
So, is there any way to add a NSColorPicker object to a window?
I know this is an older question, but check out NSColorWell. From the docs:
NSColorWell is an NSControl for selecting and displaying a single color value.
Interresting Question.
I strongly doubt it (but would love to be proven wrong). NSColorPickers are not NSControls (nor NSCells) so there's no clean wrapper to insert into a window.
Even if you were to instanciate an NSColorPanel and get a reference to its contentView and copy it (with all that defines the color picking controls) to your own window... there's no obvious way of obtaining the color value. NSColorPickers are plug-ins so you can't forsee the controls of a colorPicker.
The only other way I can see (and that's a stretch) would be to manually load the NSColorPickers plug-ins directly. I don't know how successfull this would be.
File a bug report and request the feature?

Unable to have no Scattered windows in Screen by .Xresources

Inital Problem: to have no scattered windows when I use vspilt in Vim inside Screen
Attemps to solve the problem:
Impossible: to increase the Display Refreshing Rate for Mac's terminal code
to add something to .Xresources
alt text http://dl.getdropbox.com/u/175564/bugWithScreen.png
Unix Power Tools -book says that the problem can be solved in .Xresources.
However, it does not specify exacly how.
I have collected the following codes to my .Xresources
mrxvt*scrollBar: true
mrxvt*loginShell: true
mrxvt*syncTabTitle: true
mrxvt*font: Monaco
mrxvt*faceSize: 11
mrxvt*xft: True
mrxvt*xftFont: Monaco
mrxvt*xftSize: 12
mrxvt*xftAntialias: True
mrxvt*termName: xterm-256color
XTerm*VT100.metaSendsEscape: True
# translations used to coordinate xterm with xcilpboard
# Unix Power Tools: p.117
*VT100.Translations: #override\
Button1 <Btn3Down>: select-end(primary,CUT_BUFFER0,CLIPBOARD)\n\
!Shift <Btn2Up>: insert-selection(CLIPBOARD)\n\
~Shift ~Ctrl ~Meta <Btn2Up>: insert-selection(primary,CUT_BUFFER0)
Is this occurring when you run Tlist, or when reconnecting to a previously opened session?
If it's the latter (and your window size varies), it may be because of the options screen was launched with. Try launching screen with these options "-aADR". "-a" and "-A" will force screen to redraw upon reconnection.
Parsing of ~/.Xresources is done when the X11 server is started, as part of the X11 session init scripts. If you edit ~/.Xresources then you need to use xrdb(1) to load in the new file to tell the running X11 server about the changes.
BEWARE that xrdb(1) will, by default, replace the current resources instead of overwriting them and read from stdin is the default, so don't invoke it with no parameters! So you want to use
xrdb -merge ~/.Xresources
to load the changed file in. You can use
xrdb -query
to see what's already loaded.
For the Mac, I don't know what, where or when, might be looking at ~/.Xresources; because the X11 stuff is a program run to use the display, rather than the master of everything graphical, it might be rather minimal and not doing so by default. xrdb -query will help.
One thing that might help is to instead set XAPPLRESDIR as an exported shell variable; there's some knob somewhere in MacOS to set environment variables as a session thing, visible to all programs without hitting the user shell, but I forget where (found it when setting up the SSH Keychain once). XAPPLRESDIR is an env variable variable to point to a user's own overrides of application resources. It's value should be a directory ($HOME/share/xapps/ for instance). Every X11 application linked against the X Intrinsics library (libXt) will, at X11 init time, look in that directory for files matching the application class name. This way, you don't need to worry about loading resources, etc; edit the app file, start the program.
So resources for xterm go into a file XTerm, etc; to find out the class of an arbitrary program, you might use xprop(1) with no arguments, click in the target window while the pointer is a cross-hair and then look at stdout from xprop for the WM_CLASS property. For some older tools like xterm you can also use editres(1) to be able to interactively view the widgets of a running X application via remote inspection; there's a Get Tree menu item, to let you click on the target app and another menu item to show the class names.
Myself, my ~/share/xapps/XTerm file sets the menu background colour to a hideous yellow; that way, when I control-<left|middle|right>-click in an XTerm I immediately know if something is wrong and my resources weren't loaded.
#ifdef COLOR
XTerm.SimpleMenu*background: yellow
#endif

Resources