⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 scriptwriter.cpp

📁 用java 编写的源码开放的文本编辑器。有很多有用的特性
💻 CPP
📖 第 1 页 / 共 2 页
字号:
		hres = psl->QueryInterface(IID_IPersistFile, (LPVOID *)&ppf);		if (SUCCEEDED(hres))		{			WORD wsz[MAX_PATH];		    MultiByteToWideChar(CP_ACP, 0, path, -1, wsz, MAX_PATH);		    hres = ppf->Load(wsz, STGM_READ);			if (SUCCEEDED(hres))			{//				LauncherLog::Log(Debug, "[launcher] IPersistFile::Load call succeeded.\n");				hres = psl->Resolve(0, SLR_ANY_MATCH | SLR_NO_UI);				if (SUCCEEDED(hres))				{//					LauncherLog::Log(Debug,//						"[launcher] IShellLink::Resolve call succeeded.\n");					WIN32_FIND_DATA wfd;					char szgotpath[MAX_PATH];					ZeroMemory(szgotpath, MAX_PATH);				    hres = psl->GetPath(szgotpath, MAX_PATH,						&wfd, SLGP_SHORTPATH);					if(SUCCEEDED(hres))					{//						LauncherLog::Log(Debug,//							"[launcher] IShellLink::GetPath() call succeeded; resolved path is %s\n",//							((szgotpath == 0 || strlen(szgotpath) == 0)//								? "<zero-length string>." : szgotpath));						if(szgotpath != 0 && strlen(szgotpath) != 0)							strcpy(outPath, szgotpath);					}					else					{						LauncherLog::Log(Error,							"[launcher] IShellLink::GetPath() call failed. Error code: 0x%08x\n",							hres);					}				}				else				{					LauncherLog::Log(Error,						"[launcher] IShellLink::Resolve() call failed. Error code: 0x%08x\n",						hres);				}			}			else			{//				LauncherLog::Log(Debug,//					"[launcher] IPersistFile::Load() call failed. Error code: 0x%08x\n",//					hres);			}			ppf->Release();		}		else		{			LauncherLog::Log(Error,				"[launcher] Could not get pointer to IPersistFile object. Error code: 0x%08x\n",				hres);		}		psl->Release();	}	else	{		LauncherLog::Log(Error,			"[launcher] Could not get pointer to IShellLink object. Error code: 0x%08x\n",			hres);	}	if(!SUCCEEDED(hres))	{		strcpy(outPath, path);	}	return hres;}void ScriptWriter::AppendPath(const char* path){	if(path == 0) return;	const char* s = path;	char *d = pBuffer + strlen(pBuffer);	*d++ = '\"';	while(*s != 0)	{		if(*s == '\\')			*d++ = '\\';		*d++ = *s++;	}	*d++ = '\"';	*d = 0;}void ScriptWriter::Append(const char* source){	strcat(pBuffer, source);}// Implementation of class OpenFileScriptOpenFileScript::OpenFileScript()	: ScriptWriter(), m_nFiles(0){	InitBuffer(0x2000);}OpenFileScript::~OpenFileScript() {}HRESULT OpenFileScript::WritePrefix(){//	LauncherLog::Log(Debug,"[launcher] Calling OpenFileScript::WritePrefix()\n");	ClearBuffer();	Append("v = new java.util.Vector(8); ");	return S_OK;}HRESULT OpenFileScript::ProcessSinglePath(const char* pszPath){//	LauncherLog::Log(Debug,//		"[launcher] Calling OpenFileScript::ProcessSinglePath() with char parameter %s\n",//		pszPath);	if(m_nFiles < 128)	{		Append("v.addElement(");		AppendPath(pszPath);		Append("); ");		++m_nFiles;	}	return S_OK;}HRESULT OpenFileScript::WriteSuffix(){//	LauncherLog::Log(Debug,"[launcher] Calling OpenFileScript::WriteSuffix()\n");	if(m_nFiles == 0)	{		ClearBuffer();		Append("Macros.error(jEdit.getFirstView(), ");		Append("\"No files met the supplied wild-card specification.\");");	}	else	{		Append("s = v.size(); args = new String[s]; v.copyInto(args); ");		Append("EditServer.handleClient(true, null, args); ");		Append("jEdit.openFile(jEdit.getLastView(), args[s - 1]);\n\n");	}	return S_OK;}// Implementation of class OpenDiffScript/*	Here is the script written by this object:	It will work with jDiff version written for	jEdit 3.2.2 and jEdit 4.0 // ----- prefix ----- 	v = jEdit.getFirstView();	jDiff40 = false;	if(jEdit.getPlugin("JDiffPlugin") == null) {		jDiff40 = true;	}	if(jEdit.getPlugin("jdiff.JDiffPlugin") == null) {		Macros.error(v, "You must have the JDiff plugin "        	+ "installed to use this jEditLauncher feature.");			return;	}	if(jDiff40) {		if(jdiff.DualDiff.isEnabledFor(v))			jdiff.DualDiff.toggleFor(v);	}	else if(DualDiff.isEnabledFor(v))		DualDiff.toggleFor(v);	while(v.getEditPanes().length > 1)		v.unsplit();	v.splitVertically();	if(jDiff40)		jdiff.DualDiff.toggleFor(v);	else		DualDiff.toggleFor(v);	openDiffFiles(vv) {		v = vv;		run() {			buf1 = // ----- file 1 -----				jEdit.openFile(v, "<file 1>");			buf2 = // ----- file 2 -----			jEdit.openFile(v, "<file 2>"); // ----- suffix -----			VFSManager.waitForRequests();			editPanes = v.getEditPanes();			editPanes[0].setBuffer(buf1);			editPanes[1].setBuffer(buf2);		}		return this;	}	SwingUtilities.invokeLater(openDiffFiles(v));*/OpenDiffScript::OpenDiffScript()	: ScriptWriter(), secondFile(false){	InitBuffer(1024);}OpenDiffScript::~OpenDiffScript() {}HRESULT OpenDiffScript::WritePrefix(){	ClearBuffer();	Append("v = jEdit.getFirstView(); ");	Append("jDiff40 = false;");	Append("if(jEdit.getPlugin(\"JDiffPlugin\") == null) {jDiff40 = true;} ");	Append("if(jEdit.getPlugin(\"jdiff.JDiffPlugin\") == null) { ");	Append("Macros.error(v, \"You must have the JDiff plugin ");	Append("installed to use this jEditLauncher feature.\"); return; } ");	Append("if(jDiff40) { if(jdiff.DualDiff.isEnabledFor(v)) ");	Append("jdiff.DualDiff.toggleFor(v); } ");	Append("else if(DualDiff.isEnabledFor(v)) DualDiff.toggleFor(v); ");	Append("while(v.getEditPanes().length > 1) v.unsplit(); ");	Append("v.splitVertically(); ");	Append("if(jDiff40) jdiff.DualDiff.toggleFor(v); else ");	Append("DualDiff.toggleFor(v); openDiffFiles(vv) { v = vv; run() { buf1 = ");	return S_OK;}HRESULT OpenDiffScript::ProcessSinglePath(const char* pszPath){	Append("jEdit.openFile(v, ");	AppendPath(pszPath);	Append("); ");	if(!secondFile)	{		Append("buf2 = ");		secondFile = true;	}	return S_OK;}HRESULT OpenDiffScript::WriteSuffix(){	Append("VFSManager.waitForRequests(); editPanes = v.getEditPanes(); ");	Append("editPanes[0].setBuffer(buf1); ");	Append("editPanes[1].setBuffer(buf2); } return this; } ");	Append("SwingUtilities.invokeLater(openDiffFiles(v));");	return S_OK;}// Implementation of class StartAppScriptStartAppScript::StartAppScript(LPCTSTR lpszCmdLine)	: ScriptWriter(), bFirstFile(true), m_lpszCmdLine(lpszCmdLine){	InitBuffer(2048);}StartAppScript::~StartAppScript() {}HRESULT StartAppScript::WritePrefix(){	ClearBuffer();	Append(m_lpszCmdLine);	return S_OK;}HRESULT StartAppScript::ProcessSinglePath(const char* pszPath){	if(bFirstFile)	{		Append("-- ");		bFirstFile = false;	}	AppendPath(pszPath);	Append(" ");	return S_OK;}HRESULT StartAppScript::WriteSuffix(){	bFirstFile = true;		// reset	return S_OK;}// Implementation of class FileListScriptFileListScript::FileListScript()	: ScriptWriter(){	InitBuffer(1024);}FileListScript::~FileListScript() {}HRESULT FileListScript::WritePrefix(){	ClearBuffer();	Append("-- ");	return S_OK;}HRESULT FileListScript::ProcessSinglePath(const char* pszPath){	AppendPath(pszPath);	Append(" ");	return S_OK;}HRESULT FileListScript::WriteSuffix(){	return S_OK;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -