-
Notifications
You must be signed in to change notification settings - Fork 7
New files (NavBar) #24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
PlIlchevski
wants to merge
2
commits into
oxy-compsci:master
Choose a base branch
from
PlIlchevski:Buttons
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/* global require, module, editor, editorState, blockDict, monaco */ | ||
|
||
var BLOCK_DELETE_TYPES = [ | ||
"IfStatement", | ||
"IfStatement", | ||
"ForStatement", | ||
"FunctionDeclaration", | ||
"WhileStatement", | ||
|
@@ -183,8 +183,8 @@ function onPointBackspace() { | |
} | ||
} else if (spansProtectedPunctuation(buffer, ast, [oneBack, cursor])) { | ||
// ignore the backspace if it's something important | ||
// flash editor screen | ||
flash(); | ||
// flash editor screen | ||
flash(); | ||
} else { | ||
charBackspaceBranch(buffer, cursor); | ||
} | ||
|
@@ -234,15 +234,15 @@ function onPointDelete() { | |
} | ||
} else if (spansProtectedPunctuation(buffer, ast, [cursor, oneAhead])) { | ||
// ignore the delete if it's something important | ||
// flash editor screen | ||
flash(); | ||
// flash editor screen | ||
flash(); | ||
} else { | ||
charDeleteBranch(buffer, cursor); | ||
} | ||
} else if (cursor.lineNumber == editorState.cursor.lineNumber) { // if unparsable but on same line | ||
// if inside parentheses when became unparsable | ||
// if inside parentheses when became unparsable | ||
if (editorState.openParenthesis && editorState.closeParenthesis) { | ||
if (positionFromEnd(buffer, cursor) - 1 == editorState.closeParenthesis) { // if directly to left of ) | ||
if (positionFromEnd(buffer, cursor) - 1 == editorState.closeParenthesis) { // if directly to left of ) | ||
// ignore delete if parenthesis | ||
flash(); | ||
} else if (positionFromStart(buffer, cursor) <= editorState.openParenthesis || positionFromEnd(buffer, cursor) <= editorState.closeParenthesis) { // if left of ( or right of ) | ||
|
@@ -287,32 +287,103 @@ function onRangeDelete() { | |
unhighlight(); | ||
} else { | ||
highlight(node.loc.start.line, node.loc.start.column, node.loc.end.line, node.loc.end.column); | ||
} | ||
} | ||
} | ||
updateEditorState(); | ||
} | ||
|
||
/** | ||
/** | ||
* Set value of editor using executeEdits to preserve undo stack | ||
* | ||
* @param {string} newBuffer - String replacing oldBuffer. | ||
* @returns {undefined} | ||
*/ | ||
function setValue(newBuffer) { | ||
// get range of editor model | ||
// get range of editor model | ||
var range = editor.getModel().getFullModelRange(); | ||
// call execute edits on the editor | ||
// call execute edits on the editor | ||
editor.executeEdits(editor.getValue(), [{ identifier: "insert", range: range, text: newBuffer }]); | ||
} | ||
|
||
/** | ||
/** | ||
* Resets the buffer value to the last correct parsed state | ||
* | ||
* @returns {undefined} | ||
*/ | ||
function resetToParsed() { // eslint-disable-line no-unused-vars | ||
setValue(editorState.parsableText); | ||
} | ||
} | ||
|
||
/** | ||
* Undo function | ||
* @returns {undefined} | ||
*/ | ||
function buttonUndo(){ | ||
setValue(editor.getModel().undo()); | ||
} | ||
|
||
/** | ||
* Redo function | ||
* | ||
* @returns {undefined} | ||
*/ | ||
function buttonRedo(){ | ||
setValue(editor.getModel().redo()); | ||
} | ||
|
||
/** | ||
* Zoom in function | ||
* | ||
* @returns {undefined} | ||
*/ | ||
function buttonZoomIn(){ | ||
editor.updateOptions({fontSize: 30 }); | ||
} | ||
|
||
/** | ||
* Zoom out function | ||
* | ||
* @returns {undefined} | ||
*/ | ||
function buttonZoomOut(){ | ||
editor.updateOptions({fontSize: 10 }); | ||
} | ||
|
||
/** | ||
* Default zoom function | ||
* | ||
* @returns {undefined} | ||
*/ | ||
function buttonDefaultZoom(){ | ||
editor.updateOptions({fontSize: 14 }); | ||
} | ||
|
||
/** | ||
* Copy function | ||
* | ||
* @returns {undefined} | ||
*/ | ||
function buttonCopy(){ | ||
document.execCommand('copy', false); | ||
} | ||
|
||
/** | ||
* Cut function | ||
* | ||
* @returns {undefined} | ||
*/ | ||
function buttonCut(){ | ||
document.execCommand('Cut', false); | ||
} | ||
|
||
/** | ||
* Paste function | ||
* | ||
* @returns {undefined} | ||
*/ | ||
function buttonPaste(){ | ||
document.execCommand('Paste', data); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am confused by this line - what's |
||
} | ||
|
||
|
||
// EDITOR INTERFACE CODE | ||
|
@@ -408,16 +479,16 @@ function unhighlight() { | |
highlighted = false; | ||
} | ||
|
||
/** | ||
* Flashes the editor background for 100 ms | ||
* | ||
* @returns {undefined} | ||
/** | ||
* Flashes the editor background for 100 ms | ||
* | ||
* @returns {undefined} | ||
*/ | ||
function flash() { | ||
monaco.editor.setTheme("flash"); | ||
setTimeout(function () { monaco.editor.setTheme("normal"); }, 100); | ||
|
||
} | ||
} | ||
|
||
/** | ||
* Highlights from opening parenthesis to closed parenthesis, inclusive | ||
|
@@ -904,7 +975,7 @@ function getSurroundingProtectedBrace(buffer, ast, cursor) { | |
|
||
/** | ||
* Split a string into sections delimited by Cursors. | ||
* | ||
* | ||
* @param {string} buffer - A string of text from the editor. | ||
* @param {[Cursor]} cursors - Non-empty list of cursors. | ||
* @returns {[string]} - List of sections of the original string. | ||
|
@@ -962,11 +1033,11 @@ function onDidChangeCursorSelection(e) { // eslint-disable-line no-unused-vars | |
var selection = e.selection; | ||
console.log(" [" + | ||
selection.startLineNumber | ||
+ ":" + | ||
+ ":" + | ||
selection.startColumn | ||
+ ", " + | ||
+ ", " + | ||
selection.endLineNumber | ||
+ ":" + | ||
+ ":" + | ||
selection.endColumn | ||
+ "]" | ||
); | ||
|
@@ -1053,7 +1124,7 @@ function updateEditorState() { | |
editorState.cursor = getCursor(); | ||
editorState.sections = splitAtCursors(buffer, [editorState.cursor]); | ||
} | ||
} else { | ||
} else { | ||
editorState.parsable = false; | ||
// if on same line | ||
if (cursor.lineNumber == editorState.cursor.lineNumber) { | ||
|
@@ -1093,12 +1164,12 @@ function positionFromStart(buffer, cursor) { | |
* @returns {string} Position of cursor from end of buffer | ||
*/ | ||
function positionFromEnd(buffer, cursor) { | ||
var splitBuffer = buffer.split("\n"); | ||
var lastPart = splitBuffer.slice(cursor.lineNumber); | ||
var sameLine = splitBuffer.slice(cursor.lineNumber - 1, cursor.lineNumber).join(""); | ||
sameLine = sameLine.split(""); | ||
var splitBuffer = buffer.split("\n"); | ||
var lastPart = splitBuffer.slice(cursor.lineNumber); | ||
var sameLine = splitBuffer.slice(cursor.lineNumber - 1, cursor.lineNumber).join(""); | ||
sameLine = sameLine.split(""); | ||
sameLine = sameLine.slice(cursor.column).join(""); | ||
lastPart.unshift(sameLine); | ||
lastPart.unshift(sameLine); | ||
|
||
return lastPart.join("").length; | ||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll need to add your new functions into this list to fix the lint.