Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
drewhamlett committed Dec 27, 2012
0 parents commit 8f191d6
Show file tree
Hide file tree
Showing 5 changed files with 155 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.DS_Store
9 changes: 9 additions & 0 deletions README.md
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).
6 changes: 6 additions & 0 deletions jquery-ui-1.9.2.custom.min.js

Large diffs are not rendered by default.

35 changes: 35 additions & 0 deletions main.css
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;

}

104 changes: 104 additions & 0 deletions main.js
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();
});
});

});

0 comments on commit 8f191d6

Please sign in to comment.