dail8859 / NotepadNext

A cross-platform, reimplementation of Notepad++
GNU General Public License v3.0
8.69k stars 527 forks source link

有对记事本做计算器感兴趣的吗?Is anyone here interested in Notepad as a calculator? #485

Closed lededev closed 6 months ago

lededev commented 7 months ago

我刚开发完成这个功能,如果本项目接受这个功能,我可以提交PR。notepad3已经内置这个功能有几年了,自从用了它,我再没打开过系统的计算器。但它是单窗口无tab编辑器。我有时还是需要有tab支持同时打开多个文件的。 相比于普通计算器,正文计算的优势在于过程和计算结果不会主动消失,除非你删除它,很像传统的草稿纸,方便往前寻找计算过程。而且Ctrl+s可随时保存你的计算公式和结果,在数字旁边加上文字备注也很顺手,这些优点都足以淘汰掉系统计算器。此外它还避免了两个软件间的来回切换和复制粘贴。 I have just finished developing this feature. If this project accepts this feature, I can submit a PR. Notepad3 has had this feature built in for several years. Since using it, I have never opened the system's calculator. But it is a single-window tab-less editor. Sometimes I still need tabs to support opening multiple files at the same time. The advantage of text calculation is that the process and calculation results will not disappear automatically unless you delete it, much like a traditional scratch paper, making it easier to find the calculation process. Moreover, Ctrl+s can save your calculation formulas and results at any time, and it is very convenient to add text notes next to the numbers. These advantages are enough to eliminate the system default calculator. In addition, it avoids switching back and forth between the two software and copy-pasting. PRdemo0

dail8859 commented 7 months ago

Though I'm not completely against the functionality I personally don't see a need for it within Notepad Next. I'm assuming this would require a 3rd party library and/or other significant amounts of code that would require maintenance.

lededev commented 7 months ago

Notepad for take note, note include numbers, numbers need to be calculated. Therefore, Notepad naturally needs calculation feature, which is a natural combination. Calculating and saving results directly in Notepad instead of using third-party software to copy and paste is the most efficient and convenient way for users who use Notepad. Because as long as the user wants to save the calculation results, he must need an editor, not a GUI calculator. I have already port this feture to NotepadNext, code modified not too much. Of course, these are only the core function codes, which are 90% complete. The user interface menu items have not been added yet (used to turn off functions and set calculation accuracy). Thanks to the author of tinyexpr++, his library has completed all the calculation work. I only need to pass the string to be calculated to tinyexpr++, and then get a double type result. However, the time expression calculation was implemented by me, because tinyexpr++ only provides mathematical calculations, otherwise it would take less than 100 lines of core code. I think this is a small commit, but it's a new feature. As far as I know, currently only notepad3 has this function.

git diff --numstat
6       3       src/NotepadNext/NotepadNext.pro
267     0       src/NotepadNext/ScintillaNext.cpp
11      0       src/NotepadNext/ScintillaNext.h

And tinyexpr++ only one .cpp file and one .h file,2260 lines, Zlib license.

find src/tinyexpr-plusplus/ -maxdepth 1 -name "tinyexpr*" -exec wc -l {} \;
1410 src/tinyexpr-plusplus/tinyexpr.cpp
850 src/tinyexpr-plusplus/tinyexpr.h

nne

dail8859 commented 7 months ago

Notepad for take note, note include numbers, numbers need to be calculated. Therefore, Notepad naturally needs calculation feature, which is a natural combination.

I completely disagree with this reasoning...but that's beside the point.

Thanks to the author of tinyexpr++, his library has completed all the calculation work.

This actually makes me much more at ease to see a small and well supported library that can handle all the needed functionality. Since you already have the code in a semi-working state I'd be interested in taking a look at the pull request.

As long as the changes to the application itself are reasonable and can be enabled/disabled then it would be something I'd be willing to consider.

lededev commented 7 months ago

I'm done, please review. The reason why I didn't commit the GUI part at the beginning was that it would be easy for the commit to swell to thousands of lines (including updates to the i18n translation). Content submission is step-by-step

cuixiping commented 6 months ago

This feature is more suitable as a plugin.

dail8859 commented 6 months ago

I agree this functionality is not quite fit for the core Notepad Next application code base. It is quite specific and would only be useful to a small number of users, and I would be unwilling to maintain this.

If Notepad Next did have support for plugins in the future that would be best.