Browse Source

added snippets and forgie's createproject plugin

master
oyvang 11 years ago
parent
commit
a0d2cd7490
  1. 11
      Projects/newtestProject/CMakeLists.txt
  2. 47
      juci/plugins/createproject.py
  3. 50
      juci/plugins/snippet.py
  4. 9
      juci/terminal.cc

11
Projects/newtestProject/CMakeLists.txt

@ -0,0 +1,11 @@
cmake_minimum_required (VERSION 2.8.4)
set(project_name newtestproject)
project (${project_name})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
INCLUDE(FindPkgConfig)
add_executable(main
main.cpp
)

47
juci/plugins/createproject.py

@ -0,0 +1,47 @@
#!/usr/bin/python
#snippet plugin
import juci_to_python_api as juci, inspect
import sys, os
def initPlugin():
juci.addMenuElement("CreateProject")
juci.addSubMenuElement("CreateProjectMenu", #name of parent menu
"Create new project", #menu description
"newProject()", #function to execute
inspect.getfile(inspect.currentframe()), #plugin path
"<control><alt>p")
def newProject():
path='../Projects/newtestProject/'
if not os.path.exists(path):
os.makedirs(path)
cmake=path+'CMakeLists.txt'
main=path+'main.cpp'
cmakefile = open(cmake, 'w')
cmakefile.write("""\
cmake_minimum_required (VERSION 2.8.4)
set(project_name newtestproject)
project (${project_name})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
INCLUDE(FindPkgConfig)
add_executable(main
main.cpp
)
""")
mainfile = open(main, 'w')
mainfile.write("""\
#include <iostream>
int main(int argc, char *argv[]) {
std::cout << "Hello, world!" << std::endl;
}
""")

50
juci/plugins/snippet.py

@ -48,10 +48,58 @@ snippets["hello"] = """\
#include <iostream>
int main(int argc, char *argv[]) {
std::cout << "Hello, world! << std::endl;
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 <iostream>
#include <vector>
int main(int argc, char *argv[]) {
//Example under from this line to +4
std::vector<std::string> 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]

9
juci/terminal.cc

@ -85,14 +85,11 @@ void Terminal::Controller::ExecuteCommand(std::string command, std::string mode)
command = folder_command_+command;
DEBUG("Terminal: PrintMessage: Running command");
FILE* p = NULL;
std::cout << command << std::endl;
p = popen(command.c_str(), mode.c_str());
std::cout << "KJØRTE FINT!" << std::endl;
if (p == NULL) {
p = popen(command.c_str(), mode.c_str());
if (p == NULL) {
PrintMessage("juCi++ ERROR: Failed to run command" + command + "\n");
}else {
std::cout << "SKRIVER UT KOMMANDO RESULAT" << std::endl;
char buffer[1028];
char buffer[1028];
while (fgets(buffer, 1028, p) != NULL) {
PrintMessage(buffer);
}

Loading…
Cancel
Save