Don't want to use notepad++, use notepad-- to replace

I believe that more and more people have realized the hatefulness of the author of notepad++. I used to be a user of notepad++. When I saw that its author, a Taiwanese, blatantly used the software to promote his wrong views, I felt that I should do something.

Notepad++ is just a small software, not complicated, and does not support mac and linux platforms. I use an editor almost every day, so why don't I make one myself? By the way, make a cross-platform version. Since his name is notepad++, then I will call it notepad--, to reduce some erroneous remarks and self-righteousness, referred to as ndd. I believe that there are a lot of domestic counterparts who can make this kind of similar small software. But it happens that big companies look down on them, and small companies have no technology, so let me do it.

notepad++ has simple functions and can only be used on windows. It does not support linux and mac platforms, and based on political reasons, if the author of notepad++ continues to die like this, it will be a matter of time before notepad++ will be removed from the shelves in China. At present, there have been a lot of speeches on the Internet, all of which are against the use of notepad++. But the author of notepad++ is still going his own way. He thinks that no one in mainland China can cure it. Although everyone hates it, there is no similar software that can replace it.

In the process of writing the comparison software ccompare, I found that its core function already has the prototype of a text editor. It only takes a little extra effort to become a simple text editor that can basically replace notepad++.

 

 So just do it. After some research, I found that notepad is actually just an outer package, and inside it is scintilla, the core control of the famous open source editor. Therefore, the level of the author of notepad++ is actually far from reaching the height of his self-righteousness. As long as the domestic 996 environment is liberated and programmers are given better personal time, it is conceivable that a large number of excellent free software will emerge in China.

I believe that at least 10% of programmers in China have the ability to write operating systems, compilers, and editors. But everyone was overwhelmed by 996 and a few taels of silver. Only by freeing programmers and freeing them from low-level manual work can China's basic software see hope.

However, it is basically impossible to replace the notepad++ market in a short time. At present, domestic application software, such as text editors, parsers, and compilers, not to mention operating systems, are almost all controlled by foreign countries. I think as an old programmer, although the technology may have been eliminated by the trend, but in terms of the underlying infrastructure, there is still some waste heat that can be used. It is planned to release and maintain the same kind of software that replaces Notepad++ -- notepad -- on the domestic uos system.

As for whether there is a market, whether it will be successful, and whether it can convert the market effect, then leave it to time.


ndd open source address: ndd: notepad-- is a domestic cross-platform, simple text editor, an option to replace notepad++. Its built-in powerful code comparison function allows you to lose the paid beyond compare. (gitee.com)

Let's paste some code to avoid being considered an inefficient article.

