当前位置:首页 » 操作系统 » 代码编辑器源码

代码编辑器源码

发布时间: 2022-05-21 09:03:51

1. 源码编辑器的电脑网址

摘要 1、CodePen

2. 如何打开wordpress源代码编辑器

WP后台管理-用户-个人资料-可视化编辑器选项,可选可不选。
在发布文章的页面上,右上角就有个html的标记,那个就是源码编辑。

3. java源代码编辑器

大的有eclipse 或者 netbeans 200M,小的 jcreator 10M左右.
不发了.
网上一搜一箩筐.

4. linux操作系统下的文本编辑器源代码

vim编辑器的官网下载链接,有源码下载:
http://www.vim.org/download.php

emacs的源码下载链接:
ftp://ftp.gnu.org/pub/gnu/emacs

5. java源代码编辑器 设计用于编写Java源代码的编辑器,基本要求:可以完成源程序的文件打开,编辑和文件保存

一. 高亮的内容:
需要高亮的内容有:
1. 关键字, 如 public, int, true 等.
2. 运算符, 如 +, -, *, /等
3. 数字
4. 高亮字符串, 如 "example of string"
5. 高亮单行注释
6. 高亮多行注释

二. 实现高亮的核心方法:
StyledDocument.setCharacterAttributes(int offset, int length, AttributeSet s, boolean replace)

三. 文本编辑器选择.
Java中提供的多行文本编辑器有: JTextComponent, JTextArea, JTextPane, JEditorPane等, 都可以使用. 但是因为语法着色中文本要使用多种风格的样式, 所以这些文本编辑器的document要使用StyledDocument.
JTextArea使用的是PlainDocument, 此document不能进行多种格式的着色.
JTextPane, JEditorPane使用的是StyledDocument, 默认就可以使用.
为了实现语法着色, 可以继承自DefaultStyledDocument, 设置其为这些文本编辑器的documet, 或者也可以直接使用JTextPane, JEditorPane来做. 为了方便, 这里就直接使用JTextPane了.

四. 何时进行着色.
当文本编辑器中有字符被插入或者删除时, 文本的内容就发生了变化, 这时检查, 进行着色.
为了监视到文本的内容发生了变化, 要给document添加一个DocumentListener监听器, 在他的removeUpdate和insertUpdate中进行着色处理.
而changedUpdate方法在文本的属性例如前景色, 背景色, 字体等风格改变时才会被调用.
@Override
public void changedUpdate(DocumentEvent e) {

}

@Override
public void insertUpdate(DocumentEvent e) {
try {
colouring((StyledDocument) e.getDocument(), e.getOffset(), e.getLength());
} catch (BadLocationException e1) {
e1.printStackTrace();
}
}

@Override
public void removeUpdate(DocumentEvent e) {
try {
// 因为删除后光标紧接着影响的单词两边, 所以长度就不需要了
colouring((StyledDocument) e.getDocument(), e.getOffset(), 0);
} catch (BadLocationException e1) {
e1.printStackTrace();
}
}

五. 着色范围:
pos: 指变化前光标的位置.
len: 指变化的字符数.
例如有关键字public, int
单词"publicint", 在"public"和"int"中插入一个空格后变成"public int", 一个单词变成了两个, 这时对"public" 和 "int"进行着色.
着色范围是public中p的位置和int中t的位置加1, 即是pos前面单词开始的下标和pos+len开始单词结束的下标. 所以上例中要着色的范围是"public int".
提供了方法indexOfWordStart来取得pos前单词开始的下标, 方法indexOfWordEnd来取得pos后单词结束的下标.
public int indexOfWordStart(Document doc, int pos) throws BadLocationException {
// 从pos开始向前找到第一个非单词字符.
for (; pos > 0 && isWordCharacter(doc, pos - 1); --pos);
return pos;
}

public int indexOfWordEnd(Document doc, int pos) throws BadLocationException {
// 从pos开始向前找到第一个非单词字符.
for (; isWordCharacter(doc, pos); ++pos);
return pos;
}

