前回のGeanyのタブ文字の表示変更の続き。
寝る時間を削って、やっと全角スペースの可視化に成功したので、ソース載っけてみました。
ついでにタブの表示もちょこっと変更。(最後のドットが表示されないみたいなので。)
geany-0.18.1/scintilla/Editor.cxx
1750行目あたりのDrawTabArrow関数
void DrawTabArrow(Surface *surface, PRectangle rcTab, int ymid) {
// ### Update Start タブの表示方法変更
// int ydiff = (rcTab.bottom - rcTab.top) / 2;
// int xhead = rcTab.right - 1 - ydiff;
// if (xhead <= rcTab.left) {
// ydiff -= rcTab.left - xhead - 1;
// xhead = rcTab.left - 1;
// }
// if ((rcTab.left + 2) < (rcTab.right - 1))
// surface->MoveTo(rcTab.left + 2, ymid);
// else
// surface->MoveTo(rcTab.right - 1, ymid);
// surface->LineTo(rcTab.right - 1, ymid);
// surface->LineTo(xhead, ymid - ydiff);
// surface->MoveTo(rcTab.right - 1, ymid);
// surface->LineTo(xhead, ymid + ydiff);
surface->MoveTo(rcTab.left , ymid);
surface->LineTo(rcTab.left + 2, ymid - 2);
surface->LineTo(rcTab.left + 5, ymid + 1);
// ### Update End タブの表示方法変更
}
void Editor::DrawLine 関数の2600行目あたり
// Foreground drawing loop
の下の方を追加。
} else if (IsControlCharacter(ll->chars[i])) {
// Control character display
inIndentation = false;
if (controlCharSymbol < 32) {
// ### Add Start 制御文字の色変更
if (vsDraw.whitespaceForegroundSet)
textFore = vsDraw.whitespaceForeground.allocated;
surface->PenColour(textFore);
// ### Add End 制御文字の色変更
// Draw the character
const char *ctrlChar = ControlCharacterString(ll->chars[i]);
DrawTextBlob(surface, vsDraw, rcSegment, ctrlChar, textBack, textFore, twoPhaseDraw);
} else {
char cc[2] = { static_cast<char>(controlCharSymbol), '\0' };
surface->DrawTextNoClip(rcSegment, ctrlCharsFont,
rcSegment.top + vsDraw.maxAscent,
cc, 1, textBack, textFore);
}
} else if ((i == startseg) && (static_cast<unsigned char>(ll->chars[i]) >= 0x80) && IsUnicodeMode()) {
char hexits[3];
sprintf(hexits, "%2X", ll->chars[i] & 0xff);
DrawTextBlob(surface, vsDraw, rcSegment, hexits, textBack, textFore, twoPhaseDraw);
} else {
// Normal text display
if (vsDraw.styles[styleMain].visible) {
if (twoPhaseDraw) {
surface->DrawTextTransparent(rcSegment, textFont,
rcSegment.top + vsDraw.maxAscent, ll->chars + startseg,
i - startseg + 1, textFore);
} else {
surface->DrawTextNoClip(rcSegment, textFont,
rcSegment.top + vsDraw.maxAscent, ll->chars + startseg,
i - startseg + 1, textFore, textBack);
}
}
if (vsDraw.viewWhitespace != wsInvisible ||
(inIndentation && vsDraw.viewIndentationGuides != ivNone)) {
for (int cpos = 0; cpos <= i - startseg; cpos++) {
if (ll->chars[cpos + startseg] == ' ') {
if (vsDraw.viewWhitespace != wsInvisible) {
if (vsDraw.whitespaceForegroundSet)
textFore = vsDraw.whitespaceForeground.allocated;
if (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways) {
int xmid = (ll->positions[cpos + startseg] + ll->positions[cpos + startseg + 1]) / 2;
if (!twoPhaseDraw && drawWhitespaceBackground &&
(!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways)) {
textBack = vsDraw.whitespaceBackground.allocated;
PRectangle rcSpace(ll->positions[cpos + startseg] + xStart - subLineStart,
rcSegment.top,
ll->positions[cpos + startseg + 1] + xStart - subLineStart,
rcSegment.bottom);
surface->FillRectangle(rcSpace, textBack);
}
PRectangle rcDot(xmid + xStart - subLineStart, rcSegment.top + vsDraw.lineHeight / 2, 0, 0);
rcDot.right = rcDot.left + 1;
rcDot.bottom = rcDot.top + 1;
surface->FillRectangle(rcDot, textFore);
}
}
if (inIndentation && vsDraw.viewIndentationGuides == ivReal) {
int startSpace = ll->positions[cpos + startseg];
if (startSpace > 0 && (startSpace % indentWidth == 0)) {
DrawIndentGuide(surface, lineVisible, vsDraw.lineHeight, startSpace + xStart, rcSegment,
(ll->xHighlightGuide == ll->positions[cpos + startseg]));
}
}
} else {
inIndentation = false;
}
// ### Add Start 全角スペース可視化
int charpos = cpos + startseg;
if (charpos > 1 &&
(static_cast<unsigned char>(ll->chars[charpos - 2]) == 0xe3) &&
(static_cast<unsigned char>(ll->chars[charpos - 1]) == 0x80) &&
(static_cast<unsigned char>(ll->chars[charpos]) == 0x80) &&
IsUnicodeMode()) {
if (vsDraw.viewWhitespace != wsInvisible) {
if (vsDraw.whitespaceForegroundSet)
textFore = vsDraw.whitespaceForeground.allocated;
surface->PenColour(textFore);
PRectangle rcZenSpace(ll->positions[charpos - 2] + xStart - subLineStart,
rcSegment.top,
ll->positions[charpos + 1] + xStart - subLineStart,
rcSegment.bottom);
surface->MoveTo(rcZenSpace.left + 2, rcZenSpace.top + 3);
surface->LineTo(rcZenSpace.right - 4, rcZenSpace.top + 3);
surface->LineTo(rcZenSpace.right - 4, rcZenSpace.bottom - 5);
surface->LineTo(rcZenSpace.left + 2, rcZenSpace.bottom - 5);
surface->LineTo(rcZenSpace.left + 2, rcZenSpace.top + 3);
}
}
// ### Add End 全角スペース可視化
}
}
}
これでLinuxで使えるGUIなエディタができたかな。
それにしてもブログにソースコード載っけるって大変。勝手に変換されるよー。
寝る時間を削って、やっと全角スペースの可視化に成功したので、ソース載っけてみました。
ついでにタブの表示もちょこっと変更。(最後のドットが表示されないみたいなので。)
geany-0.18.1/scintilla/Editor.cxx
1750行目あたりのDrawTabArrow関数
void DrawTabArrow(Surface *surface, PRectangle rcTab, int ymid) {
// ### Update Start タブの表示方法変更
// int ydiff = (rcTab.bottom - rcTab.top) / 2;
// int xhead = rcTab.right - 1 - ydiff;
// if (xhead <= rcTab.left) {
// ydiff -= rcTab.left - xhead - 1;
// xhead = rcTab.left - 1;
// }
// if ((rcTab.left + 2) < (rcTab.right - 1))
// surface->MoveTo(rcTab.left + 2, ymid);
// else
// surface->MoveTo(rcTab.right - 1, ymid);
// surface->LineTo(rcTab.right - 1, ymid);
// surface->LineTo(xhead, ymid - ydiff);
// surface->MoveTo(rcTab.right - 1, ymid);
// surface->LineTo(xhead, ymid + ydiff);
surface->MoveTo(rcTab.left , ymid);
surface->LineTo(rcTab.left + 2, ymid - 2);
surface->LineTo(rcTab.left + 5, ymid + 1);
// ### Update End タブの表示方法変更
}
void Editor::DrawLine 関数の2600行目あたり
// Foreground drawing loop
の下の方を追加。
} else if (IsControlCharacter(ll->chars[i])) {
// Control character display
inIndentation = false;
if (controlCharSymbol < 32) {
// ### Add Start 制御文字の色変更
if (vsDraw.whitespaceForegroundSet)
textFore = vsDraw.whitespaceForeground.allocated;
surface->PenColour(textFore);
// ### Add End 制御文字の色変更
// Draw the character
const char *ctrlChar = ControlCharacterString(ll->chars[i]);
DrawTextBlob(surface, vsDraw, rcSegment, ctrlChar, textBack, textFore, twoPhaseDraw);
} else {
char cc[2] = { static_cast<char>(controlCharSymbol), '\0' };
surface->DrawTextNoClip(rcSegment, ctrlCharsFont,
rcSegment.top + vsDraw.maxAscent,
cc, 1, textBack, textFore);
}
} else if ((i == startseg) && (static_cast<unsigned char>(ll->chars[i]) >= 0x80) && IsUnicodeMode()) {
char hexits[3];
sprintf(hexits, "%2X", ll->chars[i] & 0xff);
DrawTextBlob(surface, vsDraw, rcSegment, hexits, textBack, textFore, twoPhaseDraw);
} else {
// Normal text display
if (vsDraw.styles[styleMain].visible) {
if (twoPhaseDraw) {
surface->DrawTextTransparent(rcSegment, textFont,
rcSegment.top + vsDraw.maxAscent, ll->chars + startseg,
i - startseg + 1, textFore);
} else {
surface->DrawTextNoClip(rcSegment, textFont,
rcSegment.top + vsDraw.maxAscent, ll->chars + startseg,
i - startseg + 1, textFore, textBack);
}
}
if (vsDraw.viewWhitespace != wsInvisible ||
(inIndentation && vsDraw.viewIndentationGuides != ivNone)) {
for (int cpos = 0; cpos <= i - startseg; cpos++) {
if (ll->chars[cpos + startseg] == ' ') {
if (vsDraw.viewWhitespace != wsInvisible) {
if (vsDraw.whitespaceForegroundSet)
textFore = vsDraw.whitespaceForeground.allocated;
if (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways) {
int xmid = (ll->positions[cpos + startseg] + ll->positions[cpos + startseg + 1]) / 2;
if (!twoPhaseDraw && drawWhitespaceBackground &&
(!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways)) {
textBack = vsDraw.whitespaceBackground.allocated;
PRectangle rcSpace(ll->positions[cpos + startseg] + xStart - subLineStart,
rcSegment.top,
ll->positions[cpos + startseg + 1] + xStart - subLineStart,
rcSegment.bottom);
surface->FillRectangle(rcSpace, textBack);
}
PRectangle rcDot(xmid + xStart - subLineStart, rcSegment.top + vsDraw.lineHeight / 2, 0, 0);
rcDot.right = rcDot.left + 1;
rcDot.bottom = rcDot.top + 1;
surface->FillRectangle(rcDot, textFore);
}
}
if (inIndentation && vsDraw.viewIndentationGuides == ivReal) {
int startSpace = ll->positions[cpos + startseg];
if (startSpace > 0 && (startSpace % indentWidth == 0)) {
DrawIndentGuide(surface, lineVisible, vsDraw.lineHeight, startSpace + xStart, rcSegment,
(ll->xHighlightGuide == ll->positions[cpos + startseg]));
}
}
} else {
inIndentation = false;
}
// ### Add Start 全角スペース可視化
int charpos = cpos + startseg;
if (charpos > 1 &&
(static_cast<unsigned char>(ll->chars[charpos - 2]) == 0xe3) &&
(static_cast<unsigned char>(ll->chars[charpos - 1]) == 0x80) &&
(static_cast<unsigned char>(ll->chars[charpos]) == 0x80) &&
IsUnicodeMode()) {
if (vsDraw.viewWhitespace != wsInvisible) {
if (vsDraw.whitespaceForegroundSet)
textFore = vsDraw.whitespaceForeground.allocated;
surface->PenColour(textFore);
PRectangle rcZenSpace(ll->positions[charpos - 2] + xStart - subLineStart,
rcSegment.top,
ll->positions[charpos + 1] + xStart - subLineStart,
rcSegment.bottom);
surface->MoveTo(rcZenSpace.left + 2, rcZenSpace.top + 3);
surface->LineTo(rcZenSpace.right - 4, rcZenSpace.top + 3);
surface->LineTo(rcZenSpace.right - 4, rcZenSpace.bottom - 5);
surface->LineTo(rcZenSpace.left + 2, rcZenSpace.bottom - 5);
surface->LineTo(rcZenSpace.left + 2, rcZenSpace.top + 3);
}
}
// ### Add End 全角スペース可視化
}
}
}
これでLinuxで使えるGUIなエディタができたかな。
それにしてもブログにソースコード載っけるって大変。勝手に変換されるよー。
※コメント投稿者のブログIDはブログ作成者のみに通知されます