// // 英単語カウント (2014/06/10) // by mobitan http://mobitan.org/ // setcompatiblemode 0x12020F; loaddll "hmjre.dll"; // disabledraw; if (rectselecting) { tomultiselect; } if (multiselecting) { disabledraw; call MultiSelected; enabledraw; } else if (selecting) { call Selected; } else { call NoSelected; } title str(#nw) + " words, " + str(#nl) + " breaks", 1; title -1, 1; // enabledraw; freedll; endmacro; NoSelected: call Core gettext2(0, 1, 9999, linecount2, false); return; Selected: call Core gettext(seltopx, seltopy, selendx, selendy, true); return; MultiSelected: $$w1 = currentmacrobasename + "#selection1"; $$w2 = currentmacrobasename + "#selection2"; colormarker 0xFFFFFF, 0xFF6666, 11, 2, 0, $$w1; ##bx = seltopx; ##by = seltopy; gofiletop; nextcolormarker 0x09, 0, $$w1; while (result) { beginsel; nextcolormarker 0x0A, 0, $$w1; endsel; deletecolormarker $$w1; call Core gettext(seltopx, seltopy, selendx, selendy, true); colormarker 0xFFFFFF, 0x993333, 11, 2, 0, $$w2; nextcolormarker 0x01, 0, $$w1; } moveto ##bx, ##by; selectcolormarker $$w2; deletecolormarker $$w2; return; Core: $$text = dllfuncstr("ReplaceRegular", "\\r", $$1, 0, "", 2); $$words = dllfuncstr("ReplaceRegular", "\\S+", $$text, 0, "!", 2); $$words = dllfuncstr("ReplaceRegular", "\\s+", $$words, 0, "", 2); #nw = #nw + strlen($$words); #nl = #nl + charcount(0x80022222); return; // (c) mobitan 2014