一个字符是单词的有效字符: 是字母, 数字, 下划线.
public boolean isWordCharacter(Document doc, int pos) throws BadLocationException {
char ch = getCharAt(doc, pos); // 取得在文档中pos位置处的字符
if (Character.isLetter(ch) || Character.isDigit(ch) || ch == '_') { return true; }
return false;
}

所以着色的范围是[start, end] :
int start = indexOfWordStart(doc, pos);
int end = indexOfWordEnd(doc, pos + len);

六. 关键字着色.
从着色范围的开始下标起进行判断, 如果是以字母开或者下划线开头, 则说明是单词, 那么先取得这个单词, 如果这个单词是关键字, 就进行关键字着色, 如果不是, 就进行普通的着色. 着色完这个单词后, 继续后面的着色处理. 已经着色过的字符, 就不再进行着色了.
public void colouring(StyledDocument doc, int pos, int len) throws BadLocationException {
// 取得插入或者删除后影响到的单词.
// 例如"public"在b后插入一个空格, 就变成了:"pub lic", 这时就有两个单词要处理:"pub"和"lic"
// 这时要取得的范围是pub中p前面的位置和lic中c后面的位置
int start = indexOfWordStart(doc, pos);
int end = indexOfWordEnd(doc, pos + len);

char ch;
while (start < end) {
ch = getCharAt(doc, start);
if (Character.isLetter(ch) || ch == '_') {
// 如果是以字母或者下划线开头, 说明是单词
// pos为处理后的最后一个下标
start = colouringWord(doc, start);
} else {
//SwingUtilities.invokeLater(new ColouringTask(doc, pos, wordEnd - pos, normalStyle));
++start;
}
}
}

public int colouringWord(StyledDocument doc, int pos) throws BadLocationException {
int wordEnd = indexOfWordEnd(doc, pos);
String word = doc.getText(pos, wordEnd - pos); // 要进行着色的单词

if (keywords.contains(word)) {
// 如果是关键字, 就进行关键字的着色, 否则使用普通的着色.
// 这里有一点要注意, 在insertUpdate和removeUpdate的方法调用的过程中, 不能修改doc的属性.
// 但我们又要达到能够修改doc的属性, 所以把此任务放到这个方法的外面去执行.
// 实现这一目的, 可以使用新线程, 但放到swing的事件队列里去处理更轻便一点.
SwingUtilities.invokeLater(new ColouringTask(doc, pos, wordEnd - pos, keywordStyle));
} else {
SwingUtilities.invokeLater(new ColouringTask(doc, pos, wordEnd - pos, normalStyle));
}

return wordEnd;
}

因为在insertUpdate和removeUpdate方法中不能修改document的属性, 所以着色的任务放到这两个方法外面, 所以使用了SwingUtilities.invokeLater来实现.
private class ColouringTask implements Runnable {
private StyledDocument doc;
private Style style;
private int pos;
private int len;

public ColouringTask(StyledDocument doc, int pos, int len, Style style) {
this.doc = doc;
this.pos = pos;
this.len = len;
this.style = style;
}

public void run() {
try {
// 这里就是对字符进行着色
doc.setCharacterAttributes(pos, len, style, true);
} catch (Exception e) {}
}
}

七: 源码
关键字着色的完成代码如下, 可以直接编译运行. 对于数字, 运算符, 字符串等的着色处理在以后的教程中会继续进行详解.
import java.awt.Color;
import java.util.HashSet;
import java.util.Set;

import javax.swing.JFrame;
import javax.swing.JTextPane;
import javax.swing.SwingUtilities;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
import javax.swing.text.Style;
import javax.swing.text.StyleConstants;
import javax.swing.text.StyledDocument;

public class HighlightKeywordsDemo {
public static void main(String[] args) {
JFrame frame = new JFrame();

JTextPane editor = new JTextPane();
editor.getDocument().addDocumentListener(new SyntaxHighlighter(editor));
frame.getContentPane().add(editor);

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(500, 500);
frame.setVisible(true);
}
}

