标签: formatter

如何更改jqgrid自定义格式化程序中单元格的背景颜色?

我可以通过在jqgrid自定义格式化程序中执行此操作来更改文本颜色:

function YNFormatter(cellvalue, options, rowObject)
{
    var color = (cellvalue == "Y") ? "green" : "red";
    var cellHtml = "<span style='color:" + color + "' originalValue='" +
                                cellvalue + "'>" + cellvalue + "</span>";

    return cellHtml;
 }
Run Code Online (Sandbox Code Playgroud)

但我想现在改变整个单元格的背景颜色(而不是文本颜色).

这可能吗?

jquery formatter jqgrid

9
推荐指数
1
解决办法
3万
查看次数

如何在Eclipse中更改代码约定

我喜欢以这种方式使用花括号

void hello()
{
    code();
}
Run Code Online (Sandbox Code Playgroud)

当我在Eclipse中按Ctrl+ Shift+时F,它会改变一切

void hello(){
    code();
}
Run Code Online (Sandbox Code Playgroud)

java eclipse coding-style formatter

9
推荐指数
1
解决办法
7630
查看次数

为什么intellij格式化程序在嵌入脚本后附加一个空行?

例如,HTML看起来像这样:

<script>
    var hello;
</script>
Run Code Online (Sandbox Code Playgroud)

格式化几次后会变为此(Code> Reformat code...):

<script>
    var hello;



</script>
Run Code Online (Sandbox Code Playgroud)

html javascript intellij-idea formatter

9
推荐指数
1
解决办法
612
查看次数

如何正确格式化python日志格式化程序?

我尝试格式化我的 Python 日志格式化程序输出字符串的方式。我写了一个简约的例子来说明这个问题:

import logging
from pathlib import Path

# create auxiliary variables
loggerName = Path(__file__).stem

# create logging formatter
logFormatter = logging.Formatter(fmt=' %(name)s :: %(levelname)s :: %(message)s')

# create logger
logger = logging.getLogger(loggerName)
logger.setLevel(logging.DEBUG)

# create console handler
consoleHandler = logging.StreamHandler()
consoleHandler.setLevel(logging.WARNING)
consoleHandler.setFormatter(logFormatter)

# Add console handler to logger
logger.addHandler(consoleHandler)

# Test
logger.debug('debug message')
logger.info('info message')
logger.warning('warn message')
logger.error('error message')
logger.critical('critical message')
Run Code Online (Sandbox Code Playgroud)

该脚本将给出一个没有正确格式的输出:

logger :: WARNING :: warn message
logger :: ERROR :: error message
logger :: CRITICAL :: …
Run Code Online (Sandbox Code Playgroud)

python logging formatter

9
推荐指数
1
解决办法
1万
查看次数

强制 VSCode 始终使用制表符作为缩进

当我在 VSCode 中保存文件时,它们会自动格式化。制表符被转换为四个空格。但我更喜欢标签。如何强制 VSCode 使用制表符而不是四个空格?

这些是我的设置。

{
    "files.insertFinalNewline": true,
    "terminal.integrated.shellArgs.windows": [
        "-ExecutionPolicy",
        "Bypass"
    ],
    "files.trimFinalNewlines": false,
    "window.zoomLevel": 0,
    "explorer.confirmDelete": false,
    "workbench.startupEditor": "newUntitledFile",
    "typescript.updateImportsOnFileMove.enabled": "always",
    "typescript.format.semicolons": "remove",
    "editor.formatOnSave": true,
    "editor.detectIndentation": false,
    "editor.tabSize": 4,
    "editor.insertSpaces": false
}
Run Code Online (Sandbox Code Playgroud)

我缺少什么设置来强制 VSCode不用 4 个空格替换制表符?

formatter visual-studio-code

9
推荐指数
1
解决办法
6039
查看次数

JFormattedTextField问题

在此输入图像描述 在此输入图像描述

1)如何将Cursor设置为0,而不使用Caret或Focus包装到invokeLater()(使用@camickr 格式文本字段提示可以解决),是否有人知道另一种方式

在此输入图像描述 在此输入图像描述

2)How to reset Formatter有时(通过TAB从键盘提高Focus),重置不起作用,并且在focusLost(空字段)格式化程序返回/重新生成的字符或字符串返回(最后在setText("")之前知道;),

