-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 8f191d6
Showing
5 changed files
with
155 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
.DS_Store |
This file contains 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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
brackets-minimap-extension | ||
============================ | ||
|
||
Work in progress... | ||
|
||
Install | ||
=== | ||
|
||
Please download zip and extract into arbitrary directory (or clone source files), then move the folder to the extensions folder (you can open this folder by clicking "Help > Show Extensions Folder" menu). |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#mini-map { | ||
|
||
position: fixed; | ||
top: 37px; | ||
width: 70px; | ||
right:0; | ||
margin-right:86px; | ||
z-index: 21; | ||
} | ||
|
||
#mini-map .selection { | ||
top:-2px; | ||
position: absolute; | ||
width:141px; | ||
border-radius:3px; | ||
background-color:rgba(0,0,0, 0.1); | ||
z-index:22; | ||
} | ||
|
||
#mini-map pre { | ||
|
||
font-family: 'SourceCodePro', monospace; | ||
white-space: pre; | ||
word-wrap: normal; | ||
border-color:transparent; | ||
font-size:2px; | ||
line-height:1px; | ||
padding: 0; | ||
margin:0; | ||
background:transparent; | ||
overflow:hidden; | ||
width:135px; | ||
|
||
} | ||
|
This file contains 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 |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/*jslint vars: true, plusplus: true, devel: true, nomen: true, regexp: true, indent: 4, maxerr: 50 */ | ||
/*global define, $, brackets, window */ | ||
|
||
define(function (require, exports, module) { | ||
"use strict"; | ||
|
||
require('jquery-ui-1.9.2.custom.min'); | ||
|
||
var CommandManager = brackets.getModule("command/CommandManager"), | ||
EditorManager = brackets.getModule("editor/EditorManager"), | ||
ExtensionUtils = brackets.getModule("utils/ExtensionUtils"), | ||
Editor = brackets.getModule("editor/Editor").Editor, | ||
DocumentManager = brackets.getModule("document/DocumentManager"), | ||
EditorUtils = brackets.getModule("editor/EditorUtils"), | ||
Menus = brackets.getModule("command/Menus"), | ||
COMMAND_ID = "me.drewh.brackets.minimap"; | ||
|
||
var loadCSSPromise = ExtensionUtils.loadStyleSheet(module, 'main.css'); | ||
|
||
|
||
function _change(text) { | ||
$('#mini-map-code').html(text); | ||
} | ||
|
||
function _drawMap() { | ||
$('.main-view').append('<div id="mini-map"><div class="selection"></div><div class="cm-s-default" id="mini-map-code"></div></div>'); | ||
} | ||
|
||
function lineToPx(line) { | ||
return line * 4; | ||
} | ||
|
||
|
||
function pxToLine(px) { | ||
return px / 4; | ||
} | ||
|
||
|
||
function _documentChange() { | ||
|
||
var miniSelectionEl = $('#mini-map .selection'); | ||
var drag = false; | ||
var height = $(window).height(); | ||
|
||
var editor = EditorManager.getCurrentFullEditor(); | ||
|
||
var lineCount = editor.lineCount(); | ||
|
||
console.log(lineCount); | ||
console.log(editor.totalHeight(true)); | ||
|
||
var doc = DocumentManager.getCurrentDocument(); | ||
//var doc = editor.document; | ||
|
||
if (doc) { | ||
console.log($('.CodeMirror-lines div div:eq(2)').html()); | ||
_change($('.CodeMirror-lines div div:eq(2)').html()); | ||
|
||
$(doc).on('change', function () { | ||
_change($('.CodeMirror-lines div div:eq(2)').html()); | ||
}); | ||
|
||
miniSelectionEl.css({ | ||
height: lineToPx(68) + 'px' | ||
}); | ||
|
||
// miniSelectionEl.draggable({ | ||
// containment: "parent", | ||
// start: function () { | ||
// drag = true; | ||
// }, | ||
// drag: function () { | ||
// drag = true; | ||
// var x = editor.getScrollPos().x; | ||
// var y = $('#mini-map .selection').offset().top - 40; | ||
// editor.setScrollPos(x, y); | ||
// }, | ||
// stop: function () { | ||
// drag = false; | ||
// } | ||
// }); | ||
// | ||
// $(editor).on('scroll', function () { | ||
// if (drag === false) { | ||
// var y = editor.getScrollPos().y / 10; | ||
// miniSelectionEl.css({ | ||
// 'top': y + 'px' | ||
// }); | ||
// } | ||
// }); | ||
} | ||
} | ||
|
||
|
||
|
||
loadCSSPromise.then(function () { | ||
_drawMap(); | ||
_documentChange(); | ||
$(DocumentManager).on('currentDocumentChange', function (e) { | ||
_documentChange(); | ||
}); | ||
}); | ||
|
||
}); |