/**
* 当文本输入区的有字符插入或者删除时, 进行高亮.
*
* 要进行语法高亮, 文本输入组件的document要是styled document才行. 所以不要用JTextArea. 可以使用JTextPane.
*
* @author Biao
*
*/
class SyntaxHighlighter implements DocumentListener {
private Set<String> keywords;
private Style keywordStyle;
private Style normalStyle;

public SyntaxHighlighter(JTextPane editor) {
// 准备着色使用的样式
keywordStyle = ((StyledDocument) editor.getDocument()).addStyle("Keyword_Style", null);
normalStyle = ((StyledDocument) editor.getDocument()).addStyle("Keyword_Style", null);
StyleConstants.setForeground(keywordStyle, Color.RED);
StyleConstants.setForeground(normalStyle, Color.BLACK);

// 准备关键字
keywords = new HashSet<String>();
keywords.add("public");
keywords.add("protected");
keywords.add("private");
keywords.add("_int9");
keywords.add("float");
keywords.add("double");
}

public void colouring(StyledDocument doc, int pos, int len) throws BadLocationException {
// 取得插入或者删除后影响到的单词.
// 例如"public"在b后插入一个空格, 就变成了:"pub lic", 这时就有两个单词要处理:"pub"和"lic"
// 这时要取得的范围是pub中p前面的位置和lic中c后面的位置
int start = indexOfWordStart(doc, pos);
int end = indexOfWordEnd(doc, pos + len);

char ch;
while (start < end) {
ch = getCharAt(doc, start);
if (Character.isLetter(ch) || ch == '_') {
// 如果是以字母或者下划线开头, 说明是单词
// pos为处理后的最后一个下标
start = colouringWord(doc, start);
} else {
SwingUtilities.invokeLater(new ColouringTask(doc, start, 1, normalStyle));
++start;
}
}
}

/**
* 对单词进行着色, 并返回单词结束的下标.
*
* @param doc
* @param pos
* @return
* @throws BadLocationException
*/
public int colouringWord(StyledDocument doc, int pos) throws BadLocationException {
int wordEnd = indexOfWordEnd(doc, pos);
String word = doc.getText(pos, wordEnd - pos);

if (keywords.contains(word)) {
// 如果是关键字, 就进行关键字的着色, 否则使用普通的着色.
// 这里有一点要注意, 在insertUpdate和removeUpdate的方法调用的过程中, 不能修改doc的属性.
// 但我们又要达到能够修改doc的属性, 所以把此任务放到这个方法的外面去执行.
// 实现这一目的, 可以使用新线程, 但放到swing的事件队列里去处理更轻便一点.
SwingUtilities.invokeLater(new ColouringTask(doc, pos, wordEnd - pos, keywordStyle));
} else {
SwingUtilities.invokeLater(new ColouringTask(doc, pos, wordEnd - pos, normalStyle));
}

return wordEnd;
}

/**
* 取得在文档中下标在pos处的字符.
*
* 如果pos为doc.getLength(), 返回的是一个文档的结束符, 不会抛出异常. 如果pos<0, 则会抛出异常.
* 所以pos的有效值是[0, doc.getLength()]
*
* @param doc
* @param pos
* @return
* @throws BadLocationException
*/
public char getCharAt(Document doc, int pos) throws BadLocationException {
return doc.getText(pos, 1).charAt(0);
}

/**
* 取得下标为pos时, 它所在的单词开始的下标. ±wor^d± (^表示pos, ±表示开始或结束的下标)
*
* @param doc
* @param pos
* @return
* @throws BadLocationException
*/
public int indexOfWordStart(Document doc, int pos) throws BadLocationException {
// 从pos开始向前找到第一个非单词字符.
for (; pos > 0 && isWordCharacter(doc, pos - 1); --pos);

return pos;
}

/**
* 取得下标为pos时, 它所在的单词结束的下标. ±wor^d± (^表示pos, ±表示开始或结束的下标)
*
* @param doc
* @param pos
* @return
* @throws BadLocationException
*/
public int indexOfWordEnd(Document doc, int pos) throws BadLocationException {
// 从pos开始向前找到第一个非单词字符.
for (; isWordCharacter(doc, pos); ++pos);

return pos;
}

/**
* 如果一个字符是字母, 数字, 下划线, 则返回true.
*
* @param doc
* @param pos
* @return
* @throws BadLocationException
*/
public boolean isWordCharacter(Document doc, int pos) throws BadLocationException {
char ch = getCharAt(doc, pos);
if (Character.isLetter(ch) || Character.isDigit(ch) || ch == '_') { return true; }
return false;
}

@Override
public void changedUpdate(DocumentEvent e) {

}

@Override
public void insertUpdate(DocumentEvent e) {
try {
colouring((StyledDocument) e.getDocument(), e.getOffset(), e.getLength());
} catch (BadLocationException e1) {
e1.printStackTrace();
}
}

@Override
public void removeUpdate(DocumentEvent e) {
try {
// 因为删除后光标紧接着影响的单词两边, 所以长度就不需要了
colouring((StyledDocument) e.getDocument(), e.getOffset(), 0);
} catch (BadLocationException e1) {
e1.printStackTrace();
}
}

/**
* 完成着色任务
*
* @author Biao
*
*/
private class ColouringTask implements Runnable {
private StyledDocument doc;
private Style style;
private int pos;
private int len;

public ColouringTask(StyledDocument doc, int pos, int len, Style style) {
this.doc = doc;
this.pos = pos;
this.len = len;
this.style = style;
}

public void run() {
try {
// 这里就是对字符进行着色
doc.setCharacterAttributes(pos, len, style, true);
} catch (Exception e) {}
}
}
}

