By default, Bugzilla does not search the list of RESOLVED bugs.
You can force it to do so by putting the upper-case word ALL in front of your search query, e.g.: ALL tdelibs
We recommend searching for bugs this way, as you may discover that your bug has already been resolved and fixed in a later release.
Bug 2421 - Add word count feature to kate/kwrite
Summary: Add word count feature to kate/kwrite
Status: NEW
Alias: None
Product: TDE
Classification: Unclassified
Component: tdebase (show other bugs)
Version: R14.0.x [Trinity]
Hardware: Other Linux
: P5 enhancement
Assignee: Timothy Pearson
URL:
Depends on:
Blocks: 2969
  Show dependency treegraph
 
Reported: 2015-04-12 12:04 CDT by Darrell
Modified: 2023-02-02 00:04 CST (History)
3 users (show)

See Also:
Compiler Version:
TDE Version String:
Application Version:
Application Name:


Attachments
Proposed pseudo code for word count (8.29 KB, application/gzipped-tar)
2015-04-30 15:55 CDT, Darrell
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Darrell 2015-04-12 12:04:44 CDT
Kate/kwrite does not have this basic feature.

A look around the web indicates some work-arounds but this should be a basic text editor feature. Using wc would be straightforward.

The feature should be able to detect when text is selected. The resulting dialog should display the following:

* Whether the results are for selected text or the entire document.
* The number of lines (wc -l).
* The number of words (wc -w).
* The number of characters (wc -m).
Comment 1 Darrell 2015-04-30 15:55:56 CDT
Created attachment 2494 [details]
Proposed pseudo code for word count

Attached are two C files from the geany IDE/editor, tools.h and tools.c. There are two functions in tools.c that likely could be massaged into C++, starting at line 799, word_count and tools_word_count.

The KDE folks added a Kate word count feature to the status bar, but I prefer the geany interface, which is invoked only when the user requests and provides more information.
Comment 2 Michele Calgaro 2015-05-02 03:36:23 CDT
I have been "away" for a while and will probably be for a couple of months more, but I also think this is a good enhancement to be made.
We could also consider making a plugin for Kate that provides this functionality, unless one already exists.
Comment 3 Darrell 2023-02-02 00:04:14 CST
I write daily and (sorely) need a word count feature in Kate/KWrite. I would like to help resolve this bug report. Until then I am posting information I have found in case others want to proceed. Please feel free to contact me if I can help.

Kate and KWrite share common katepart code and Katepart plugins, but there are other TDE software that make use of Katepart elements. Any solution pursued here probably will have to be tested in any software using Katepart elements.

Also of note is not all people want or need this feature. To many people word count is a fundamental feature of any text editing environment, but the feature should nonetheless be optional.

Three solutions seem optimal:

* Display the information in the status bar.
* Provide a Tools menu option.
* Provide the feature through a Katepart plugin (tdelibs and not a Kate plugin in tdeaddons).

All three methods keep the feature optional.

The first solution requires a Settings check box to enable/disable. When enabled the information would always be available at a glance.

The second and third solution would make the feature available to any TDE software using Katepart code. The information would be available only upon request. The information would be displayed through a dialog box. This is the method I conceived originally with my code attachments from the Geany text editor.

The KDE version of Kate has this feature built into the status bar. The feature is enabled in Settings. Line count and word count are two separate Settings options. The word count feature includes the character count. As might be expected this is super convenient, not in the way, and available at a glance. I do not know if this built-in feature uses the wc command underneath.

While a Tools menu and dialog approach would be acceptable, I would rather have the information at a glance in the status bar (I have since changed my mind about my original Geany-like proposal in Comment #1). Perhaps the GPL code from Plasma Kate/Kwrite could be studied/borrowed and massaged into TDE.

**Other comments:**

Because of TDE roots in KDE 3.5.10, searching the web for pre Plasma day discussions find some work-arounds for Kate. These solutions include kdialog and dcop scripts along with the Kate External Tools feature.

I found two places with a kdialog solution:

* https://www.linuxquestions.org/questions/linux-software-2/word-count-on-Kate-824163/
* https://bugs.kde.org/show_bug.cgi?id=65740

What about the wc command? This is the method used in Geany. This method could be adapted to Kate/KWrite as a Katepart element or plugin.

Using the Kate TextFilter plugin (tdeaddons) to directly pass text to the wc command overwrites the selected text and pastes the wc results (line/words/characters). Messy and disruptive. Possibly this method could be scripted and launched from External Tools. I think this method requires an underlying JavaScript script. Refer to $TDEDIR/share/apps/Katepart/scripts/sort.js for an example.

The caveat with this approach is this bug report would not be resolved with an External Tools solution because External Tools are not supported in KWrite.

Kate and KWrite share access to Katepart plugins. A robust kdialog command script would be a nice short-term solution for Kate and beginning point. Conceptually such a script should be straightforward to convert to a C++ plugin by an experienced coder, which is the format needed for Katepart plugins.

In the end though the solution should be part of the Katepart system and be available to all TDE tools using those elements.