mirror of
https://github.com/claudehohl/Stikked.git
synced 2025-04-25 20:41:20 -05:00
codemirror nicely integrated.
This commit is contained in:
parent
64d98ed739
commit
27b78041c1
115
htdocs/application/config/codemirror_languages.php
Normal file
115
htdocs/application/config/codemirror_languages.php
Normal file
@ -0,0 +1,115 @@
|
||||
<?php
|
||||
/**
|
||||
* Class and Function List:
|
||||
* Function list:
|
||||
* Classes list:
|
||||
*/
|
||||
|
||||
if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
//codemirror languages
|
||||
$config['codemirror_languages'] = array(
|
||||
'html4strict' => 'HTML',
|
||||
'css' => 'CSS',
|
||||
'javascript' => 'JavaScript',
|
||||
'php' => array(
|
||||
'mode' => 'php',
|
||||
'js' => array(
|
||||
array(
|
||||
'codemirror/mode/xml/xml.js'
|
||||
) ,
|
||||
array(
|
||||
'codemirror/mode/javascript/javascript.js'
|
||||
) ,
|
||||
array(
|
||||
'codemirror/mode/css/css.js'
|
||||
) ,
|
||||
array(
|
||||
'codemirror/mode/clike/clike.js'
|
||||
) ,
|
||||
array(
|
||||
'codemirror/mode/php/php.js'
|
||||
) ,
|
||||
) ,
|
||||
) ,
|
||||
'python' => 'Python',
|
||||
'ruby' => 'Ruby',
|
||||
'bash' => 'Bash',
|
||||
'c' => 'C',
|
||||
'cpp' => 'C++',
|
||||
'diff' => 'Diff',
|
||||
'latex' => 'LaTeX',
|
||||
'sql' => 'SQL',
|
||||
'xml' => 'XML',
|
||||
'text' => 'Plain Text',
|
||||
'abap' => 'ABAP',
|
||||
'actionscript' => 'Actionscript',
|
||||
'ada' => 'ADA',
|
||||
'apache' => 'Apache Log',
|
||||
'applescript' => 'AppleScript',
|
||||
'asm' => 'Assembler',
|
||||
'asp' => 'ASP',
|
||||
'autoit' => 'AutoIt',
|
||||
'blitzbasic' => 'Blitzbasic',
|
||||
'bnf' => 'Backus-Naur-Form',
|
||||
'c_mac' => 'C for Macs',
|
||||
'caddcl' => 'CAD DCL',
|
||||
'cadlisp' => 'CAD Lisp',
|
||||
'cfdg' => 'CFDG',
|
||||
'cfm' => 'CFM',
|
||||
'cpp-qt' => 'C++ QT',
|
||||
'csharp' => 'C#',
|
||||
'd' => 'D',
|
||||
'delphi' => 'Delphi',
|
||||
'div' => 'DIV',
|
||||
'dos' => 'DOS',
|
||||
'dot' => 'dot',
|
||||
'eiffel' => 'Eiffel',
|
||||
'fortran' => 'Fortran',
|
||||
'freebasic' => 'FreeBasic',
|
||||
'genero' => 'Genero',
|
||||
'gml' => 'GML',
|
||||
'groovy' => 'Groovy',
|
||||
'haskell' => 'Haskell',
|
||||
'idl' => 'Unoidl',
|
||||
'ini' => 'INI',
|
||||
'inno' => 'Inno Script',
|
||||
'io' => 'Io',
|
||||
'java' => 'Java',
|
||||
'java5' => 'Java 5',
|
||||
'lisp' => 'Lisp',
|
||||
'lua' => 'LUA',
|
||||
'm68k' => 'm68k',
|
||||
'matlab' => 'Matlab',
|
||||
'mirc' => 'mIRC',
|
||||
'mpasm' => 'MPASM',
|
||||
'mysql' => 'MySQL',
|
||||
'nsis' => 'NSIS',
|
||||
'objc' => 'Objective C',
|
||||
'ocaml' => 'ocaml',
|
||||
'oobas' => 'OpenOffice.org Basic',
|
||||
'oracle8' => 'Orcale 8 SQL',
|
||||
'pascal' => 'Pascal',
|
||||
'per' => 'Per',
|
||||
'perl' => 'Perl',
|
||||
'plsql' => 'PL/SQL',
|
||||
'qbasic' => 'QBasic',
|
||||
'rails' => 'Rails',
|
||||
'reg' => 'Registry',
|
||||
'robots' => 'robots.txt',
|
||||
'sas' => 'SAS',
|
||||
'scheme' => 'Scheme',
|
||||
'sdlbasic' => 'sdlBasic',
|
||||
'smalltalk' => 'Smalltalk',
|
||||
'smarty' => 'Smarty',
|
||||
'tcl' => 'TCL',
|
||||
'thinbasic' => 'thinBasic',
|
||||
'tsql' => 'T-SQL',
|
||||
'vb' => 'Visual Basic',
|
||||
'vbnet' => 'VB.NET',
|
||||
'vhdl' => 'VHDL',
|
||||
'visualfoxpro' => 'Visual FoxPro',
|
||||
'winbatch' => 'WinBatch',
|
||||
'xpp' => 'X++',
|
||||
'z80' => 'Z80',
|
||||
);
|
@ -127,8 +127,10 @@ class Main extends CI_Controller
|
||||
function _form_prep($lang = false, $title = '', $paste = '', $reply = false)
|
||||
{
|
||||
$this->load->model('languages');
|
||||
$this->load->config('codemirror_languages');
|
||||
$this->load->helper('form');
|
||||
$data['languages'] = $this->languages->get_languages();
|
||||
$data['codemirror_languages'] = $this->config->item('codemirror_languages');
|
||||
|
||||
if (!$this->input->post('submit'))
|
||||
{
|
||||
|
@ -10,21 +10,16 @@ $this->carabiner->js('stikked.js');
|
||||
$this->carabiner->js('codemirror/codemirror.js');
|
||||
$this->carabiner->display('js');
|
||||
|
||||
if(isset($codemirror_languages[$lang_set]) && gettype($codemirror_languages[$lang_set]) == 'array')
|
||||
{
|
||||
$codemirror_specific = array(
|
||||
'js' => array(
|
||||
array('codemirror/mode/xml/xml.js'),
|
||||
array('codemirror/mode/javascript/javascript.js'),
|
||||
array('codemirror/mode/css/css.js'),
|
||||
array('codemirror/mode/clike/clike.js'),
|
||||
array('codemirror/mode/php/php.js'),
|
||||
)
|
||||
'js' => $codemirror_languages[$lang_set]['js'],
|
||||
);
|
||||
|
||||
$codemirror_specific['js'][] = array('codemirror_exec.js');
|
||||
|
||||
$this->carabiner->group('codemirror', $codemirror_specific);
|
||||
|
||||
$this->carabiner->display('codemirror');
|
||||
echo '<div style="display: none;" id="codemirror_mode">' . $codemirror_languages[$lang_set]['mode'] . '</div>';
|
||||
}
|
||||
|
||||
?>
|
||||
<script>
|
||||
|
@ -1,16 +1,11 @@
|
||||
var CM = window.CM || {}
|
||||
|
||||
CM.init = function() {
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
mode: "application/x-httpd-php",
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById('code'), {
|
||||
mode: $('#codemirror_mode').text(),
|
||||
lineNumbers: true,
|
||||
lineWrapping: true,
|
||||
onCursorActivity: function() {
|
||||
editor.setLineClass(hlLine, null, null);
|
||||
hlLine = editor.setLineClass(editor.getCursor().line, null, "activeline");
|
||||
}
|
||||
});
|
||||
var hlLine = editor.setLineClass(0, "activeline");
|
||||
};
|
||||
|
||||
$(document).ready(function() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user