int main(int argc, char *argv[])
{
	QApplication a(argc, argv);

	QDir::setCurrent(QCoreApplication::applicationDirPath());

#ifdef Q_OS_UNIX
    QApplication::setStyle(QStyleFactory::create("fusion"));
#endif
	a.setApplicationDisplayName(c_strTitle);
	a.setApplicationName(c_strTitle);
	
	QStringList arguments = QCoreApplication::arguments();
#ifdef Q_OS_WIN
	QSharedMemory shared("CCNotebook");
#endif
	if (shared.attach())//共享内存被占用则直接返回
	{
		//发现在文件中如果存在空格时,参数不止1个,所以不能单纯用2个参数表示
		if (arguments.size() > 1)
		{
        #ifdef Q_OS_WIN

			qlonglong hwndId;
			shared.lock();
			memcpy(&hwndId, shared.data(), sizeof(qlonglong));
			shared.unlock();

			HWND hwnd = (HWND)hwndId;
			if (::IsWindow(hwnd))
			{
				//去掉第一个参数,后续的参数拼接起来。其实参数中间有空格还是需要使用""引用起来,避免空格参数分隔为多个
				arguments.takeFirst();

				QString filename = arguments.join("");
				QByteArray data = filename.toUtf8();

				COPYDATASTRUCT copydata;
				copydata.dwData = CUSTOM_TYPE; //自定义类型
				copydata.lpData = data.data();  //数据大小
				copydata.cbData = data.size();  // 指向数据的指针

				::SendMessage(hwnd, WM_COPYDATA, reinterpret_cast<WPARAM>(nullptr), reinterpret_cast<LPARAM>(&copydata));
			}
        #else
            pid_t pid;

            arguments.takeFirst();
            QString filename = arguments.join("");
            QByteArray data = filename.toUtf8();

            nppShared.attach();
            nppShared.lock();
            memcpy(&pid, nppShared.data(), sizeof(pid_t));
            memset((char*)nppShared.data()+sizeof(pid_t),0, 1024-sizeof(pid_t));
            memcpy((char*)nppShared.data()+sizeof(pid_t),data.data(),data.size());
            nppShared.unlock();

            kill(pid,SIGUSR1);
			#endif
		}
		else if (arguments.size() == 1)
		{
#ifdef Q_OS_WIN
			//把窗口设置到最前
			qlonglong hwndId;
			shared.lock();
			memcpy(&hwndId, shared.data(), sizeof(qlonglong));
			shared.unlock();
			HWND hwnd = (HWND)hwndId;
			if (::IsWindow(hwnd))
			{
				QString filename("open");
				QByteArray data = filename.toUtf8();

				COPYDATASTRUCT copydata;
				copydata.dwData = OPEN_NOTEPAD_TYPE; //自定义类型
				copydata.lpData = data.data();  //数据大小
				copydata.cbData = data.size();  // 指向数据的指针

				::SendMessage(hwnd, WM_COPYDATA, reinterpret_cast<WPARAM>(nullptr), reinterpret_cast<LPARAM>(&copydata));
			}
#else
            pid_t pid;
            nppShared.attach();
            nppShared.lock();
            memcpy(&pid, nppShared.data(), sizeof(pid_t));
            memset((char*)nppShared.data()+sizeof(pid_t),0, 1024-sizeof(pid_t));
            nppShared.unlock();
            qDebug()<<"empty file send";
            kill(pid,SIGUSR1);
#endif
		}
		return 0;
	}
#ifdef Q_OS_WIN
	shared.create(32);
#else
    shared.create(32);
    nppShared.create(2048);

    if(signal(SIGUSR1,sig_usr) == SIG_ERR)
    {
       qDebug()<<"linux create sign failed";
    }
#endif

	QFile file(":/mystyle.qss"); //qss文件路径
	QString styleSheet;
	if (file.open(QIODevice::Text | QIODevice::ReadOnly))
	{
		styleSheet = file.readAll();
		qApp->setStyleSheet(styleSheet);
	}
	file.close();

	CCNotePad *pMainNotepad = new CCNotePad(true);
	pMainNotepad->setAttribute(Qt::WA_DeleteOnClose);
	pMainNotepad->setShareMem(&shared);
	pMainNotepad->show();

	QThread *workThread = new QThread(&a);
	//QObject::connect(workThread, &QThread::finished, workThread, &QObject::deleteLater);
	workThread->start();

	//这里不能给parent,否则会导致父子对象不在同一个线程的错误
	NetRegister *pNetReg = new NetRegister(nullptr);
	pNetReg->moveToThread(workThread);

	QStatusBar *pStatusBar = pMainNotepad->statusBar();
	QObject::connect(pNetReg, &NetRegister::showMessage, pStatusBar, &QStatusBar::showMessage);
	QObject::connect(pNetReg, &NetRegister::signToLicenceServer, pNetReg, &NetRegister::slot_ToLicenceServer); 
	QObject::connect(pNetReg, &NetRegister::signMsg, pMainNotepad, &CCNotePad::slot_donate);
	//下面槽函数会在workThread删除的时候执行
	QObject::connect(workThread, &QThread::finished, pNetReg, &NetRegister::quit);
	//注意下面函数会在新线程中执行
	emit pNetReg->signToLicenceServer();


#ifdef Q_OS_WIN
	//HWND hwnd = ::FindWindowA("Qt5QWindowIcon", "CCNotebook");
	//发现hwnd就是和effectiveWinId相等的,不需要查询了
	qlonglong winId = (qlonglong)pMainNotepad->effectiveWinId();

	shared.lock();
	memcpy(shared.data(), &winId, sizeof(qlonglong));
	shared.unlock();
#else
    qlonglong winId = (qlonglong)pMainNotepad->effectiveWinId();
    shared.lock();
    memcpy(shared.data(), &winId, sizeof(qlonglong));
    shared.unlock();
    nppShared.attach();
    //get proceess id to share memory
    pid_t pid = getpid();
    nppShared.lock();
    memcpy(nppShared.data(), &pid, sizeof(pid_t));
    nppShared.unlock();
#endif // Q_OS_WIN

	if (arguments.size() == 2)
	{
		pMainNotepad->openFile(arguments[1]);
        pMainNotepad->showNormal();
	}
	else
	{
		pMainNotepad->initTabNewOne();
	}

	a.exec();

	//结束进程
	workThread->quit();
	workThread->wait();
	delete workThread;

	return 0;
}

ndd open source address:

ndd: notepad-- is a domestic cross-platform, simple text editor, an option to replace notepad++. Its built-in powerful code comparison function allows you to lose the paid beyond compare. (gitee.com)

Guess you like

Origin blog.csdn.net/peterbig/article/details/125970175