포럼: マクロ掲示板 (Thread #42719)

マクロでの自動インデント判定 (2020-07-30 16:01 by あやきょん #85457)

現在マクロを作っているところなのですが、サクラエディタ本体で自動インデントの設定がONなのかOFFなのかを判定する方法はありませんでしょうか?

自動インデントがONならばインデント分を排除して、OFFならばインデント分含めて文字列を配置したいと考えております。

アドバイス宜しくお願い致します。

Reply to #85457×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login

Re: マクロでの自動インデント判定 (2020-08-01 00:44 by berryzplus #85476)

Reply To Message #85457
> 現在マクロを作っているところなのですが、サクラエディタ本体で自動インデントの設定がONなのかOFFなのかを判定する方法はありませんでしょうか?

ざっと見た感じ、なさそうです。

マクロ用に取得関数を追加するか、タイプ別設定を設定ファイルか読むか、いずれかになると思います。

なお、オートインデントは「1文字入力」コマンドで「改行文字」を入れた場合のみに働く機能です。
発動条件を回避するようにマクロを組めば、考慮しなくてもいいんじゃね?というのは邪悪な発想かも知れませんが。
Reply to #85457

Reply to #85476×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login

Re: マクロでの自動インデント判定 (2020-08-02 22:41 by あやきょん #85487)

メッセージ #85476 への返信
> Reply To Message #85457

> ざっと見た感じ、なさそうです。
あぁ…。やっぱりないんですね。

> なお、オートインデントは「1文字入力」コマンドで「改行文字」を入れた場合のみに働く機能です。
> 発動条件を回避するようにマクロを組めば、考慮しなくてもいいんじゃね?というのは邪悪な発想かも知れませんが。
実は作っているマクロが「リスト文字自動入力マクロ」でして…。
リスト用マーク(●■★など)やリスト数字(1.1.など)を自動的に入力しちゃおうと試みたマクロです。
一応完成はしたんですが、オートインデント機能を設定しちゃっている場合にはその分だけ余分にタブや空白が入っちゃうので、それを回避する方法がないかなぁ…と思った次第です。

> マクロ用に取得関数を追加するか、タイプ別設定を設定ファイルか読むか、いずれかになると思います。
ふむ…。なるほど。その辺も考慮して考えてみるしかなぁ。
Reply to #85476

Reply to #85487×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login

Re: マクロでの自動インデント判定 (2020-08-03 06:25 by noname #85489)

メッセージ #85487 への返信
> リスト用マーク(●■★など)やリスト数字(1.1.など)を自動的に入力しちゃおうと試みたマクロです。
> 一応完成はしたんですが、オートインデント機能を設定しちゃっている場合にはその分だけ余分にタブや空白が入っちゃうので、それを回避する方法がないかなぁ…と思った次第です。

行頭の空白部分を選択状態にして InsText() 等はどうでしょうか?
SetDrawSwitch() 使えば見た目上のチラつきも抑えれそうな気がします。
Reply to #85487

Reply to #85489×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login

Re: マクロでの自動インデント判定 (2020-09-07 18:03 by あや 改め朱桜 #85722)

メッセージ #85489 への返信

お返事遅くなってすみません。

> 行頭の空白部分を選択状態にして InsText() 等はどうでしょうか?
> SetDrawSwitch() 使えば見た目上のチラつきも抑えれそうな気がします。
オートインデントのタブ挿入はマクロでのInsText()後に挿入されている感じ?

一応参考までに作成したマクロをコピペしておきます。

-----以下マクロになります-----
//リスト自動入力
// 2020/07/10 by.朱桜花鈴

// 現在行が以下の構文を含む場合、改行して行頭に開始記号を追加する
// (順序ありリストの場合は数値を1加算する)
//
// 順序なしリスト: '-','-','+','・','・','*','*','■','□'
// 順序あり数字リスト: '1.','2.'... 全角/半角対応
// 順序あり英字リスト: 'a.','b.'... 大文字/小文字対応
// カッコつき英数字: '(x)','(y)'
//
// マクロの文字コードはSJISかUTF-8BOM付き(UTF-8として読み込まれる)で保存
//
// Shift+Enterに登録して使用

// リスト用記号
var reg = /^([\t  ]*)(?:([((]*)([a-zA-Z]+|[0-9]+|[0-9]+)([)).. ]+)|([--+・・**■□]))/;

// 現在行の内容を取得
var s = Editor.GetLineStr(0);
// 指定構文を取得
var s_syntax = reg.exec(s);

// まずは改行
Editor.Char(13);
// 指定構文があれば処理開始
if(s_syntax != null){
// 配列[0]:一致文字列
// 配列[1]:インデント
// 配列[2]:始括弧
// 配列[3]:英数字
// 配列[4]:閉括弧またはコンマ&半角スペース
// 配列[5]:リスト記号

// 英数字の処理
if(s_syntax[3]){
if(s_syntax[3] == '9'){
s_syntax[3] = 10;
}else if(s_syntax[3] > 8){
s_syntax[3] = Number(s_syntax[3]);
s_syntax[3]++;
}else{
var i = (s_syntax[3] == "z" || s_syntax[3] == "Z")? -25 : 1;
s_syntax[3] = String.fromCharCode(s_syntax[3].charCodeAt(s_syntax[3].length - 1) + i);
}
}

// 一致文字列[0]を削除
s_syntax.shift();
// 配列を文字列に変換して出力
Editor.InsText(s_syntax.join(''));
}
Reply to #85489

Reply to #85722×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login

Re: マクロでの自動インデント判定 (2020-09-07 18:06 by あや 改め 朱桜 #85728)

うわっ!

すみません。何故か凄まじい連投になっちゃってます。
削除の仕方が分かりません。

申し訳ございませんが、不要レスの削除処理をお願い致します。m(__)m
Reply to #85722

Reply to #85728×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login

Re: マクロでの自動インデント判定 (2020-09-07 18:03 by あや 改め朱桜 #85726)

メッセージ #85489 への返信

お返事遅くなってすみません。

> 行頭の空白部分を選択状態にして InsText() 等はどうでしょうか?
> SetDrawSwitch() 使えば見た目上のチラつきも抑えれそうな気がします。
オートインデントのタブ挿入はマクロでのInsText()後に挿入されている感じ?

一応参考までに作成したマクロをコピペしておきます。

-----以下マクロになります-----
//リスト自動入力
// 2020/07/10 by.朱桜花鈴

// 現在行が以下の構文を含む場合、改行して行頭に開始記号を追加する
// (順序ありリストの場合は数値を1加算する)
//
// 順序なしリスト: '-','-','+','・','・','*','*','■','□'
// 順序あり数字リスト: '1.','2.'... 全角/半角対応
// 順序あり英字リスト: 'a.','b.'... 大文字/小文字対応
// カッコつき英数字: '(x)','(y)'
//
// マクロの文字コードはSJISかUTF-8BOM付き(UTF-8として読み込まれる)で保存
//
// Shift+Enterに登録して使用

// リスト用記号
var reg = /^([\t  ]*)(?:([((]*)([a-zA-Z]+|[0-9]+|[0-9]+)([)).. ]+)|([--+・・**■□]))/;

// 現在行の内容を取得
var s = Editor.GetLineStr(0);
// 指定構文を取得
var s_syntax = reg.exec(s);

// まずは改行
Editor.Char(13);
// 指定構文があれば処理開始
if(s_syntax != null){
// 配列[0]:一致文字列
// 配列[1]:インデント
// 配列[2]:始括弧
// 配列[3]:英数字
// 配列[4]:閉括弧またはコンマ&半角スペース
// 配列[5]:リスト記号

// 英数字の処理
if(s_syntax[3]){
if(s_syntax[3] == '9'){
s_syntax[3] = 10;
}else if(s_syntax[3] > 8){
s_syntax[3] = Number(s_syntax[3]);
s_syntax[3]++;
}else{
var i = (s_syntax[3] == "z" || s_syntax[3] == "Z")? -25 : 1;
s_syntax[3] = String.fromCharCode(s_syntax[3].charCodeAt(s_syntax[3].length - 1) + i);
}
}

// 一致文字列[0]を削除
s_syntax.shift();
// 配列を文字列に変換して出力
Editor.InsText(s_syntax.join(''));
}
Reply to #85489

Reply to #85726×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login

Re: マクロでの自動インデント判定 (2020-09-12 01:43 by AC #85784)

#85476 に書いてあるのはこういうことだと思います。

> // まずは改行
> Editor.Char(13);

これだとオートインデントが発動するので、代わりに他のマクロを使う。

例えば> Editor.InsText(["\r\n","\r","\n"][Editor.GetLineCode()]);
Reply to #85726

Reply to #85784×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login

Re: マクロでの自動インデント判定 (2020-09-12 18:55 by あや 改め 朱桜 #85791)

メッセージ #85784 への返信
> #85476 に書いてあるのはこういうことだと思います。
>
> > // まずは改行
> > Editor.Char(13);
>
> これだとオートインデントが発動するので、代わりに他のマクロを使う。
>
> 例えば> Editor.InsText(["\r\n","\r","\n"][Editor.GetLineCode()]);

あぁっ!
ホントだ。ちゃんと機能しました。

そっか。代わりのマクロを使用すれば良かったのか。
またしてもACさん。助言ありがとうございました!

追伸:
#85728でも書いてるんですが、なぜか連投になっちゃって、非常に見苦しいスレッドになってしまいました。
連投になってしまったレスを削除したいのですが、その方法が分からず放置となってしまっています。
管理されている方、またはレスの削除が可能な方がいらっしゃいましたら、どうか処理の方よろしくお願い致します。
m(_ _)m
Reply to #85784

Reply to #85791×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login

Re: マクロでの自動インデント判定 (2020-09-12 22:50 by ds14050 #85794)

メッセージを削除すると返信ごと削除されるようだったので返信のないもののみ削除しておきました。
Reply to #85791

Reply to #85794×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login