注意:知道代码或下面的代码is only this way,关于如何从OTN重置Formatter,但是他们可怕的搜索rulles ....,只有代码(问题或答案由Jeanette ???)

import java.awt.event.*;
import java.beans.*;
import java.text.ParseException;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.text.Document;

public class FormattedNull {

    private JFormattedTextField field;
    private JButton focusButton;

    private JComponent createContent() {
        JComponent content = new JPanel();
        field = new JFormattedTextField(new Integer(55));
        field.setColumns(20);
        field.addPropertyChangeListener(getPropertyChangeListener());
        field.getDocument().addDocumentListener(getDocumentListener());
        content.add(field);
        focusButton = new JButton("just something focusable");
        focusButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                field.setValue(0);
                field.requestFocusInWindow();
            }
        });
        content.add(focusButton);
        return content;
    } …
Run Code Online (Sandbox Code Playgroud)

java swing formatter jformattedtextfield

8
推荐指数
1
解决办法
4645
查看次数

python日志记录dictConfig自定义格式化程序未被调用

我的模块中有以下ColoeredFormatter.

但格式化程序不会被调用.我希望在控制台上"hi",但我得到"这是根记录器的信息".

我已经删除了所有.pyc文件,但它没有帮助.

MyModule的/ __ init__.py

from MyModule.ColoredFormatter import ColoredFormatter

__all__ = ('ColoredFormatter')
Run Code Online (Sandbox Code Playgroud)

MyModule的/ ColoredFormatter.py

import logging

class ColoredFormatter(logging.Formatter):
    def __init__(self, default):
        self.default = default

    def format(self, record):
        print("hi")
        record.msg = "hi"
        return self.default.format(record)
Run Code Online (Sandbox Code Playgroud)

我的剧本

import logging, logging.config, yaml

conf="""
logging:
  version: 1
  disable_existing_loggers: true
  root:
    level: !!python/name:logging.NOTSET
    handlers: [console]
  handlers:
    console:
      class: logging.StreamHandler
      stream: ext://sys.stdout
      formatter: myFormatter
      level: !!python/name:logging.NOTSET

  formatters:
    myFormatter:
      class: !!python/name:MyModule.ColoredFormatter
"""
dict = yaml.parse(conf)
logging.config.dictConfig(dict["logging"])

logging.info("This is an info of the root logger")
Run Code Online (Sandbox Code Playgroud)

python logging formatter

8
推荐指数
2
解决办法
2707
查看次数

如何对 Nginx 配置文件应用一致的缩进和格式?

例如,我有这个混乱的配置:

server {
listen 80 default;
                        server_name localhost;
location / {
proxy_method $foo;
                    proxy_pass http://foobar:8080;
}
} 
Run Code Online (Sandbox Code Playgroud)

我想让它看起来像:

server
{
    listen 80 default;
    server_name localhost;
    location /
    {
        proxy_method $foo;
        proxy_pass http://foobar:8080;
    }
}
Run Code Online (Sandbox Code Playgroud)

如何以更好的方式格式化 Nginx 配置?

config nginx formatter

8
推荐指数
1
解决办法
5091
查看次数

使用 VS 代码插件的 XML 缩进 - Wrap Attributes

我正在寻找一种方法,以两种方式使用插件VS Code Pretty Formatter或其他插件来识别 XML 文件及其类:块和内联。有什么方法可以获得类似的结果吗?是否可以创建键盘快捷键?

例如: 块缩进和行内缩进

plugins formatter visual-studio-code

8
推荐指数
1
解决办法
1万
查看次数

如何格式化 zsh 代码(例如 prettier / shfmt)?

对于bash和sh,有shfmt。

如何格式化zsh代码?

我希望能够设置一些选项,例如 in shfmt,即:

  -i uint   indent: 0 for tabs (default), >0 for number of spaces
  -bn       binary ops like && and | may start a line
  -ci       switch cases will be indented
  -sr       redirect operators will be followed by a space
  -kp       keep column alignment paddings
  -fn       function opening braces are placed on a separate line
Run Code Online (Sandbox Code Playgroud)

zsh-hist说它支持“统一代码格式”,但我不知道如何从命令行运行它,它的主要目的是历史操作。

如何zsh在 shell 中或通过 VSCode prettier 之类的工具格式化代码?

zsh formatter prettier

8
推荐指数
0
解决办法
1991
查看次数