×

Thông báo nâng cấp hệ thống

Hiện tại hệ thống đã chuyển đổi sang phiên bản mới hơn

Vui lòng bấm vào đây để chuyển sang phiên bản mới nhất

 Help, BigBang

Thảo luận trong 'Ebook truyện dịch' bắt đầu bởi mrland, 6/3/15.

  1. Big Bang

    Big Bang Thành viên kích hoạt

    Được thích:
    130
    lão muốn xài bản N++ cũ à? :)) Thử cái này coi, ta chưa test đâu: lão thay code trong file jsee của bản cũ (auto_correct) bằng cái này:

    Mã:
    // generate_npp_macro.jsee
    
    var errListDoc = editor.ActiveDocument;
    
    if (errListDoc.Name.toLowerCase() == "error_list.ebi")
    {
    	var FRM_DOWN_ALL_REG = eeFindNext | eeFindReplaceRegExp | eeFindReplaceQuiet | eeReplaceAll;
    	var errListSel = errListDoc.selection;
    	errListSel.SelectAll();
    	errListSel.Copy();
    	errListSel.Collapse();
    	editor.NewFile();
    	var doc = editor.ActiveDocument;
    	var sel = doc.selection;
    	sel.Paste();
    	
    	// delete comment lines
    	sel.StartOfDocument();
    	sel.Replace("^_COMMENT_[^\\r\\n]*", "", FRM_DOWN_ALL_REG);
    	
    	// tabs to spaces
    	sel.StartOfDocument();
    	sel.Replace("\\t", " ", FRM_DOWN_ALL_REG);
    	
    	// delete lines containing only spaces
    	sel.StartOfDocument();
    	sel.Replace("^ +\\r\\n", "", FRM_DOWN_ALL_REG);
    		
    	// delete blank lines
    	sel.StartOfDocument();
    	sel.Replace("(\\r\\n){2,}", "\\r\\n", FRM_DOWN_ALL_REG);
    	
    	// delete first and last (empty) lines
    	sel.StartOfDocument();
    	sel.Delete(1);
    	sel.EndOfDocument();
    	sel.DeleteLeft(1);
    	
    	// replace all lines in form <searched>=<replacement>=<type>=<option>
    	sel.StartOfDocument();
    	sel.Replace("^([^=]+)=([^=]*)=([0-2])=([0-9]+)$", "<Action type=\"0\" message=\"2316\" wParam=\"0\" lParam=\"0\" sParam=\"\" />\\r\\n<Action type=\"3\" message=\"1700\" wParam=\"0\" lParam=\"0\" sParam=\"\" />\\r\\n<Action type=\"3\" message=\"1601\" wParam=\"0\" lParam=\"0\" sParam=\"\\1\" />\\r\\n<Action type=\"3\" message=\"1625\" wParam=\"0\" lParam=\"\\3\" sParam=\"\" />\\r\\n<Action type=\"3\" message=\"1602\" wParam=\"0\" lParam=\"0\" sParam=\"\\2\" />\\r\\n<Action type=\"3\" message=\"1702\" wParam=\"0\" lParam=\"\\4\" sParam=\"\" />\\r\\n<Action type=\"3\" message=\"1701\" wParam=\"0\" lParam=\"1609\" sParam=\"\" />\\r\\n", FRM_DOWN_ALL_REG);
    	
    	// write additional code
    	sel.StartOfDocument();
    	doc.write("<Macro name=\"Correct Misspelling\" Ctrl=\"no\" Alt=\"no\" Shift=\"no\" Key=\"0\">\r\n<Action type=\"0\" message=\"2012\" wParam=\"0\" lParam=\"0\" sParam=\"\" />\r\n<Action type=\"0\" message=\"2175\" wParam=\"0\" lParam=\"0\" sParam=\"\" />\r\n\r\n");
    	sel.EndOfDocument();
    	doc.write("\r\n<Action type=\"0\" message=\"2012\" wParam=\"1\" lParam=\"0\" sParam=\"\" />\r\n</Macro>\r\n");
    	
    	var i, txt, strLen;
    	sel.SelectAll();
    	txt = sel.Text;
    //	sel.Collapse();
    	strLen = txt.length;
    	for (i=0; i<strLen; i++)
    	{
    		if (txt.charCodeAt(i) > 0x80) // not an ANSI character
    		{
    			txt = txt.replace(txt.charAt(i), "&#x" + ("000" + txt.charCodeAt(i).toString(16).toUpperCase()).slice(-4) + ";");
    			strLen = txt.length;
    		}
    	}
    	sel.Text = txt;
    }
    else
    {
    	alert("Sctipt chỉ chạy với file \"error_list.ebi\"!");
    }
    
     
    Chỉnh sửa cuối: 10/3/15
  2. Decepticon

    Decepticon Thành viên kích hoạt

    Được thích:
    269
    mịa nó, tự nhiên mất mạng

    Nói thiệt lão mà fix cái script cho Emeditor ta bỏ luôn N++.
    Auto replace bằng N++ mất công dã man, nhiều lúc thêm có 1 dòng replace mà phải vô Emeditor chạy jsee rùi vô Appdata sửa shortcut.xml rồj copy text qua N++ chạy macro... nghĩ mà phát ớn


    P/s: lão có lòng fix script Em thì config giống N++ bản cũ nhá, cấu trúc old=new=[0,1,2]=[512, 513, 514] á.
     
    Chỉnh sửa cuối: 11/3/15
  3. Big Bang

    Big Bang Thành viên kích hoạt

    Được thích:
    130
    .
    Coi topic Mẹo Vặt Làm Ebook, post #7.
     
  4. Decepticon

    Decepticon Thành viên kích hoạt

    Được thích:
    269
    không chạy được lão ơi, với lại thay <opt2> giống N++ đi cho dễ nhìn, <opt1> nhìn giống <opt2> dễ nhầm lắm

    List đả tự: http://rghost.net/7NdXlJMLf
    Test.txt: tự chém
     
  5. Big Bang

    Big Bang Thành viên kích hoạt

    Được thích:
    130
    Ta lấy ngay file sửa lỗi của lão làm file text. Kết quả hầu hết các dòng được sửa tốt (<lỗi>=<sửa> ==> <sửa>=<sửa>) Một số dòng sai vì dữ liệu của lão thế này:

    AAA=BBB
    BBB=CCC

    Kết quả:

    CCC=CCC
    CCC=CCC

    thay vì

    BBB=BBB
    CCC=CCC

    Phiên bản trên Excels có cái lợi là nó sort cho lão, tránh được hầu hết mấy cái lỗi này. Nếu làm theo script này lão phải tự sort lấy. Trong EmEditor cho phép sort theo cột ở chế độ CSV, lão vọc thử coi. Nhớ chọn separator là "=".