1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

秀丸エディタで、矩形選択範囲を罫線で囲む秀丸マクロ

Last updated at Posted at 2018-05-28

作ったきっかけ

秀丸で文章を書いている時、罫線で文字を囲いたい時があったので作成してみた。
┌────┐
│こんな │
│イメージ│
└────┘┌──────┐
      │じゃけんのー│
      └──────┘

矩形選択のやり方

ctrl + マウスで選択

秀丸マクロの中身

$topc = str(seltopcolumn);
$endc = str(selendcolumn);

$topline = str(seltoplineno);
$endline = str(selendlineno);

# free_switch = 0;

if(selecting){
	if((seltoplineno > 1)&(seltopcolumn >1)){
	escape;
	#line = val($topline);

//┌─┐を追加:開始******************

if(!freecursor){
	#free_switch = 1;//もしカーソルモードがオフならスイッチオン
	freecursorswitch;
}
moveto val($topc)-2,#line-2;
overwrite "┌";

# i = val($topc);

while(#i < val($endc)){
	overwrite "─";
	#i = #i+2;
}
overwrite "┐";

//┌─┐を追加:終了******************

while(#line < val($endline)+1){
movetolineno val($endc)+1,#line;
overwrite "│";

movetolineno val($topc),#line;
overwrite "│";
# line = #line+1;
}

//└─┘を追加:開始******************
moveto val($topc)-2,#line-1;
overwrite "└";

# i = val($topc);

while(#i < val($endc)){
overwrite "─";
# i = #i+2;
}
overwrite "┘";
//┌─┐を追加:終了******************


//フリーカーソルモードをもとに戻す
if(#free_switch == 1){
freecursorswitch;
}

}else{escape "2文字目以上、2行目以上を選択して下さい";}
}else{
message "文字選択をして下さい";
}

作成サンプル

┌─────┐
│秀丸マクロ│
│で矩形選択│
└─────┘

           ┌───────┐
           │よろしく   │
           │おねがいします│
           └───────┘

注意点

  • 矩形選択の最終行がEOF【 End Of File 】 だと矩形罫線が崩壊します。(涙)
  • 半角スペースができます。私は以下マクロで2半角空白を1全角空白にしています。
replaceallfast "  "," ";

参考本

  • 秀丸マクロ ポケットリファレンス
  • 著者:西沢 直木
  • POCKET REFERENCE社
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?