6. 百度UEditor编辑器源代码编辑模式用CSS会被转义,有解决方法吗

最新的 ueditor 已经不存在这个问题。demo:UEditor - 示例
请不要再评论此答案,谢谢。

以下文字编辑于2013-08-17:

不同意前面两人的观点,ueditor对style进行编码是一种非常多余的行为。
既然编辑器提供了html编辑方式,毫无疑问这个功能是给懂html的人提供的。
富文本编辑器一般都可以写标签内样式,所以普通用户也可以通过html模式让页面乱掉,和提不提供自定义css没关系。
还有说防止注入的。前端做不了安全,要安全只能靠后端实现。所以这个不成立。
但是他最后一句我还是非常赞同的,如果有精力可以专门制定一套样式,在编辑文章的时候直接设置class就行,便于风格一致。

我以前用php写过博客,也是用的ueditor。刚刚试了一下,里面的ueditor可以插入style而不会被转移。
因为ueditor的config里面没有版本信息,我不知道那是什么版本。我写那套程序是12年初,到现在已经一年半了,所以那是个比较老的版本。不过功能貌似都正常,如果你要可以私信我。
-----------------------------
继续说。
刚刚想了想,其实这个功能在一定程度上可以起到安全作用,可以阻止那些html入门者搞破坏,但是如果一个对js熟悉的人想要在页面插入css js,前端是阻止不了的。
ueditor的config里面也提供了blacklist,可以过滤掉标签。所以把style内容编码成url编码相当奇怪,不知道谁可以有一个合理的解释。
-----------------------------
言归正传,因为我发现提问者很没耐心。OK,说说解决方法。
这种编码是通过encodeURIComponent()方法实现的。那么就改它的源代码,去掉源文件中编码style标签内容的代码。
打开ueditor.all.min.js或者ueditor.all.js,搜索encodeURIComponent,可以找到四个结果。
其中有一处是:
case "style":
case "script":
node.setAttr({
cdata_tag: node.tagName,
cdata_data: encodeURIComponent(node.innerText() || "")
});
node.tagName = "div";
node.removeChild(node.firstChild());
break;

删除case 'style':就行。如果你还想插入script,就删掉全部。

7. java文本编辑器源代码

import java.awt.*; import javax.swing.*; import java.awt.event.*; import javax.swing.event.*; import java.util.*; //Date needed import java.io.PrintWriter; public class NotePad extends JFrame { JTextArea jta; class newl implements ActionListener { public void actionPerformed(ActionEvent e) { jta.setText(""); } } class openl implements ActionListener { public void actionPerformed(ActionEvent e) { JFileChooser jf=new JFileChooser(); jf.showOpenDialog(NotePad.this); } } //保存文件的监听 class savel implements ActionListener { public void actionPerformed(ActionEvent e) { JFileChooser jf = new JFileChooser(); 写不了那么多啊 http://..com/question/87179404.html详细看这里把

8. linux有什么源代码编辑器

Linux程序员经常抱怨,自从他们使用了免费开源的系统平台后,作为一名程序员,却并没有在代码编辑器上得到足够的重视。他们往往会认为Linux平台上的代码编辑器太少了,以至于影响他们的编程工作。但是事实并非如此,在Linux平台上有太多的代码编辑器供你使用了,下面我们分享了7个最受Linux程序员欢迎的代码编辑器,继续在编程的路上前行吧!

1、Eclipse
Eclipse是一款很酷的开源代码编辑器,同时它也是最受程序员亲睐的代码编辑器之一,它拥有代码高亮和智能提示等强大的功能。在Eclipse中,你可以完全胜任以下编程语言的工作——Python, R, Ruby, JavaScript, Natural, Lasso, C, C++, COBOL, Scheme, Clojure, Groovy等等,它也是非常着名的Java集成开发环境,甚至提供了对Java 8的支持。在一些Web开发IDE特性的帮助下,你可以非常方便地对代码文件进行组织和访问

2、Light Table
Light Table将会是一款彻底改变Linux编辑器概念的代码编辑器,它提供了直观和易用的编程界面。并且Light Table可以很方便地进行定制功能,因为它也是开源的。它有一个强大的插件管理器,这样你就不用在网上漫无目的的寻找需要的插件了。

3、Sublime Text 3
这是一款绝对值得一提的Linux代码编辑器,因为它有简单而且超酷的功能特性。Sublime Text 3最独特的地方就是它没有独特的功能,它仅仅是一个简单的代码编辑器,有了它,你就可以非常方便地对多行代码进行修改了。利用Sublime Text 3你可以做操作文件、重命名变量、分离编辑和其他有趣的操作。

4、Brackets
Brackets也是一款为Linux开发者设计的开源代码编辑器,使用Brackets写代码,你不会被任何事情所打断。比如在写HTML代码时,即便你没有保存代码也可以及时预览你的Web页面效果。你也可以使用Theseus来检查变量,Brackets默认提供一种主题,当然你也可以在扩展中心获取更多的主题。

5、Dart Editor
Dart Editor是Google开发设计的,旨在帮助开发者制作光亮而惊叹的Web应用。Dart Editor支持多种开发语言,同时也集成了Dartium。通过它的静态分析引擎,你可以创建,维护,调试和开发自己的Web应用。函数、类、方法等都能以树的结构列出来,方便你编写代码。

6、Vim
Vim是从 vi 发展出来的一个文本编辑器。代码补完、编译及错误跳转等方便编程的功能特别丰富,在程序员中被广泛使用。和Emacs并列成为类Unix系统用户最喜欢的编辑器。

7、Emacs
Emacs不仅仅是一个编辑器,他是一个整合环境,或可称它为集成开发环境,这些功能如让使用者置身于全功能的操作系统中。Emacs不仅可以作为文本编辑器,还可以用来收发电子邮件、通过FTP/TRAMP编辑远程档案、通过Telnet登录主机、上新闻组、登陆IRC和朋友交流、查看日历等功能。

9. 源码编辑器怎么跳跃

步骤如下

1、在源码编辑器中选中一个角色。
2、然后在积木脚本中加载“当开始被点击”的事件。
3、然后加载重复执行的动作。
4、接着加载“下一个动作”的积木块。
5、加载“等待一秒”的积木块,同时也可以修改等待的秒数。
6、最后点击开始运行程序,即可看到角色跳跃。
代码编辑器一般是带有语法高亮,关键字一看就知道,还有括号匹配也能通过不同的颜色看出来,对编写程序很有帮助。有的代码编辑器还可以集成编译环境。编译是从源代码(通常为高级语言)到能直接被计算机或虚拟机执行的目标代码(通常为低级语言或机器言)。然而,也存在从低级语言到高级语言的编译器,这类编译器中用来从由高级语言生成的低级语言代码重新生成高级语言代码的又被叫做反编译器。也有从一种高级语言生成另一种高级语言的编译器,或者生成一种需要进一步处理的的中间代码的编译器(又叫级联)。

