NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
Wrap text


Joined: 08 Mar 2006
Posts: 63
Reply with quote
It would be great if PHPEd could get a wrap text command that inserts physical line breaks at appropriate places.

The way this usually works is that it inserts real line breaks in a text block to adjust the line length to the current right margin, and keeping the current left indent of the first line in the block. If a comment is wrapped, then any leading comment characters should be kept. What is regarded as a text block could be the current selection, or the block containing the cursor and delimited by double new lines, or delimited by an enclosing XML/HTML block level tag. The last one might be tricky to implement, though.
View user's profileFind all posts by svenaxSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8350
Reply with quote
physical line breaks may screw your scripts/html content completely. Did you know that for example line breaks after <img> tag may add space in the rendered results and it's certainly what you'll not expect.
Editor does it job by formatting text on the fly and show you wrapped lines while it's up to you to change the text.
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 08 Mar 2006
Posts: 63
Reply with quote
ddmitrie wrote:
physical line breaks may screw your scripts/html content completely. Did you know that for example line breaks after <img> tag may add space in the rendered results and it's certainly what you'll not expect.
Editor does it job by formatting text on the fly and show you wrapped lines while it's up to you to change the text.

Yes, I know that. It would mainly be used to wrap pure text blocks and comment blocks in code. I don't like soft line breaks personally. This kind of wrapping would be used to re-adjust such text blocks after editing has changed the line lengths. It is available in other editors and I find it very useful. Now, if PHPEd had a proper scripting interface, I could probably implement it myself Smile
View user's profileFind all posts by svenaxSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8350
Reply with quote
I'm not sure what kind of soft or hard breaks you're talking about. PhpED for sure does never insert any of them Smile Its wrap engine is between source code and painting context and does wrap on the fly without modifying anything.
I agree that with a scripted editor you could do what you want to do, but it might slowdown everything. Is it an adequite price for this feature? Are you going to process whole the text when a little bit of it has changed?
To me a kind of formatter that could be called with a shortcut does look better and it's what you can do right now. See howto-use-a-php-script-for-my-editing-t753.html for the details
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 08 Mar 2006
Posts: 63
Reply with quote
ddmitrie wrote:
I'm not sure what kind of soft or hard breaks you're talking about. PhpED for sure does never insert any of them Smile Its wrap engine is between source code and painting context and does wrap on the fly without modifying anything.

Yes, yes, thats what I mean by soft line breaks. Wrap to window or whatever you want to call it.
Quote:
I agree that with a scripted editor you could do what you want to do, but it might slowdown everything. Is it an adequite price for this feature? Are you going to process whole the text when a little bit of it has changed?

I think you misunderstand - I don't mean the editor should do this dynamically. It should be a command that can be invoked by the user when needed. I know Emacs has a special mode where it will do this on-the-fly, but that is a bit dodgy.
Quote:
To me a kind of formatter that could be called with a shortcut does look better and it's what you can do right now. See howto-use-a-php-script-for-my-editing-t753.html for the details

Well, that is exactly what I mean. Only that there is no way to extend the selection to the current text block in the way I described in the OP without a real scripting API. But it is certainly possible to write a script that works on the selection as it is now. Perhaps not in PHP, though. I'll have a look at what can be done.
View user's profileFind all posts by svenaxSend private message


Joined: 08 Mar 2006
Posts: 63
Reply with quote
I just tested to make a PHP script working on the current selection as described in the FAQ linked from the previous post.

I have some issued with that though. I'm using PHP5. Here's a minimal test script:
Code:
<?php
$text = str_replace("\0", '', file_get_contents('php://stdin'));
echo $text;
?>

This doesn't work though. The str_replace is there because the text has a strange encoding with every character separated by a NUL-character. It isn't proper UTF16 though. The length of the text is just half of what it should be so only half of the text is echoed back. I am not sure if this is PHPEd or PHP acting up, but whatever it is, it makes it impossible to write this kind of scripts.
View user's profileFind all posts by svenaxSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8350
Reply with quote
Ok, seems like we have an issue there. It should be UTF-8, nothing else.
View user's profileFind all posts by dmitriSend private messageVisit poster's website
Site Admin

Joined: 13 Jul 2003
Posts: 8350
Reply with quote
it's fixed in build 4512 (will come soon)
View user's profileFind all posts by dmitriSend private messageVisit poster's website
Wrap text
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic