How we created a new product, removing 130 thousand lines of code from the old


    To begin with, about 15 years ago (in the early 2000s) we needed to create our own editor of text documents. Why mine? Yes, because not quite text documents and not a WYSIWYG editor at all. You will say that this is then not a document editor at all. But what then is a document editor? What features should it contain? And how did it occur to us to make such a bike? That's how...

    The origins


    Once upon a time, during the heyday of editors, ed, vi, em and other antiquities, there was a real need to edit text files. Basically, various configs and source code, and not documents at all in their modern sense. There were no Unicode encodings back then, and all the variety of text files was expressed, probably, only in the difference between cr + lf and simple lf as a line terminator. And then the text was really text, from 32 to the 127th character of the ASCII table and the upper half of the codes that could indicate different international characters (in each country its own). We just keep silent about mbcs encodings, because we are not talking about encodings, but about the documents themselves.

    And suddenly Apple appeared with its editors LisaWrite for Apple Lisa, released in 1983, and MacWrite for Apple Macintosh, released in 1984, which were already real WYSIWYG editors.

    To tell you the truth, WYSIWYG appeared 10 years earlier in the form of the Bravo editor developed in the notorious Xerox PARC for Alto computers, but these machines were never released to the mass market. And other home computers popular in the 1970s simply lacked the graphics capabilities needed to display documents in WYSIWYG mode.

    What did the WYSIWYG principle give to the world? People started working on computers with documents as if they were creating them on paper. We applied various formatting, alignment and styles of the text, inserted drawings, formulas and diagrams into the text, made tables and generally designed the document as they liked, since the WYSIWYG editor ensured that all this beauty was printed exactly as the document looks on on the screen (as far as accuracy is achievable here, this is a separate conversation, because the monitor and the printer have completely different dpi, but the WYSIWYG editor tries how it can bring the drawing of the document on the screen closer to what is then printed on paper).

    We will skip the whole long way of appearance and maturity of such editors as Windows Write, WordPad, Word (from Word 1.0 to Word 2016)

    Now we are used to the fact that when it comes to editing documents (not source files and configs, namely various office and other documents), then the WYSIWYG editor is simply necessary and you cannot live without it. But is that true? For example, your goal is to create some kind of documents of the same type based on forms. Or you keep some kind of large database of documents of the same type (for example, specific contracts or tenders). And here WYSIWYG will only interfere, allowing you to create some arbitrariness in the documents and adding formatting elements that are not supposed to be added to the document according to a previously agreed arrangement, because only the text is important. For example, you can agree that you can’t apply multi-column text, you can’t use footnotes in the text and footers, and you can’t apply over the text of the picture and 3D inscription.

    It was approximately the same in our case. But the situation was complicated by several more factors. In particular, in addition to the text itself, it was required to support specific markup of documents. And each element of this markup should have some kind of behavior. Approximately as if the [spoiler] element was able to collapse. And the [url] element was able to send us a link by click. Only such elements were not 2 or 3, but a couple of dozen. Each with his own behavior. And the documents themselves in this case were ordinary text, but in addition with pictures, formulas and tables. That is, in fact, we needed an editor that can, on top of a regular RTF document containing text, figures, tables, impose special markup and somehow work with it artfully.

    One could go here along the path of some specialized macros for Word, but
    a) it is not always at hand Ward, it is necessary to buy a license
    b) the emergence of new versions of MS Office can appear the problem of migration from one version Ward to another
    c) it would be desirable to be able to over the behavior is absolutely full control editor
    g) as has been written, WYSIWYG is in the way. We needed an editor to create documents that were completely identical in terms of the design capabilities used in them. Those. it was agreed in advance that all documents should contain text typed in such a font of a certain size, with such indentation, etc. Under such conditions, the functionality of setting the font size and type, flying over the text of labels, various indents and alignments, including, for example, multi-column text, would only interfere with users.

    Result


    No sooner said than done. Editor created. Over 15 years, about 45 person-years have been spent on developing the editor, as on average, 3 people were constantly working on the project at full time. The editor’s architecture turned out to be so specific and tailored for our tasks, and therefore this editor cannot be called a text editor in the general sense. And in this form it could be used only inside our company. Now the editor has definitely gone through the middle of his life cycle, has gained a certain architecture, filled with a large number of functions, and further work on it involves mainly refactoring and supporting the necessary changes.

    Reincarnation


    For a long time I was interested in the question whether our editor can somehow be brought out into a more open market. After all, so much time has been spent and so many useful things have been done that it is strange not to use at least some of them in some other project, for another purpose. Since many things were implemented in our editor regarding the general principles of working with documents, it was decided to try to remove everything specific from the project and leave only those functions that are inherent in a “regular” text editor. And see what happens.

    I want to warn in advance that all the functions of the editor, including rendering the document in the editing window, are implemented completely from scratch by our code. Those. it's not some RichEdit that just loads the text into. Miscalculating the position of paragraphs, dividing a paragraph into lines, drawing a caret, highlighting - all only by hand, only hardcore. Those. in principle, we can do anything with this editor.

    Without delaying things and not doubting too much, I called the new editor TexEd (from the phrase Text Editor). The code of the current editor was taken and everything that opens “our internal functions” outside (in the application interface) was removed from it. The code for implementing these functions has also been deleted if possible. Before the start of cutting functionality, the project code was 430 thousand lines of our code (1 million 300 thousand, if you count the code of the used third-party components).

    After discarding or hiding a specific functional, the code size was 297 thousand lines, i.e. about 1/3 of the project was dropped. Of course, it was possible to drop even more, but you can also clean the source from the legacy, because this "extra" unused code does not affect the appearance and work of the editor.

    A huge plus of the editor is that in fact it is a single exe-file and several text files with directories and settings. Not a couple of monstrous office suites.

    A large layer of functions contained various automatic processing (for example, the formation of a table of contents based on the analysis of the text, without taking into account the styles, the meaning of the text, identifying structural units, etc.), as well as checking the compliance of documents with certain design rules. But since these were our internal rules, not applicable to other users, this functionality was mainly cut out from the editor (if you return it, then in some new, revised form).

    The editor is not demanding on resources and can open 100-megabyte (or more) documents, including with tables, and pretty quick to work with them (which cannot be said about MS Office and Open Office, which can be hung on such documents, at least in page layout mode). The limitation on the volume of opened documents is that at the moment we only support 32-bit assembly, i.e. the application technically cannot allocate more than 4 GB of memory.

    What features remained in the editor?


    1) Support for formats:
    - RTF, WordML 2003 (XML), DOCX, HTML - native reading and writing (independently read and write the format in part of a subset of the supported design elements)
    - ODT - read through Open / Libre Office by converting it to one of the formats that we support natively
    - DOC - we read through the Word converter also by converting to one of the formats that we support natively. To do this, just install the free Office 2007 compatibility package (FileFormatConverters.exe), while MS Office itself is not required to be installed and is not necessary
    - TXD is its own binary editor format that supports all the same elements that we support in other formats. Why not? And as a clipboard format when copying pieces of documents inside our editor, it’s convenient.
    - XLS - somehow we read through Excel
    2) Support for editing documents containing:
    - Text
    - Tables (without nesting, when reading some formats, nested tables are simply embedded in a cell of a more external table, in RTF they are not supported at all)
    - Figures and formulas (for editing formulas, you need to install the MathType program , you can use the free trial version, it will work, but the set of formula elements will be limited)
    3) Printing documents (with the ability to preview)
    4) Comparing documents (File menu - Compare files) is a cool thing, because knows how to compare documents with tables; it's not Tortoise Diff for you! ;)
    5) Checking Russian and English spelling, including user dictionaries
    6) Search and replace
    7) Background auto-save documents
    8) highlighting words and substrings in words according to an arbitrary user guide and quick jumps to such highlighted words
    9) Insert templates of standard phrases from the panel tools (the user configures the phrases themselves)
    10) Record and play keyboard macros (sequences of keystrokes on the keyboard, not Visual Basic macros :))
    11) Several standard treatments, just as an example of what can be and how it works

    What else could be of interest in the editor, you ask? Yes, a lot of things. For example, when deleting huge (several hundred megabytes) chunks of large documents, the editor may warn that free RAM is running out (due to the formation of the Undo list for Ctrl + Z) and will go into memory saving mode, which will limit the number of actions in Undo -list. You must admit that this is an original and interesting opportunity, but someone saved a few nerve cells when editing such large documents on a machine with 1-2 GB of RAM. And this is just one example. Under the hood of the editor, there are quite a lot of interesting things that could be reintroduced into production if interested users were found. For instance, we have a full-fledged editor of pseudo-graphic tables (typed in a monospace font using pseudo-graphic characters), which allows you to work with tables such as ordinary dynamic Word tables, i.e. change the widths of rows and columns, set the alignment of text inside cells, etc., while the table remains pseudographic. In the days of DOS, the Word and Deed text editor (Word & Deed, wd.exe) knew how to do it. I disabled this functionality, because calculated that in 2017, users who have documents with pseudographic tables probably no longer exist or their percentage is very small. But if it is interesting and in demand by someone, you can turn it back on. set the alignment of the text inside the cells, etc., while the table remains pseudographic. In the days of DOS, the Word and Deed text editor (Word & Deed, wd.exe) knew how to do it. I disabled this functionality, because calculated that in 2017, users who have documents with pseudographic tables probably no longer exist or their percentage is very small. But if it is interesting and in demand by someone, you can turn it back on. set the alignment of the text inside the cells, etc., while the table remains pseudographic. In the days of DOS, the Word and Deed text editor (Word & Deed, wd.exe) knew how to do it. I disabled this functionality, because calculated that in 2017, users who have documents with pseudographic tables probably no longer exist or their percentage is very small. But if it is interesting and in demand by someone, you can turn it back on.

    You can see the rest yourself in the demo version.

    Editor Limitations


    There may be a large sheet, as depending on what to compare and what is considered a limitation, because the whole project is one big limitation, but this is good in certain cases.

    1) Only 32-bit version.
    2) Not cross-platform, works only under Windows.
    3) Few element formats are supported.
    4) The current version does not support the OOXML format (the new Office XML format starting in 2010).
    5) There is no WYSIWYG mode with the display of pagination (such a breakdown is visible only in the print preview).
    6) There is no font job. Absolutely. But it’s rather easy to add, because internally, the editor supports working with different fonts and displaying them on the screen.
    7) I confess, the editor’s icon was taken from a set of Linux icons from the designer Everaldo Coelho . If we redraw something later, there was simply no time for it.
    8) The editor is written in Delphi :-) At the moment, it is being built under the latest versions of Delphi (specifically in 10.1 Berlin, but it is possible in Tokyo too - no problems). And on what else was it to start writing such a Rich-GUI Windows Application in the early 2000s. It’s even a little fun, because the principle of security through obscurity there are few developers on Delphi now, i.e. for example, even if the source code is leaked, using them with benefit (for example, to create a competitor product or for some unfriendly purposes) will not be so simple :-)
    9) The editor alone cannot replace OpenOffice and MS Office as a whole, as It does not contain, for example, functions for working with tables (like Excel) or creating presentations (like PowerPoint).
    10) No documentation (user manual)

    You can download the fully functional (if this term is generally applicable in the current situation) demo version of the editor (0.1) from GitHub as an archive, which is enough to unpack it to any place. The editor at the first start with administrator rights installs the protection service, do not worry, this is not a virus and not a trojan, honestly, honestly. The service is needed to determine computer hardware parameters on which hash calculation for the registration key is based. Without this service, when starting the application under UAC (with the privileges of a regular user, i.e., not an administrator), it is not possible to get to the necessary equipment parameters, there are not enough rights.

    This version of the editor works without registration (without a key) until the end of 2017. I limited it purely for reasons “to be”, and not because I think that at the end of 2017 someone else will use this poorly functional first alpha version.

    Future


    Future plans:

    1) RTF (selection of arbitrary text fonts as in Word)
    2) multilingual interface (and spelling?)
    3) Normal list support (multi-level, etc.)
    4) Some kind of review mode support
    5) Task indent paragraphs and change column widths on the ruler
    6) WYSIWYG in edit mode (page by page)
    7) Native built-in formula editor, not tied to MathType
    8) From the editor, you can make a library of document processing from other applications using the Com Automation mechanism, similar to Word only much faster tray, easier and more convenient. This has already been implemented, but the API is still very poor, I will not give it so as not to bother anyone.

    What other features should I add to the product in the first place? Please write in the comments!

    Why all this? I sincerely hope that the project of such an editor can find very good use. Those. we are now looking for our new users to implement for them what they need. No, we do not plan to engage in custom development (to cut something for one specific customer, unless of course he is at the level of Beeline or Sberbank :-) Those. we want to make a new finished product that will be useful to a wide range of users thanks to convenient settings and specialized functions that are not available in conventional text editors.

    PS Since the cutting of functions was done in haste (it took about 10 days for 2-3 hours a day), somewhere, something could break, which we might not notice. You can create Issues on GitHub.

    → Temporary project home: GitHub

    UPD! We uploaded version 0.1.1 , which does not install and does not use the protection / registration service.

    You can delete an already installed service on the command line with the
    sc delete TexEdProtectService command
    and then delete the TexEdProtectService.exe file from the system32 directory of the Windows installation directory.

    And finally, a small poll:

    Only registered users can participate in the survey. Please come in.

    Is the project as a whole interesting?

    • 20.3% Yes, as a lightweight replacement for editors from bloated office suites 33
    • 3.7% Yes, as a cheap replacement for MS Word 6
    • 39.5% No, because already there are many analogues, including free (OpenOffice, LibreOffice, MyOffice, OnlyOffice) 64
    • 4.9% No, because few features supported (too disparate replacement for Word) 8
    • 29% No, because just a meaningless project, don't waste your time 47
    • 2.4% Other (I will write in the comments) 4

    What is the fair value of the described future product?

    • 75.5% Free 130
    • 4% 100-500 rubles for 1 workplace per year 7
    • 2.9% 500-1000 rubles for 1 workplace per year 5
    • 0% 1000-2000 rubles for 1 workplace per year 0
    • 2.9% 2000-3000 rubles for 1 workplace per year 5
    • 6.3% 100-500 rubles for 1 workplace forever (without subscription payment system) 11
    • 2.9% 500-1000 rubles for 1 workplace forever (without subscription payment system) 5
    • 2.3% 1000-2000 rubles per 1 workplace forever (without a subscription payment system) 4
    • 0.5% 2000-3000 rubles for 1 workplace forever (without subscription payment system) 1
    • 2.3% Other (I will write in the comments) 4

    Also popular now: