首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Axapta 4.0注释快捷方式

Axapta 4.0注释快捷方式
EN

Stack Overflow用户
提问于 2015-12-03 21:12:43
回答 2查看 308关注 0票数 0

我现在用axapta 4.0工作了3天,我不能通过快捷方式评论文本。我知道在axapta中没有实现快捷方式,但是有没有一种可能的解决方案,这样我就可以编写一个代码片段或其他东西来注释我的文本。我无法想象以前没有人遇到过这个问题,也没有找到解决方案。

EN

回答 2

Stack Overflow用户

发布于 2015-12-04 13:26:06

这对你来说应该是有用的。它是从其他方法中删减出来的,只是为了复制和粘贴,simple...you可以进行优化。

在此处创建此方法alex_GeneralComment

Classes\EditorScripts\alex_GeneralComment

然后输入以下代码,您应该能够在编辑器[right click>Scripts>alex>General Comment]中选择代码

它将创建如下所示的注释,并将光标放在//行上。用它做实验。

// (ALEX) (12/03/2015) /-->info(“如果我选择这两行代码,则右键单击并执行");info(”脚本,注释块将如下所示“);//<--

代码语言:javascript
复制
public void alex_GeneralComment(Editor _editor)
{
    #define.YourCompanyName("ALEX")
    str         selText = EditorScripts::getSelectedText(_editor, false);
    str         selFirstLine;
    int         startLine = _editor.selectionStartLine()+1;
    int         endLine   = _editor.selectionEndLine()+1;
    int         startCol  = _editor.selectionStartCol();
    str         name      = XUserInfo::find(False, curUserId()).name ? XUserInfo::find(False, curUserId()).name : XUserInfo::find(False, curUserId()).networkAlias;
    xppSource   xppSource;

    str getSelectedText(Editor e, boolean takeAllIfEmpty = true)
    {
        int i;
        str text;
        str line;
        int _startLine = e.selectionStartLine()+1;
        int _endLine   = e.selectionEndLine()+1;
        int _startCol  = e.selectionStartCol();
        int endCol    = e.selectionEndCol();

        if (_startLine == _endLine && _startCol == endCol)
        {
            // This method returns the selected text, and if the user selects
            // no text, then it returns nothing.  So we want to return the
            // entire code block if the parameter is set
            if (!takeAllIfEmpty)
                return text;

            e.firstLine();
            while (e.moreLines())
            {
                text += e.getLine()+'\r\n';
                e.nextLine();
            }
        }
        else
        {
            e.firstSelectedLine();
            for (i = _startLine; i <= _endLine; i++)
            {
                line = e.getLine();
                if (i == _startLine && i == _endLine)
                {
                    line = subStr(line, _startCol, endCol-_startCol);
                }
                else
                if (i == _endLine)
                {
                    line = subStr(line, 1, endCol-1);
                }
                else
                if (i == _startLine)
                {
                    line = strRep(' ', _startCol-1)+subStr(line, _startCol, strLen(line));
                }

                text += line + '\r\n';
                e.nextSelectedLine();
            }
        }
        return text;
    }

    boolean isSelectionNonEmpty(str s)
    {
        // delete all special symbols
        return strLen(strRem(strRem(strRem(s," "),"\n"),"\r"))>0;
    }

    if(isSelectionNonEmpty(selText))
    {
        startLine = _editor.selectionStartLine()+1;
        _editor.firstSelectedLine();
        selFirstLine = _editor.getLine();

        startCol  = strLen(selFirstLine) -strLen(strLTrim(selFirstLine));
        xppSource = new xppSource(startCol);
        _editor.insertLines(strFmt("// ("+#YourCompanyName+") (%1)", date2str(today(), 213, 2, 4, 2, 4, 4, DateFlags::None))+"\n");
        _editor.insertLines(xppSource.indent()+strFmt("// \n"));
        _editor.insertLines(xppSource.indent()+strFmt("//-->\n"));

        // If it's one line, indent it, otherwise paste as-is
        if (startLine == endLine)
            _editor.insertLines(xppSource.indent() + selText);
        else
            _editor.insertLines(selText);

        _editor.insertLines(xppSource.indent()+strFmt("//<--"));
        _editor.gotoLine(startLine);
        _editor.gotoCol(strLen(_editor.getLine())); // Go to the comments section
    }
    else
    {
        startCol = _editor.columnNo();
        xppSource = new xppSource(startCol);
        _editor.insertLines(strFmt("// ("+#YourCompanyName+") (%1)", date2str(today(), 213, 2, 4, 2, 4, 4, DateFlags::None))+"\n");
        _editor.insertLines(xppSource.indent()+strFmt("// \n"));
        _editor.insertLines(xppSource.indent()+strFmt("//-->\n"));
        _editor.insertLines(xppSource.indent()+strFmt("\n"));
        endLine = _editor.currentLineNo(); // Line we want to end on
        _editor.insertLines(xppSource.indent()+strFmt("//<--"));
        _editor.gotoLine(endLine);
        _editor.gotoCol(startCol+1);
    }
}
票数 2
EN

Stack Overflow用户

发布于 2018-07-26 04:34:24

除了上面的answer之外:

可以通过键入Alt+R, S打开可用的编辑器脚本菜单

之后,您可以查看EditorScripts类中的getApplicableScripts方法。此方法负责通过返回一个充满编辑器脚本的容器来获取菜单包含的编辑器脚本。您可以根据需要修改该代码。

例如,要将容器修改为仅包含注释和取消注释功能,请在变量声明的正下方添加以下代码:

代码语言:javascript
复制
if (curUserId() == "YourUserId")
{
    scripts += "comments_comment";
    scripts += "comments_uncomment";

    return scripts;
}

//- Some more code

这样,您就可以在comment和Alt+R, S, C, U中输入Alt+R, S, C, C

..。一开始只需要一点练习就能记住。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34066984

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档