edit - What's wrong with this SlickEdit macro? - Stack Overflow

What's wrong with this macro. It only performs the operation on the first line.#include "sli

What's wrong with this macro. It only performs the operation on the first line.

#include "slick.sh"

_command format_HTML() name_info(','VSARG2_MACRO|VSARG2_MARK|VSARG2_REQUIRES_MDI_EDITORCTL)
{
   _macro('R',1);

   top_of_buffer()
   while ( !down() ) {
        begin_line()
        last_event(name2event('<'));html_lt();
        keyin("p");
        last_event(name2event('>'));html_gt();
        last_event(name2event(' '));html_space();
        end_line();
        last_event(name2event(' '));html_space();
        last_event(name2event('<'));html_lt();
        keyin('/');
        keyin("p");
        last_event(name2event('>'));html_gt();
   }
}

This code is to format regular text into HTML paragraphs, however it only works on the first line.

What's wrong with this macro. It only performs the operation on the first line.

#include "slick.sh"

_command format_HTML() name_info(','VSARG2_MACRO|VSARG2_MARK|VSARG2_REQUIRES_MDI_EDITORCTL)
{
   _macro('R',1);

   top_of_buffer()
   while ( !down() ) {
        begin_line()
        last_event(name2event('<'));html_lt();
        keyin("p");
        last_event(name2event('>'));html_gt();
        last_event(name2event(' '));html_space();
        end_line();
        last_event(name2event(' '));html_space();
        last_event(name2event('<'));html_lt();
        keyin('/');
        keyin("p");
        last_event(name2event('>'));html_gt();
   }
}

This code is to format regular text into HTML paragraphs, however it only works on the first line.

Share Improve this question edited Apr 10 at 15:27 Ley CM 176 bronze badges asked Dec 31, 2024 at 5:53 WaylandWayland 112 bronze badges 1
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Bot Commented Dec 31, 2024 at 15:47
Add a comment  | 

1 Answer 1

Reset to default 0

The issue with your macro is that the while (!down()) loop condition will exit after the first line because down() returns 0 when it successfully moves to the next line (and your loop continues while !down() is true, i.e., while moving down fails).

#include "slick.sh"

_command void format_HTML() name_info(','VSARG2_MACRO|VSARG2_MARK|VSARG2_REQUIRES_MDI_EDITORCTL)
{
    _macro('R',1);
    
    top_of_buffer();
    while (1) {
        begin_line();
        last_event(name2event('<')); html_lt();
        keyin("p");
        last_event(name2event('>')); html_gt();
        last_event(name2event(' ')); html_space();
        
        // Move to end of line
        end_line();
        
        last_event(name2event(' ')); html_space();
        last_event(name2event('<')); html_lt();
        keyin('/');
        keyin("p");
        last_event(name2event('>')); html_gt();
        
        // Try to move down
        if (down()) break;
    }
}

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745410839a4626525.html

相关推荐

  • edit - What&#39;s wrong with this SlickEdit macro? - Stack Overflow

    What's wrong with this macro. It only performs the operation on the first line.#include "sli

    4小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信