Skip to content

Commit d569a38

Browse files
authored
Snippets (#82)
* Fixed LUA simple expression in snippets.json * Added update_display_data_code for cpp * Added input prompt for C++
1 parent b3c08be commit d569a38

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

snippets/snippets.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,13 @@
128128
"incomplete_code": "int foo(",
129129
"complete_code": "int x = 1;",
130130
"syntax_error": "int int;",
131-
"input_prompt": "// C++ kernel stdin varies",
131+
"input_prompt": "#include <iostream>\n#include <string>\nstd::string name;\nstd::cin >> name;",
132132
"sleep_code": "#include <thread>\n#include <chrono>\nstd::this_thread::sleep_for(std::chrono::seconds(2));",
133133
"completion_var": "test_variable_for_completion",
134134
"completion_setup": "int test_variable_for_completion = 42;",
135135
"completion_prefix": "test_variable_for_",
136136
"display_data_code": "#include <string>\n#include \"xcpp/xdisplay.hpp\"\n\nstruct html_content {\n std::string content;\n};\n\n#include \"nlohmann/json.hpp\"\nnlohmann::json mime_bundle_repr(const html_content& h) {\n auto bundle = nlohmann::json::object();\n bundle[\"text/html\"] = h.content;\n return bundle;\n}\n\nhtml_content h{\"<b>bold</b>\"};\nxcpp::display(h);",
137-
"update_display_data_code": "// xeus-cling update_display_data requires display_id handling",
137+
"update_display_data_code": "#include <string>\n#include \"xcpp/xdisplay.hpp\"\n#include \"nlohmann/json.hpp\"\nnamespace nl = nlohmann;\nnamespace ht\n{\nstruct html\n{\ninline html(const std::string& content)\n{\nm_content = content;\n}\nstd::string m_content;\n};\nnl::json mime_bundle_repr(const html& a)\n{\nauto bundle = nl::json::object();\nbundle[\"text/html\"] = a.m_content;\nreturn bundle;\n}\n}\nht::html rect(R\"(\n<div style='\n width: 90px;\n height: 50px;\n line-height: 50px;\n background-color: blue;\n color: white;\n text-align: center;'>\nOriginal\n</div>)\");\nxcpp::display(rect, \"some_display_id\");\nrect.m_content = R\"(\n<div style='\n width: 90px;\n height: 50px;\n line-height: 50px;\n background-color: red;\n color: white;\n text-align: center;'>\nUpdated\n</div>)\";xcpp::display(rect, \"some_display_id\", true);",
138138
"rich_execute_result_code": "// C++ uses display_data for rich output"
139139
},
140140
"sql": {
@@ -157,7 +157,7 @@
157157
"lua": {
158158
"print_hello": "print('hello')",
159159
"print_stderr": "io.stderr:write('error\\n')",
160-
"simple_expr": "return 1 + 1",
160+
"simple_expr": "1 + 1",
161161
"simple_expr_result": "2",
162162
"incomplete_code": "function foo(",
163163
"complete_code": "x = 1",

0 commit comments

Comments
 (0)