Javascript 如何在WT中保存Ace编辑器中的所有文本?
因此,我在WT项目中嵌入了一个Ace编辑器,并将Ace.js文件的副本加载到其中作为测试,以查看它的外观。加载进行得很顺利,所以现在我尝试保存它,我注意到没有调用我的save函数。在调试了一段时间后,我注意到,如果试图保存的文件大于70000-80000个字符,则不会调用save函数,如果文件较小,则会调用fine并传递数据。在尝试保存大型文件时,如何绕过此限制?下面可以看到我在WT项目中运行的代码,以及如何在这里嵌入它的更多细节Javascript 如何在WT中保存Ace编辑器中的所有文本?,javascript,c++,html,ace-editor,wt,Javascript,C++,Html,Ace Editor,Wt,因此,我在WT项目中嵌入了一个Ace编辑器,并将Ace.js文件的副本加载到其中作为测试,以查看它的外观。加载进行得很顺利,所以现在我尝试保存它,我注意到没有调用我的save函数。在调试了一段时间后,我注意到,如果试图保存的文件大于70000-80000个字符,则不会调用save函数,如果文件较小,则会调用fine并传递数据。在尝试保存大型文件时,如何绕过此限制?下面可以看到我在WT项目中运行的代码,以及如何在这里嵌入它的更多细节 如前所述,我加载了Ace.js,长度约为15000行。这导致我的
如前所述,我加载了Ace.js,长度约为15000行。这导致我的save调用失败。尽管我确信任何其他超过80000个字符的文件也会导致它失败。提前谢谢你 可能需要增加wt_config.xml中的最大请求大小。默认值为128K。我当前没有在项目中使用wt_config.xml,我将尝试添加它并设置最大请求大小。
WText *editor;
MyClass::MyClass(const WEnvironment& env)
: WApplication(env)
{
wApp->require("lib/src/ace.js");
// A WContainerWidget is rendered as a div
editor = new WText("function(){\n hello.abc();\n}\n", root());
editor->setInline(false);
editor->resize(500, 500);
std::string editor_ref = editor->jsRef(); // is a text string that will be the element when executed in JS
std::string command =
editor_ref + ".editor = ace.edit(" + editor_ref + ");" +
editor_ref + ".editor.setTheme(\"ace/theme/monokai\");" +
editor_ref + ".editor.getSession().setMode(\"ace/mode/javascript\");";
editor->doJavaScript(command);
JSignal <std::string> *jsignal = new JSignal<std::string>(editor, "textChanged");
jsignal->connect(this, &MyClass::textChanged);
WPushButton *b = new WPushButton("Save", root());
command = "function(object, event) {" +
jsignal->createCall(editor_ref + ".editor.getValue()") +
";}";
b->clicked().connect(command);
}
void MyClass::textChanged(std::string incoming)
{
}
std::string MyClass::ReadFile(std::string path)
{
std::ifstream in(path, std::ios::in | std::ios::binary);
if(in)
{
std::string contents;
in.seekg(0, std::ios::end);
contents.resize(in.tellg());
in.seekg(0, std::ios::beg);
in.read(&contents[0], contents.size());
in.close();
return(contents);
}
throw(errno);
}