home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DOS/V Power Report 1998 January (DVD)
/
VPR980100.ISO
/
OLS
/
WIN32
/
MM95370
/
MM95370.LZH
/
DANRAKU.MAC
< prev
next >
Wrap
Text File
|
1996-05-17
|
2KB
|
75 lines
// [禁則処理付き段落整形マクロ]
// danraku.mac
//
// 1段落(改行まで)を整形します。
// インデント(字下げ)および行頭・行末禁則文字の処理を行います。
// 段落の最初が2個以上(n個)の全角スペースで始まるとき、2行目以後の
// 行頭は自動的に n-1 字分インデントされます。
// 整形終了後、カーソル位置は次の段落の先頭へ移動します。
// 1行の長さを変える場合は xwide の値(現在は64)を変更して下さい。
//
main()
{
char *ps, *pe;
int n, num, xwide, sIns, sInd;
// 行頭禁則文字を指定します
ps=" 、。,.:;!?)]}」-、。,.:;!?)〕]}〉》」』】’”";
// 行末禁則文字を指定します
pe="([{「(〔[{〈《「『【‘“";
xwide = 64; // 1行の長さ
sIns = Ins;
sInd = Indent;
InsMode(1);
AIndent(0);
num = 0;
LEdge();
if(Code == 0x8140) // 段落の最初が全角スペースなら
{
while(Code == 0x8140) // 全角スペースの連続数を数える
{
++num;
Right();
}
LEdge();
}
while(1)
{
KbHit();
if(Result == 0x1b) // [ESC]が押されたら中断
break;
GotoX(xwide + 1);
if(Tcode == 1) // 整形終了で、カーソル位置は次の段落の先頭へ
{
while(Tcode == 1)
Right();
break;
}
else
{
Left();
StrChr(Code, pe); // 行末禁則文字をチェック
if(Result == -1)
{
Right();
StrChr(Code, ps); // 行頭禁則文字をチェック
if(Result != -1)
Right();
}
Ret();
if(num > 1) // 行頭を n-1 字分インデント
{
n = num;
while(n > 1)
{
PutChr(0x8140);
--n;
}
}
}
}
InsMode(sIns);
AIndent(sInd);
}