ShortenGroupnames
From 40tude Dialog Wiki
Contents |
Shorten groupnames in grouplist
The following scripts cuts down the groupnames for a better view in small grouplist-windows. The script is written by Mirko D. Walter (mwalter@2via.de). Some changes are made by Kai Jürges for the complete shortened names and a bit of comfortable configuration.
Please read the Painting script warning page before trying out this script.
Samples
de.comp.software.40tude-dialog -> d.c.s.40tude-dialog
de.alt.netdigest -> d.a.netdigest
It's possible by configuration to get the complete shortened names (without the dots between the letters):
de.rec.sport.laufen.misc -> drslm
de.alt.netdigest -> dan
Screenshots:
Specials
Some newsgroup have standard-short-names. All known in de.all are handled.
For example:
de.alt.gruppenkasper - dag°
de.comm.software.40tude-dialog - dcs4-d
Installation & Setup
Paste the script in Event scripts -> OnNewsgroupListPaint, save, compile and run. The column numbers affected are in the const statement.
Setup the script:
To config the script as your own wish, edit the script in the following lines:
// Set to 1 if you want everything to be shortened const CompleteShort = 0; // Set to 0 if you don't want dots between the letters const WithPoints = 1; // Set to minimal count of dots before shortening should be done (1 or 2) const DotCount = 2;
Additional setup possibilities:
NGConstantNoDots.Add('DE.ADMIN.NET-ABUSE.MAIL=dan-am');
...
NGConstantNoDots.Add('DE.TALK.JUGEND=dtju');
Just copy one of the existing lines and insert the groupname and the correct short-name in the new line, separated by '='. This is not necassary if the short-name contains the first letters of each word only! Remember to do this twice, in the version without dots and then with dots.
NGShortNoDots.Add('MICROSOFT=ms');
...
NGShortNoDots.Add('FEUERWEHRMANN=fm');
Just copy one of the existing lines and insert the namepart and the correct short-name in the new line, separated by '='. Remember to do this twice, in the version without dots and then with dots.
program OnNewsgroupListPaint;
// ' If a group has more than one qualifier, all apart beside the last
// ' one will be shortened with the first letter
const CompleteShort = 1; // Set to 1 if you want everything to be shortened
WithPoints = 0; // Set to 0 if you don't want dots between the letters
DotCount = 2; // Set to minimal count of dots before shortening should be done (1 or 2)
maxInt = 2147483647;
// Arrays for special ng-names and special shortnames
Var NGConstantDots : TstringList;
NGConstantNoDots : TstringList;
NGShortDots : TstringList;
NGShortNoDots : TstringList;
Procedure InitArrays();
begin
NGConstantDots := TstringList.Create;
NGConstantNoDots := TstringList.Create;
NGShortDots := TstringList.Create;
NGShortNoDots := TstringList.Create;
// If you have some newsgroups with special short-names, please enter them below with
// the correct short-name (copy a line and change the values).
NGConstantNoDots.Add('DE.ADMIN.NET-ABUSE.MAIL=dan-am');
NGConstantNoDots.Add('DE.ALT.0D=da0d');
NGConstantNoDots.Add('DE.ALT.ARNOOO=daa' + Chr(39) + 'ooo');
NGConstantNoDots.Add('DE.ALT.FAN.DIE-AERZTE=dafd-a');
NGConstantNoDots.Add('DE.ALT.FAN.HARRY-POTTER=dafh-p');
NGConstantNoDots.Add('DE.ALT.FOLKLORE.URBAN-LEGENDS=dafu-l');
NGConstantNoDots.Add('DE.ALT.GRUPPENKASPER=dag°');
NGConstantNoDots.Add('DE.ALT.MUD=daMUD');
NGConstantNoDots.Add('DE.ALT.REC.ASCII-ART=dara-a');
NGConstantNoDots.Add('DE.ALT.TALK.KASPER=dateka°');
NGConstantNoDots.Add('DE.ALT.RECOVERY.WEBAUTHOR=<darw/>');
NGConstantNoDots.Add('DE.ALT.SOC.AUFMERKSAMKEITSDEFIZIT=dasad');
NGConstantNoDots.Add('DE.ALT.SOC.VERSCHWOERUNG=dasVau');
NGConstantNoDots.Add('DE.COMM.FUNK.CB=dcfcb');
NGConstantNoDots.Add('DE.COMM.INFOSYSTEMS.WWW.AUTHORING.MISC=<dciwam/>');
NGConstantNoDots.Add('DE.COMM.SOFTWARE.40TUDE-DIALOG=dcs4-d');
NGConstantNoDots.Add('DE.REC.MODELLE.BAHN=DER_MOBA');
NGConstantNoDots.Add('DE.REC.MUSIK.NACHTLEBEN=deremuna');
NGConstantNoDots.Add('DE.REC.SPORT.MOTORSPORT.FORMEL1=drsmf1');
NGConstantNoDots.Add('DE.SOC.RECHT.MARKEN+URHEBER=dsrm+u');
NGConstantNoDots.Add('DE.SOC.RECHT.STRAFRECHT=dsr.sr');
NGConstantNoDots.Add('DE.TALK.BIZARRE=detebe');
NGConstantNoDots.Add('DE.TALK.JOKES=detejott');
NGConstantNoDots.Add('DE.TALK.JUGEND=dtju');
NGConstantNoDots.Add('BLN.JUGEND.TALK=bjt');
NGConstantDots.Add('DE.ADMIN.NET-ABUSE.MAIL=d.a.n-a.m');
NGConstantDots.Add('DE.ADMIN.NET-ABUSE.NEWS=d.a.n-a.n');
NGConstantDots.Add('DE.ALT.0D=d.a.0d');
NGConstantDots.Add('DE.ALT.ARNOOO=d.a.a' + Chr(39) + 'ooo');
NGConstantDots.Add('DE.ALT.FAN.DIE-AERZTE=d.a.f.d-a');
NGConstantDots.Add('DE.ALT.FAN.HARRY-POTTER=d.a.f.h-p');
NGConstantDots.Add('DE.ALT.FOLKLORE.URBAN-LEGENDS=d.a.f.u-l');
NGConstantDots.Add('DE.ALT.GRUPPENKASPER=d.a.g°');
NGConstantDots.Add('DE.ALT.MUD=d.a.MUD');
NGConstantDots.Add('DE.ALT.REC.ASCII-ART=d.a.r.a-a');
NGConstantDots.Add('DE.ALT.TALK.KASPER=d.a.te.ka°');
NGConstantDots.Add('DE.ALT.RECOVERY.WEBAUTHOR=<d.a.r.w/>');
NGConstantDots.Add('DE.ALT.SOC.AUFMERKSAMKEITSDEFIZIT=d.a.s.ad');
NGConstantDots.Add('DE.ALT.SOC.VERSCHWOERUNG=dasVau');
NGConstantDots.Add('DE.COMM.FUNK.CB=d.c.f.cb');
NGConstantDots.Add('DE.COMM.INFOSYSTEMS.WWW.AUTHORING.MISC=<d.c.i.w.a.m/>');
NGConstantDots.Add('DE.COMM.SOFTWARE.40TUDE-DIALOG=d.c.s.4-d');
NGConstantDots.Add('DE.REC.MODELLE.BAHN=DER_MOBA');
NGConstantDots.Add('DE.REC.MUSIK.NACHTLEBEN=de.re.mu.na');
NGConstantDots.Add('DE.REC.SPORT.MOTORSPORT.FORMEL1=d.r.s.m.f1');
NGConstantDots.Add('DE.SOC.RECHT.MARKEN+URHEBER=d.s.r.m+u');
NGConstantDots.Add('DE.SOC.RECHT.STRAFRECHT=d.s.r.sr');
NGConstantDots.Add('DE.TALK.BIZARRE=de.te.be');
NGConstantDots.Add('DE.TALK.JOKES=de.te.jott');
NGConstantDots.Add('DE.TALK.JUGEND=d.t.ju');
NGConstantDots.Add('BLN.JUGEND.TALK=b.j.t.');
// If you have some substrings to be shortened in a special way, please enter them
// below with the correct short version (copy a line and change the values).
NGShortNoDots.Add('MICROSOFT=ms');
NGShortNoDots.Add('NGFOLDER=ng-');
NGShortNoDots.Add('FEUERWEHRMANN=fm');
NGShortDots.Add('MICROSOFT=ms');
NGShortDots.Add('NGFOLDER=ng');
NGShortDots.Add('FEUERWEHRMANN=fm');
end;
Function NameConstants(NGName : String) : String;
begin
result := '';
If WithPoints = 0 Then
begin
IF NGConstantNoDots.IndexOfName(NGName) <> -1 THEN
BEGIN
Result := NGConstantNoDots.Values[NGName];
END
end
else
begin
IF NGConstantDots.IndexOfName(NGName) <> -1 THEN
BEGIN
Result := NGConstantDots.Values[NGName];
END
end
end;
Function GetShort(NGName : String) : string;
VAR chkStr : String;
Index : Integer;
begin
result := Copy(NGName, 1, 1);
If WithPoints = 0 Then
begin
FOR Index := 0 TO NGShortNoDots.Count-1 DO
BEGIN
chkStr := NGShortNoDots.Names[Index];
IF NGShortNoDots.Names[Index] = Copy(UpperCase(NGName),1,Length(chkStr)) Then
Result := NGShortNoDots.Values[NGShortNoDots.Names[Index]];
END;
end
else
begin
FOR Index := 0 TO NGShortDots.Count-1 DO
BEGIN
chkStr := NGShortDots.Names[Index];
IF NGShortDots.Names[Index] = Copy(UpperCase(NGName),1,Length(chkStr)) Then
Result := NGShortDots.Values[NGShortDots.Names[Index]];
END;
end
end;
Function CutGenerations(NGName : String) : string;
var Posi : integer;
Temp : string;
Temp2 : string;
Temp3 : string;
KlammerPos : integer;
SName : string;
begin
begin
KlammerPos := AnsiPos('(', NGName);
if KlammerPos <= 0 then KlammerPos := AnsiPos(' ', NGName);
If KlammerPos > 0 then
begin // Servername is showed. Remember for later use and cut away.
SName := Copy(NGName, AnsiPos('(', NGName), MaxInt);
NGName := Trim(Copy(NGName, 1, KlammerPos - 1));
end
else
SName := '';
Temp3 := NameConstants(UpperCase(NGName));
If Temp3 = '' Then
begin
Posi := AnsiPos('.', NGName);
If Posi > 0 Then
begin
Temp2 := Copy(NGName, Posi+1, MaxInt);
Posi := AnsiPos('.', Temp2);
If (Posi > 0) OR (DotCount < 2) Then
begin
Temp2 := NGName;
Posi := AnsiPos('.', Temp2);
repeat
If WithPoints = 1 Then
Temp := Temp + '.' + GetShort(Temp2)
Else
Temp := Temp + GetShort(Temp2);
Temp2 := Copy(Temp2, Posi + 1, MaxInt);
Posi := AnsiPos('.', Temp2);
Until Posi <= 0;
if CompleteShort = 0 then
begin
Temp := Temp + '.' + Temp2;
If WithPoints = 1 Then Temp := Copy(Temp, 2, MaxInt);
end
else
begin
If WithPoints = 1 Then
begin
Temp := Temp + '.' + GetShort(Temp2);
Temp := Copy(Temp, 2, MaxInt);
end
else
begin
Temp := Temp + GetShort(Temp2);
end
end
end
else
Temp := NGName;
end
else
Temp := NGName;
end
else
Temp := Temp3;
end
if SName <> '' then result := Temp + ' ' + SName // Include Servername, if it was showed before
else result := Temp;
end;
function OnNewsgroupListPaint(PaintString:widestring;ColumnIndex:integer):widestring;
var shortstring: string;
newwide : widestring;
begin
InitArrays;
shortstring := paintstring;
shortstring := CutGenerations(shortstring);
newwide := shortstring;
result := newwide;
// Clean up memory
NGConstantDots.free;
NGConstantNoDots.free;
NGShortDots.free;
NGShortNoDots.free;
end;
begin
end.
Mirko D. Walter
Kai Jürges

