CodePress is web-based source code editor with syntax highlighting written in JavaScript that colors text in real time while it's being typed in the browser.

It's a lightweight, extensible and simple (compared to similar web-based code editors) script with very good performance with large files (tested with up to 3000 lines).

Go to http://codepress.fermads.net/ for updates.

Demo

Example shows syntax highlighting for PHP, Java, JavaScript, Perl, HTML and CSS.

choose language:

:: Example getting (alert()) original code from CodePress window
:: Example setting code from a hidden textarea to CodePress window

How to use it

Considering you already have a PHP server and http://yourserver/codepress/codepress.php open an empty file editor window

Method 1: Loading files directly from server
  1. Put the iframe below on your page:
    <iframe id="codepress" src="/codepress/codepress.php?action=edit&file=[file]" width="100%" height="400"></iframe>
    Where [file] is the filename (e.g. test.php) to open.
  2. Configure your root path $path['files'] on codepress.php
Method 2: Loading code from textarea (on page load)
  1. Put the iframe below on your page:
    <iframe id="codepress" src="/codepress/codepress.php" width="100%" height="400"></iframe>
  2. Put the textarea below somewhere on your page:
    <textarea id="codepress-onload" lang="[language]">/*your code here*/</textarea>
    Where [language] is the language of your source code (java, javascript, php, perl, html, css).
Method 3: Loading code from textarea (on demand)
  1. Put the iframe below on your page:
    <iframe id="codepress" src="/codepress/codepress.php" width="100%" height="400"></iframe>
  2. Put the textarea below on your page:
    <textarea id="codepress-ondemand" lang="[language]">/*your code here*/</textarea>
  3. Put on your page a call to the CodePress.setCode() function:
    <button onclick="CodePress.setCode('codepress-ondemand')">Load my code</button>
  4. You can call CodePress.setCode() passing as a parameter any id from any other textarea you wish. Just make sure to hide it with display:none. You can also pass language and source code as parameters. e.g.
    CodePress.setCode('javascript',document.someForm.someTextarea.value);
    CodePress.setCode('someTextareaId');
Getting code from CodePress window
Considering you have done one of the 3 methods above
  1. Just call CodePress.getCode()
    e.g. alert(CodePress.getCode())
    var myCode = CodePress.getCode()

About

CodePress is distributed under the LGPL. You can use it as you want. Just keep my credits somewhere around.

Thanks.

Fernando M.A.d.S.