AkelPad Forum Index AkelPad
Support forum
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Astyle и AkelPad

 
Post new topic   Reply to topic    AkelPad Forum Index -> Discussion (Russian)
View previous topic :: View next topic  
Author Message
se7h



Joined: 28 Sep 2009
Posts: 767
Location: Minsk, Belarus

PostPosted: Sun Jun 27, 2010 10:16 am    Post subject: Astyle и AkelPad Reply with quote

Рабочий скрипт

Code:
/// Process current file in external tool

var WshShell=new ActiveXObject("WScript.shell");
var fso=new ActiveXObject("Scripting.FileSystemObject");
var pToolPath=AkelPad.GetAkelDir() + "\\AkelFiles\\Plugs\\AStyle\\AStyle.exe";
var pToolFlags="--style=java --indent=tab";
var hEditWnd=AkelPad.GetEditWnd();
var pTmpFile;
var pText;

if (pTmpFile=CreateTempFile())
{
    AkelPad.SaveFile(hEditWnd, pTmpFile, 65001, true, false);

    if (pToolPath.search(/ /) != -1)
      pToolPath="\"" + pToolPath + "\"";
    if (pTmpFile.search(/ /) != -1)
      pTmpFile="\"" + pTmpFile + "\"";
    WshShell.Run("%COMSPEC% /c " + pToolPath + " " + pToolFlags + " " + pTmpFile, 0, true);

    pText=AkelPad.ReadFile(pTmpFile);
    AkelPad.SetSel(0, -1);
    AkelPad.ReplaceSel(pText);

  fso.DeleteFile(pTmpFile);
}


//Functions
function CreateTempFile()
{
  var oTmpFolder;
  var oTmpFile;
  var pTmpName;

  if (oTmpFolder=fso.GetSpecialFolder(2 /*TemporaryFolder*/))
  {
    pTmpName=fso.GetTempName();
    if (oTmpFile=oTmpFolder.CreateTextFile(pTmpName))
      oTmpFile.Close();
    return (oTmpFolder.Path + "\\" + pTmpName);
  }
  return "";
}

, связывающий AStyle с AP


Last edited by se7h on Tue Jun 29, 2010 9:57 am; edited 1 time in total
Back to top
View user's profile Send private message
Instructor
Site Admin


Joined: 06 Jul 2006
Posts: 5358

PostPosted: Sun Jun 27, 2010 10:26 am    Post subject: Reply with quote

se7h
На страничке указаны файлы с юниксовой косой чертой. Может так заработает:
Code:
    if (pTmpFile1.search(/ /) != -1)
      pTmpFile1="\"" + pTmpFile1 + "\"";
    pTmpFile1=pTmpFile1.replace(/\\/g, "/");

Кстати, выложенный вами код, не соответствует тому, что в "Scripts collection". Также кодировку, следуя из описания Astyle, необходимо указать не 1200 (UTF-16LE), а например 65001 (UTF-8).
Back to top
View user's profile Send private message Send e-mail
se7h



Joined: 28 Sep 2009
Posts: 767
Location: Minsk, Belarus

PostPosted: Sun Jun 27, 2010 10:59 am    Post subject: Reply with quote

я убрал лишний темпфайл, в астайл можно работать с одним
для htmltidy код вообще не менял
Back to top
View user's profile Send private message
se7h



Joined: 28 Sep 2009
Posts: 767
Location: Minsk, Belarus

PostPosted: Tue Jun 29, 2010 9:49 am    Post subject: Reply with quote

поборол Cool
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AkelPad Forum Index -> Discussion (Russian) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


SourceForge.net Logo Powered by phpBB © 2001, 2005 phpBB Group