Snipmate triples my input. I do the following:
template[press tap here]
I get an expansion:
template <class T = >
class {
public:
() {}
~() {}
private:
};
which simply follows the definition in ~/.vim/vim-addons/snipmate-snippets/snippets/cpp.snippets
# template
snippet template
template <class ${1:T} = ${2}>
class ${3:`Filename('$3', 'name')`} {
public:
$3() {}
~$3() {}
private:
};
I have no problem with inputting {$1} and {$2} tab stops but when I enter "lala " for {$3}, i get
template <class T = int>
class lala lala alal {
public:
lala alal() {}
~lala alal() {}
private:
};
snipmate syntax is pretty simple. i'm confused on what i'm doing wrong.
I installed snipmate through VAM
call vam#ActivateAddons(['snipmate-snippets'], {'auto_install' : 0})
What I write, might be a bit biased, but I don't see any reason for using snipMate, when there is UltiSnips by SirVer. Don't get me wrong snipMate is great, or better say - was great, but now it's just so far behind the UltiSnips plugin.
Be sure to see screencasts posted in the README of this project - to see the proof of what I said above.
Good luck.
Related
If I instantiate a lambda somewhere (and the compiler doesn't inline it), I can find a string showing where the lambda is located in my c++ code like this:
... ?AV<lambda_1>#?0??MyFunction#MyScopedClass#MyNamespace##SAXXZ# ...
I don't want this information in the executable, as it could give away important names of classes and functions.
All kinds of output debug information are turned off. If I use a normal function instead, the final executable doesn't have this information, so manually converting all lambdas into normal functions would "fix it". But what's the best way to handle this? Can we tell the compiler to transform lambdas into normal functions?
UPDATE: I tested with other compilers: g++ and clang. They both leave the same references. I also found another unanswered question about this Gcc - why are lambdas not stripped during release build Please don't come with the "why do you care about a few symbols anyway".
Here's some code you can test with:
#include <iostream>
#include <functional>
class MyUnscopedClass
{
public:
MyUnscopedClass(const std::function<void(int x)>& f) :
f(f)
{
}
std::function<void(int x)> f;
};
namespace MyNamespace
{
class MyScopedClass
{
public:
static void temp1(int x)
{
std::cout << x * (x + 1);
}
static void MyFunction()
{
//MyUnscopedClass obj(temp1); // no symbols
MyUnscopedClass obj([](int x) // ?AV<lambda_1>#?0??MyFunction#MyScopedClass#MyNamespace##SAXXZ#
{
std::cout << x;
});
obj.f(23);
}
};
}
int main()
{
MyNamespace::MyScopedClass::MyFunction();
}
With the help of #dxiv in the comments, I found the problematic setting.
Configuration Properties > General > C++ Language Standard
can't be, for some reason,
Preview - Features from the Latest C++ Working Draft (std:c++latest)
So I set it to the second most recent one
ISO C++17 Standard (std:c++17)
and I get a random identifier instead.
AV<lambda_f65614ace4683bbc78b79ad57f781b7f>##
I'm still curious how this identifier is chosen though.
I know source insight can show multilayer function relationship in one window.
For example, we have four functions as below
void example_A()
{
example_B();
}
void example_B()
{
example_C();
}
void example_C()
{
example_D();
}
void example_D();
{
return 5;
}
When I click example_D() in source insight, source insight show example_C() is calling the function.
Moreover, when I click example_C(), I see example_B() is calling the function.
The relationship is like this:
Example_D()
|
-->Example_C()
|
-->Example_B()
|
-->Example_A()
Could I see the relationship in one window by using cscope in vim?
Thank you.
CCTRee plugin for vim does this kind of visualization using cscope
https://sites.google.com/site/vimcctree/
http://www.vim.org/scripts/script.php?script_id=2368
https://github.com/hari-rangarajan/CCTree
How can I add an event or other method to listen to keypresses on a gnome shell extension? e.g. show a dialog with each key press showing the pressed key?
I can not find any example. The documentation mentions a keyboard module, but with that common name searching is hard.
Class explanation
...
- General utils
- Keyboard: Manage and define the keyboard events, etc. for gnome shell.
(read above as a quote from the docs linked above. it is styled as code because the quote styling for some reason do not preserve line breaks in this site)
I found some extensions using the bellow code for results similar to what i'm asking, but i, again, failed to find docs for the specific classes and methods:
workViewInjections['_init'] = injectToFunction(WorkspacesView.WorkspacesView.prototype, '_init', function(width, height, x, y, workspaces) {
this._pickWorkspace = false;
this._pickWindow = false;
this._keyPressEventId = global.stage.connect('key-press-event', Lang.bind(this, this._onKeyPress));
this._keyReleaseEventId = global.stage.connect('key-release-event', Lang.bind(this, this._onKeyRelease));
connectedSignals.push({ obj: global.stage, id: this._keyPressEventId });
connectedSignals.push({ obj: global.stage, id: this._keyReleaseEventId });
});
Also, no class named keyboard anywhere there...
--
edit1: more searching... i think i may have to use the Clutter api. but again, not much examples or documentation for that. farthest i went was this
edit2: more searching. looking on the gnome shell source code, on the main ui tree, i think the answer is to use the barelly mentioned global object that is available to the extension code. e.g.
global.connect('key-press-event', function(if, i, know, the, signature){} );
I came across this snippet in gcampax's gtk-js-app template some time ago, which may be related to what you're doing:
// Due to limitations of gobject-introspection wrt GdkEvent and GdkEventKey,
// this needs to be a signal handler
this.connect('key-press-event', Lang.bind(this, this._handleKeyPress));
and
_handleKeyPress: function(self, event) {
return this.main_search_bar.handle_event(event);
},
I haven't had a need to use keyboard events yet, and this is Gtk in GJS, but the same limitation may be affecting gnome-shell extensions.
UPDATE
I've been doing some keybinding stuff lately, and if attaching a signal handler to the global object is working, you can do something like this:
global.display.connect("key-press-event", (widget, event, user_data) => {
let [success, keyval] = event.get_keyval(); // integer
let keyname = Gdk.keyval_name(keyval); // string keyname
if (keyname === "Control_L") {
// Dialog code or eg. this.keys_array.push("<Ctrl>");
}
});
There's also some Shell keybinding code here and some shell-global documentation here that might give you more clues. Wish I could help more but I'm wrestling my own GJS atm ;)
ADDENDUM
There is a good answer here with an example class with informative logging, as well as a speculative explanation. I've also found this functionality is exposed over DBus which might be more convenient in some cases:
Bus Name: org.gnome.Shell -> Path: /org/gnome/Shell -> Interface: org.gnome.Shell
Relevant Methods:
GrabAccelerator(String accelerator, UInt32 flags) -> (UInt32 action)
UngrabAccelerator(UInt32 action) -> (Boolean success)
Signal:
AcceleratorActivate(UInt32, Dict of {String, Variant})
For me global.stage.connect("key-press-event", _handleKeyPress) did the trick
I have developed a number of groovys used as plugins by Serviio.
Many of the methods used by these plugins are common, but when changes are made, each plugin needs to be updated. Therefore I want to "include" those methods in each plugin from a tools.groovy. I have tried 2 different approaches suggested in other posts.
I tried using
evaluate(new File("C:\\Program Files\\Serviio\\plugins\\tools.groovy"))
at the start of each plugin where tools.groovy just has
class Tools{method1{return}method2{return}}
but when executing the plugin I get
Caught: groovy.lang.MissingMethodException: No signature of method: Tools.main() is applicable for argument types: () values: []
If I then add
void main(args) { }
to class Tools, the error goes away but that Tools.main is run instead of the plugin.main and I get no output.
My second approach as suggested was to use
def script = new GroovyScriptEngine( '.' ).with {
loadScriptByName( 'C:\\Program Files\\Serviio\\plugins\\tools.groovy' )
}
this.metaClass.mixin script
This however gives the error
unexpected token: this # line 55, column 2.
this.metaClass.mixin script
Any suggestions on how to make either of these solutions work would be appreciated.
Did you try defining a common base script and giving it as a compiler configuration.
http://groovy.codehaus.org/Embedding+Groovy
From the groovy documentation...
class ScriptBaseTest {
#Test
void extend_groovy_script() {
def compiler = new CompilerConfiguration()
compiler.setScriptBaseClass("ScriptBaseTestScript")
def shell = new GroovyShell(this.class.classLoader, new Binding(), compiler)
assertEquals shell.evaluate("foo()"), "this is foo"
}
}
abstract class ScriptBaseTestScript extends Script {
def foo() {
"this is foo"
}
}
VERSION 1
class Doh {
private:
static std::map<const std::string, const Doh*> someMap;
std::string stringValue_;
public:
Doh(std::string str) : stringValue_(str) {
Doh::someMap.insert(
std::make_pair<const std::string,const Doh*>
(this->stringValue_,this)
);
}
}
The above was ok with MSVC 2010 but with MSVC 2008 it fails – and I guess it is because the object is not constructed yet when it is inserted in the map (I got a memory access violation).
So, I tried a delayed insertion, which worked:
VERSION 2
Doh(std::string str) : stringValue_(str) {
boost::thread(&Doh::insertIntoTheStaticMap,this);
}
void insertIntoTheStaticMap() {
boost::this_thread::sleep(boost::posix_time::milliseconds(1000));
Doh::someMap.insert(
std::make_pair<const std::string,const Doh*>
(this->stringValue_,this)
);
}
But as you might be able to guess, my intention is to have the static Doh::someMap as a common lookup dictionary.
VERSION 1 didn’t need any thread-safety because I would create all Doh instances in the same thread – in initialization blocks - which would be called by dynamic initializers before I enter main().
But with VERSION 2, the naïve sleep() is neither graceful nor reliable (not to mention, I might need to lock the map before insertion).
What would be a nice KISS approach?
Only potential issue I see is the initialization of the static member, if there are multiple source files. Try guarding it with a function.
class Doh {
private:
static std::map< std::string, Doh * > &get_map() {
static std::map< std::string, Doh * > someMap;
return someMap; // initialize upon first use
}
std::string stringValue_;
public:
Doh(std::string str) : stringValue_(str) {
get_map().insert(
std::make_pair
(this->stringValue_,this)
);
}
};
In neither version is there any sign of init for stringvalue_ - what does the debugger show you about this key when you hit the map insert in version 1 of the code? How is this field set up, and what is its type?
Running this in the debugger for VS2008 should allow you to narrow down the point of failure into the <map> source, I would have thought.