Summary: | "Join lines" should maintain one-line separation between paragraphs | ||
---|---|---|---|
Product: | [Applications] kate | Reporter: | Shriramana Sharma <samjnaa> |
Component: | general | Assignee: | KWrite Developers <kwrite-bugs-null> |
Status: | RESOLVED FIXED | ||
Severity: | normal | ||
Priority: | NOR | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | unspecified | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: | |||
Attachments: |
python script that unwraps lines
Prototype Katescript for Unwrap |
Description
Shriramana Sharma
2006-04-07 10:32:15 UTC
It does, what it is supposed to do: It joins the lines. Your report is not entirely clear: Do you mean join lines from a selected text? Well let me rephrase my request. I believe what the Join Lines facility actually needs to do is "unwrap" -- opposite of the Word Wrap facility. Take the following example: ------------------------------ SAMPLE A ------------------------------ Hello. My name is Shriramana Sharma. I use KDE 3.52. It is an excellent desktop environment. I have been using KDE ever since I started using Linux. ------------------------------ The above text when wrapped becomes: ------------------------------ SAMPLE B ------------------------------ Hello. My name is Shriramana Sharma. I use KDE 3.52. It is an excellent desktop environment. I have been using KDE ever since I started using Linux. ------------------------------ Now what I want the Join Lines facility to do is give me back the original text (Sample A) above, and not the following: ------------------------------ SAMPLE C ------------------------------ Hello. My name is Shriramana Sharma. I use KDE 3.52. It is an excellent desktop environment. I have been using KDE ever since I started using Linux. ------------------------------ As it is, the Join Lines facility when applied to Sample B gives Sample C as the output and not Sample A. I do not believe that anyone would need the entire text in a word-wrapped document rolled up into one big ball, as the current Join Lines facility does. Whenever people have a blank line between two sets of word-wrapped lines (as in Sample B) it means that they are two different paragraphs. As such, joining the lines, which is conceptually the opposite of word-wrapping the lines, should maintain this separation of the paragraphs by providing Sample A as the output and not Sample C. If you think that people do have need for a Join All Lines Together facility that rolls up all the lines into one paragraph (see Sample C) then make it an additional facility. But Join Lines, to my mind, is another way of saying "Unwrap Lines", and should provide Sample A as its output and not Sample C. I hope that makes things clearer. P.S: Perhaps I should have labeled this a wishlist item instead of a bug? Well I, for one, think that the "Join Lines" command should join lines, and that's what it does. For "unwrapping" text in this manner, you would be much better off using "Filter Text" command to pipe your text to a little bit of Perl, or whatever you prefer, to edit the text as you wish. On Friday 07 April 2006 14:45, Shriramana Sharma wrote:
> Well let me rephrase my request. I believe what the Join Lines facility
> actually needs to do is "unwrap" -- opposite of the Word Wrap facility
Why???? Join lines is supposed to 'join lines', not 'unwrap'. What you
describe is a different action as I see it.
On Friday 07 April 2006 17:48, Ryan Dalzell wrote:
> For "unwrapping" text in this manner, you would be much better off using
> "Filter Text" command to pipe your text to a little bit of Perl, or
> whatever you prefer, to edit the text as you wish.
... or you could write a javascript to do it
Yes, please write a "unwrap" script in javascript. Information can be found here http://drupal.kate-editor.org/article/scripting_katepart_with_javascript and when you are finish, you can attach it to this wish. -- Thanks! ;) Right, I agree that Join Lines is a different thing from unwrap. However, I do not have the programming knowledge to write Javascript plugins or anything like that. That is why I request the knowledgeable programmers to do that. From what little programming knowledge I have, I presume one could just change the Join Lines code to identify wherever two newlines are continuous and not replace them with a space. I downloaded the kdebase and kdeaddons packages for 3.52, but I am unable to identify where the Join Lines utility is. I may be able, even with my minimal knowledge, to adapt that code to implement the Unwrap feature -- provided it is not too difficult for me. Please tell me where to find the Join Lines code. A text search among the two packages for "join lines" did not help. Thanks. Hello. It's over a year since my last comment but no reply. Please if anyone tells me where the code for Join Lines and Word Wrap functions is, I may look into creating an unwrap function. I find searching the KDE sources via websvn a trying experience. file: kdelibs/kate/part/katedocument.cpp look for: void KateDocument::joinLines( uint first, uint last ) Created attachment 21778 [details]
python script that unwraps lines
This is a script I wrote in Python for unwrapping lines. It works. Now that the
algorithm is there (and in public domain) someone with better KDE/Qt/C++
knowledge than I can adapt it as appropriate.
Hello it is again over a year since my last post and KDE 4.2 has been released. I presume that with the presence of the Kross scripting framework, Python can now be used to script KDE applications, so since my JavaScript knowledge is insufficient can someone integrate this script into KWrite? Thanks for your good work! I really am proud to use KDE 4.2. Hello it is three years since my opening this wish, about two years since my providing the algorithm and six months since my ping. Can we please see this facility added to Katepart? I don't know Javascript else I would write it in Javascript. So I wrote it in Python. Please implement this feature. http://docs.kde.org/development/en/kdesdk/kate/advanced-editing-tools-scripting.html A script called rewrap-paragraph or reformat-paragraph would be nice for KDE 4.4. Created attachment 39147 [details]
Prototype Katescript for Unwrap
Here's a prototype Katescript. The basic logic is there, but I am unable to test it on my system for whatever reason because even reload-scripts does not work at the F7 commandline. Only some scripts like cleanindent, uncomment etc work. (My distro is Kubuntu Karmic Koala.)
Since I'm travelling from tomorrow, I'll be unable to access the net for some days, so I'm posting it as it is FWIW. Please take it and finetune it.
BTW my previous Python script actually has some bugs. I haven't bothereed to correct them yet (and you aren't going to use it anyway for Kate).
SVN commit 1091040 by dhaumann: new command: unwrap Invoke on command line (F7) with: unwrap Current behaviour: - unwrap all text blocks in text selection - if no selection, unwrap paragraph under cursor - never remove empty lines Multiple empty lines in a row are not removed. Should that be changed, i.e., should multiple empty lines in a row be merged to a single empty line? BUG: 125104 M +64 -1 utils.js WebSVN link: http://websvn.kde.org/?view=rev&revision=1091040 Hey thanks! A long-standing wish fulfilled. Great job! And as to your question: No, multiple sequential empty lines should NOT be merged to a single empty line. This script must only do the opposite of what the wrap script does and the wrap script does NOT create multiple empty lines. Further, users may have provided two (or more) empty lines between paragraphs for readability or whatever reason and this script must not change that. |