Skip to content

Commit e8a6415

Browse files
authored
Merge pull request #421 from Jazzelhawk/editor_tweaks2
Editor tweaks
2 parents ac326a6 + ca42c46 commit e8a6415

2 files changed

Lines changed: 21 additions & 2 deletions

File tree

html/starfall/editor.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,22 @@
6464
}
6565
});
6666

67+
editor.commands.addCommand({
68+
name: "space",
69+
bindKey: {win: "Space", mac: "Space"},
70+
exec: function(editor){
71+
editor.insert(" ");
72+
}
73+
});
74+
75+
editor.commands.addCommand({
76+
name: "enter",
77+
bindKey: {win: "Enter", mac: "Enter"},
78+
exec: function(editor){
79+
editor.insert("\n")
80+
}
81+
});
82+
6783
var editSessions = [];
6884
var keyCodes = ace.require('ace/lib/keys')
6985
codeMap = null;

lua/starfall/editor.lua

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,7 @@ if CLIENT then
489489
textPanel:SetKeyboardInputEnabled( true )
490490
textPanel:SetSize( 0, 0 )
491491
textPanel:SetMultiline( true )
492+
textPanel.m_bAllowEnter = false
492493
textPanel.m_bDisableTabbing = true
493494

494495
local html = vgui.Create( "DHTML", editor )
@@ -559,6 +560,8 @@ if CLIENT then
559560
mod = mods.control
560561
if key == KEY_C then
561562
html:Call( [[ console.log( "RUNLUA:SetClipboardText( '" + addslashes(editor.getSelectedText()) + "' )" ) ]] )
563+
elseif key == KEY_X then
564+
html:Call( [[ console.log( "RUNLUA:SetClipboardText( '" + addslashes(editor.getSelectedText()) + "' )" ); editor.insert("") ]] )
562565
elseif key == KEY_SPACE then
563566
SF.Editor.doValidation( true )
564567
elseif key == KEY_S then
@@ -584,8 +587,8 @@ if CLIENT then
584587
function textPanel:OnTextChanged ()
585588
if not ( ( input.IsKeyDown( KEY_LCONTROL ) or input.IsKeyDown( KEY_RCONTROL ) ) and input.IsKeyDown( KEY_SPACE ) ) and
586589
not ( input.IsKeyDown( KEY_LALT ) and not ( input.IsKeyDown( KEY_LCONTROL ) or input.IsKeyDown( KEY_RCONTROL ) ) ) and
587-
self:GetText():len() > 0 then
588-
html:Call( "editor.keyBinding.onTextInput( '" .. self:GetText():JavascriptSafe() .. "' )" )
590+
self:GetText() ~= "" and self:GetText() ~= " " and self:GetText() ~= "\n" then
591+
html:Call( "editor.keyBinding.onTextInput( '" .. self:GetValue():JavascriptSafe() .. "' )" )
589592
end
590593
self:SetText( "" )
591594
end

0 commit comments

Comments
 (0)