10. java语言写一个文本编辑器的源代码

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.event.*;
import java.util.*; //Date needed
import java.io.PrintWriter;
public class NotePad extends JFrame
{
JTextArea jta;
class newl implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
jta.setText("");
}
}

class openl implements ActionListener
{ public void actionPerformed(ActionEvent e)
{
JFileChooser jf=new JFileChooser();
jf.showOpenDialog(NotePad.this);

}

}
//保存文件的监听
class savel implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
JFileChooser jf = new JFileChooser();
jf.showSaveDialog(NotePad.this);

}
}
//打印的监听 ?
class printl implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
// PrintWriter p = new PrintWriter(NotePad.this);
}
}
//退出记事本的监听
class exitl implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
System.exit(0);//退出
}
}

//拷贝的监听
class l implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
jta.();
}
}

//粘贴的监听
class pastel implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
jta.paste();
}
}
//剪切的监听
class cutl implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
jta.cut();
}
}
//查找的监听

//添加日期的监听
class datel implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
Date d=new Date();
jta.append(d.toString());
}
}

//构造函数
public NotePad()
{
jta=new JTextArea("",24,40);
JScrollPane jsp=new JScrollPane(jta);
JMenuBar jmb=new JMenuBar();
JMenu mFile=new JMenu("File");
JMenu mEdit=new JMenu("Edit");

JMenuItem mNew=new JMenuItem("New",KeyEvent.VK_N);
mNew.addActionListener(new newl());
mFile.add(mNew);

JMenuItem mOpen=new JMenuItem("Open",KeyEvent.VK_O);
mOpen.addActionListener(new openl());
mFile.add(mOpen);

JMenuItem mSave=new JMenuItem("Save");
mSave.addActionListener(new savel());
mFile.add(mSave);

mFile.addSeparator(); //添加分割线

JMenuItem mPrint = new JMenuItem("Print");
mPrint.addActionListener(new printl());
mFile.add(mPrint);

mFile.addSeparator(); //添加分割线

JMenuItem mExit=new JMenuItem("Exit");
mExit.addActionListener(new exitl());
mFile.add(mExit);
mFile.setMnemonic(KeyEvent.VK_F);

//编辑菜单的子菜单的处理
JMenuItem jmi;
jmi=new JMenuItem("Copy");
jmi.addActionListener(new l());
mEdit.add(jmi);

jmi=new JMenuItem("Cut");
jmi.addActionListener(new cutl());
mEdit.add(jmi);

jmi=new JMenuItem("Paste");
jmi.addActionListener(new pastel());
mEdit.add(jmi);

mEdit.addSeparator(); //添加分割线

jmi=new JMenuItem("Find");

mEdit.add(jmi);

jmi=new JMenuItem("FindNext");
mEdit.add(jmi);
mEdit.addSeparator();
jmi=new JMenuItem("Select All");
mEdit.add(jmi);
jmi=new JMenuItem("Date/Time");
jmi.addActionListener(new datel());
mEdit.add(jmi);

jmb.add(mFile);
jmb.add(mEdit);

this.setJMenuBar(jmb);

this.getContentPane().add(jsp);
this.setSize(200,200);
this.setVisible(true);
}
//主函数,程序入口点
public static void main(String s[])
{
new NotePad();
}

}

热点内容
html编译成JavaScript 发布:2024-04-29 00:00:15 浏览:367
html编译器手机 发布:2024-04-28 23:59:22 浏览:518
大宇精雕机的密码是多少 发布:2024-04-28 23:50:02 浏览:457
androidapi查询 发布:2024-04-28 23:44:06 浏览:58
怎么升级加密狗 发布:2024-04-28 23:24:57 浏览:665
netgear远程访问 发布:2024-04-28 23:06:18 浏览:532
javaweb整合开发 发布:2024-04-28 23:03:49 浏览:457
福康中国服务器地址 发布:2024-04-28 22:47:20 浏览:746
mcryptphp 发布:2024-04-28 22:29:12 浏览:195
程序源代码加密 发布:2024-04-28 22:10:42 浏览:836