#!/usr/bin/python #snippet plugin import juci_to_python_api as juci, inspect def initPlugin(): juci.addMenuElement("Snippet") juci.addSubMenuElement("SnippetMenu", #name of parent menu "Insert snippet", #menu description "insertSnippet()", #function to execute inspect.getfile(inspect.currentframe()), #plugin path "space") snippets = {} snippets["for"] = """\ for(int i=0; i int main(int argc, char *argv[]) { std::cout << "Hello, world!" << std::endl; } """ snippets["fore"] = """\ for (auto i : v) { //std::cout << i << std::endl; } """ snippets["funca"] = """\ auto functionName(arg) { // Write code here return n; } """ snippets["lambdaa"] = """\ auto lambda = []() { //code here }; """ snippets["jucifor"] = """\ #include #include int main(int argc, char *argv[]) { //Example under from this line to +4 std::vector v = {"Hello!", "This is juCi++"}; for (auto& i : v) { std::cout << i << std::endl; } return 0; } """ snippets["switch"] = """\ switch (arg) { case 1: //some code //recommended to use break or return on only one possible outcome default: //some code } """ snippets["cout"] = """\ std::cout << "example"; """ snippets["coute"] = """\ std::cout << "example" << std::endl; """ def getSnippet(word): try: output = snippets[word] except KeyError: output = word return output def insertSnippet(): theWord=juci.getWord() output=getSnippet(theWord) juci.replaceWord(output)