⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 prettyprinterprefs.java

📁 Python Development Environment (Python IDE plugin for Eclipse). Features editor, code completion, re
💻 JAVA
字号:
/*
 * Created on Feb 11, 2006
 */
package org.python.pydev.parser.prettyprinter;

import java.util.HashMap;
import java.util.Map;

public class PrettyPrinterPrefs {

    private String newLine;
    private String spacesBeforeComment="";
    private Map<String,String> tokReplacement = new HashMap<String, String>();
    private int linesAfterMethod = 0;
    private int linesAfterClass = 0;
    private int spacesAfterColonInDict=0;

    public PrettyPrinterPrefs(String newLine) {
        this.newLine = newLine;
        tokReplacement.put("elif", "elif ");
    }

    public String getNewLine() {
        return newLine;
    }

    public String getIndent() {
        return "    ";
    }

    public void setSpacesAfterComma(int i) {
        this.tokReplacement.put(",", createSpacesStr(i, ","));
    }

    private String createSpacesStr(int i, String startingWith) {
        StringBuffer buffer = new StringBuffer();
        if(startingWith != null){
            buffer.append(startingWith);
        }
        for (int j = 0; j < i; j++) {
            buffer.append(' ');
        }
        return buffer.toString();
    }

    public String getReplacement(String tok) {
        String r = tokReplacement.get(tok);
        if(r == null){
            return tok;
        }
        return r;
    }

    //spaces before comment
    public String getSpacesBeforeComment() {
        return spacesBeforeComment;
    }
    
    public void setSpacesBeforeComment(int i) {
        spacesBeforeComment = createSpacesStr(i, null);
    }
    
    
    
    //spaces after colon (dict, lambda)
    public void setSpacesAfterColon(int i) {
        spacesAfterColonInDict = i;
    }
    
    public void enableSpacesAfterColon(){
        this.tokReplacement.put(":", createSpacesStr(spacesAfterColonInDict, ":"));
    }
    
    
    public void disableSpacesAfterColon(){
        this.tokReplacement.put(":", ":");
    }
    
    

    //lines after method
    public void setLinesAfterMethod(int i) {
        linesAfterMethod = i;
    }
    
    public int getLinesAfterMethod(){
        return linesAfterMethod;
    }
    
    public void setLinesAfterClass(int i) {
        linesAfterClass = i;
    }

    public int getLinesAfterClass() {
        return linesAfterClass;
    }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -