创建源代码编辑器我需要了解什么?

发布于 2024-08-31 04:28:15 字数 160 浏览 2 评论 0原文

假设我想为 ocaml 编程语言创建一个源代码编辑器,我从哪里开始?我希望为 Windows 平台创建一个编辑器作为一个业余爱好项目。我的主要技能是网络开发。我很久以前就开发过Windows应用程序。我不知道如何使用当今可用的工具来完成它。我有 Visual Studio 2008,C# 是我选择的语言。

Say I want to create a source code editor for ocaml programming language, where do I start? I am looking to create an editor for the Windows platform as a hobby project. My primary skill is in web development. I have developed windows apps long time ago. I have no clue how it is done with todays available tools. I have visual studio 2008 and C# is my language of choice.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

栩栩如生 2024-09-07 04:28:15

您需要知道:

  • OCAML 语法、功能、关键字、函数等...
  • C#,因为这是您的母语,我想
  • 您需要知道您想要实现哪些功能
  • ...如果它使用 GUI 或仅从 nano 等终端/vim
  • 语法突出显示如何工作
  • 如何打开和保存文件
  • 自动完成如何工作
  • 等。

您可能想看看一些开源编辑器,如 dev-c++ 或 gedit

另外,由于您个人更喜欢 web-devvy,您可能想要开始创建一个在网络浏览器中运行的程序。这通常更容易,并且可以帮助您了解创建代码编辑器的基础知识。稍后您可以随时为桌面编写一个。

You need to know:

  • OCAML Syntax, Features, Keywords, Functions etc...
  • C# as this is your native language I guess
  • You need to know what features you wanna implement
  • ...if it's using a GUI or just from a terminal like nano/vim
  • how syntax highlighting works
  • how to open and save files
  • how autocompletion works
  • etc..

You might want to take look at some open source editors like dev-c++ or gedit

Also, as you in person are more web-devvy, you might want to start creating one which runs in a web browser. This is often easier and helps you understand the basics of creating a code editor. Later you can always write one for desktops.

猫卆 2024-09-07 04:28:15

如果您最熟悉 Visual Studio,那么您可以使用 Visual Studio Shell 在此基础上创建您自己的 IDE。

这是一个播客,提供了很好的概述:
http://www.code- magazine.com/codecast/index.aspx?messageid=32b9401a-140d-4acb-95bb-6accd3a3dafc

另外,作为参考,IronPython Studio 是使用 Visual Studio 2008 Shell 创建的:
http://ironpythonstudio.codeplex.com/

浏览源代码应该会给你一个很好的起点。

If you are most comfortable in Visual Studio, then you can use the Visual Studio Shell to create your own IDE based on that foundation.

Here is a podcast that gives a good overview:
http://www.code-magazine.com/codecast/index.aspx?messageid=32b9401a-140d-4acb-95bb-6accd3a3dafc

Also, as a reference, the IronPython Studio was created using the Visual Studio 2008 Shell:
http://ironpythonstudio.codeplex.com/

Browsing that source code should give you a good starting point.

吃不饱 2024-09-07 04:28:15

一个更轻量级的替代方案是使用 RichEdit 控件

示例:
http://www.codeproject.com/Messages/3401956/NET- Richedit-Control.aspx

// http://www.codeproject.com/Messages/3401956/NET-Richedit-Control.aspx

using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace RichEditor
{
    public class RichTextBoxEx : RichTextBox    
    {
        IntPtr mHandle = IntPtr.Zero;

        protected override CreateParams CreateParams        
        {
            get
            {
                // Prevent module being loaded multiple times.
                if (this.mHandle == IntPtr.Zero)                
                {
                    // load the library to obtain an instance of the RichEdit50 class.
                    this.mHandle = LoadLibrary("msftedit.dll");                
                }
                // If module loaded, reset ClassName.
                if (this.mHandle != IntPtr.Zero)                 
                {
                    CreateParams cParams = base.CreateParams;
                    // Check Unicode or ANSI system and set appropriate ClassName.
                    if (Marshal.SystemDefaultCharSize == 1)                     
                    {
                        cParams.ClassName = "RichEdit50A";                    
                    }
                    else
                    {
                        cParams.ClassName = "RichEdit50W";                    
                    }
                    return cParams;                
                }
                else // Module wasnt loaded, return default .NET RichEdit20 CreateParams.                
                {
                    return base.CreateParams;                
                }
            }
        }

        ~RichTextBoxEx()        
        {
            //Free loaded Library.
            if (mHandle != IntPtr.Zero)            
            {
                FreeLibrary(mHandle);            
            }
        }

        [DllImport("kernel32.dll", SetLastError = true)]
        private static extern IntPtr LoadLibrary(String lpFileName);

        [DllImport("kernel32.dll", SetLastError = true)]
        private static extern bool FreeLibrary(IntPtr hModule);    
    }

}

a lighter-weight alternative is to use the RichEdit control

example:
http://www.codeproject.com/Messages/3401956/NET-Richedit-Control.aspx

// http://www.codeproject.com/Messages/3401956/NET-Richedit-Control.aspx

using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace RichEditor
{
    public class RichTextBoxEx : RichTextBox    
    {
        IntPtr mHandle = IntPtr.Zero;

        protected override CreateParams CreateParams        
        {
            get
            {
                // Prevent module being loaded multiple times.
                if (this.mHandle == IntPtr.Zero)                
                {
                    // load the library to obtain an instance of the RichEdit50 class.
                    this.mHandle = LoadLibrary("msftedit.dll");                
                }
                // If module loaded, reset ClassName.
                if (this.mHandle != IntPtr.Zero)                 
                {
                    CreateParams cParams = base.CreateParams;
                    // Check Unicode or ANSI system and set appropriate ClassName.
                    if (Marshal.SystemDefaultCharSize == 1)                     
                    {
                        cParams.ClassName = "RichEdit50A";                    
                    }
                    else
                    {
                        cParams.ClassName = "RichEdit50W";                    
                    }
                    return cParams;                
                }
                else // Module wasnt loaded, return default .NET RichEdit20 CreateParams.                
                {
                    return base.CreateParams;                
                }
            }
        }

        ~RichTextBoxEx()        
        {
            //Free loaded Library.
            if (mHandle != IntPtr.Zero)            
            {
                FreeLibrary(mHandle);            
            }
        }

        [DllImport("kernel32.dll", SetLastError = true)]
        private static extern IntPtr LoadLibrary(String lpFileName);

        [DllImport("kernel32.dll", SetLastError = true)]
        private static extern bool FreeLibrary(IntPtr hModule);    
    }

}
醉城メ夜风 2024-09-07 04:28:15

您可以使用 Scintilla。它具有语法突出显示和其他一些功能。此外,此处还提供了 .NET 版本。

另一个不错的工具是Alsing Syntax Box

强大的语法高亮窗口
Microsoft.NET 的表单控件
平台。用 100% 托管 C# 编写。
支持语法高亮和代码
折叠几乎适用于任何编程
语言。

使用 Alsing Syntax Box,您可以定义语法文件(就像 这个用于 C#),后来有一个 智能感知之类的功能

您可以为您的编辑器从其中之一开始。

You could use Scintilla. It has syntax highlighting and some other features. Also, it has a .NET Version available here.

Another good tool is Alsing Syntax Box:

Powerful Syntax Highlight Windows
Forms Control for the Microsoft.NET
Platform. Written in 100% managed C#.
Supports syntax highlighting and code
folding for just about any programming
language.

With Alsing Syntax Box, you can define a syntax file (just like this one for C#) and later have a intellisense like feature.

You can start with one of them for your editor.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文