Skip to content
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

New Edit -> Duplicate action with shortcut #672

Merged
merged 1 commit into from
Feb 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ app/resources/locale/**/*.json
ice-build/

# WebStorm IDE project folder
.idea
.idea
8 changes: 4 additions & 4 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<!-- JS ENTRY POINT: -->
<!-- Icestudio depends on many .js files. The main JS file, which is -->
<!-- initially executed, is app.js -->
<!-- If you want to understand the icestudio code, first have a look -->
<!-- If you want to understand the icestudio code, first have a look -->
<!-- to this index.html and then continue with app.js -->
<!----------------------------------------------------------------------->
<!-- NW documentation: -->
Expand Down Expand Up @@ -78,9 +78,9 @@
position:absolute;
top:0;left:0;
overflow:hidden;
z-index:0;
background-color:#7ccff4;
opacity:0.4;
z-index:0;
background-color:#7ccff4;
opacity:0.4;
}
.spinner-wrapper--container{
position:absolute;
Expand Down
30 changes: 16 additions & 14 deletions app/scripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@

//-- Global Icestudio
//-- this is the core system with services, api and communications.
//-- Group inside different object for eficiency model by V8 engine.
//-- Group inside different object for efficiency model by V8 engine.
//-- The global variable should be declared as "var" and not "let"
//-- because is accesible from popups windows
//-- because it is accessible from popups windows
var iceStudio = new Icestudio();

//-- Global CONSOLE. Used for Debugging
Expand All @@ -26,7 +26,7 @@ var iceConsole = new IceLogger();
angular
.module("icestudio", ["ui.bootstrap", "ngRoute", "gettext"])
.run(function (
profile, //-- Icestudio profile file managment
profile, //-- Icestudio profile file management
project,
common,
tools,
Expand Down Expand Up @@ -156,7 +156,7 @@ angular
"common.APIO_HOME_DIR: APIO folder: " + common.APIO_HOME_DIR
);
iceConsole.log(
"common.ENV_DIR: PYthon virtual environment: " + common.ENV_DIR
"common.ENV_DIR: Python virtual environment: " + common.ENV_DIR
);
iceConsole.log(
"common.ENV_BIN_DIR: Executable files: " + common.ENV_BIN_DIR
Expand Down Expand Up @@ -187,14 +187,17 @@ angular
)
);

tools.checkToolchain( () => {}, //-- No callback
false); //-- No error notifications

tools.checkToolchain(
() => {}, //-- No callback
false //-- No error notifications
);
});
} else {
profile.set("board", boards.selectBoard(profile.get("board")).name);
tools.checkToolchain( () => {}, //-- No callback
false); //-- No error notifications
tools.checkToolchain(
() => {}, //-- No callback
false //-- No error notifications
);
}

$("html").attr("lang", profile.get("language"));
Expand All @@ -205,10 +208,10 @@ angular
);
project.updateTitle(gettextCatalog.getString("Untitled"));
});
// setTimeout(function () {
$("#main-icestudio-wrapper").addClass("loaded");
$("#main-icestudio-load-wrapper").addClass("fade-loaded");
setTimeout(function () {
// setTimeout(function () {
$("#main-icestudio-wrapper").addClass("loaded");
$("#main-icestudio-load-wrapper").addClass("fade-loaded");
setTimeout(function () {
$("#main-icestudio-load-wrapper").addClass("loaded");
$("#main-icestudio-load-wrapper").removeClass("fade-loaded");
}, 1000);
Expand All @@ -217,4 +220,3 @@ angular

console.log("->DEBUG: app.js: END");
});

66 changes: 32 additions & 34 deletions app/scripts/controllers/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ angular
shortcuts,
gettextCatalog,

//-- Accesing _package object
//-- Accessing _package object
//-- Defined in module app/scripts/factories/window.js
_package
)
Expand Down Expand Up @@ -73,7 +73,7 @@ angular
//-----------------------------------

//-- Get the Window object
//-- The nw object is globaly available. It contains all the
//-- The nw object is globally available. It contains all the
//-- NWjs APIs
//-- More information:
//-- https://nwjs.readthedocs.io/en/latest/
Expand Down Expand Up @@ -144,7 +144,7 @@ angular
//-------------------------------------------------------------------------
//-- Read the arguments passed to the app
//-- If no arguments, nothing is done (just a blank project)
//-- Currenty there is only one argument to pass: The filename of the
//-- Currently, there is only one argument to pass: The filename of the
//-- icestudio design to open
//-------------------------------------------------------------------------

Expand Down Expand Up @@ -179,9 +179,9 @@ angular
filepath = params["filepath"];
}
//-- No argument through url
//-- Check if there was an argument comming from the command line
//-- If there are arguments is because it has been start by doble
//-- cliking on an .ice file
//-- Check if there was an argument coming from the command line
//-- If there are arguments is because it has been start by double
//-- clicking on an .ice file
else {

//-- Read the arguments from nw API
Expand Down Expand Up @@ -224,7 +224,7 @@ angular
let hasNewVersion =
lastversionReview === false || lastversionReview < _package.version;

//-- Display the version notes, if the option is enable or
//-- Display the version notes, if the option is enabled or
//-- if this is a newer version
if (versionW === "yes" || hasNewVersion) {
$scope.openVersionInfoWindow();
Expand Down Expand Up @@ -288,9 +288,9 @@ angular
$scope.newProject = () => {

//-- Create a new blank icestudio window
//-- A non-existant file is passed as a parameters
//-- It let us distinguis if the new window was created because of
//-- a new file or it was the first window opened
//-- A non-existent file is passed as a parameters
//-- It let us distinguish if the new window was created because of
//-- a new file, or it was the first window opened
utils.newWindow("Untitled.ice");
};

Expand All @@ -303,7 +303,7 @@ angular
$scope.openProjectDialog = function () {

//-- Open the file Dialog
//-- The selecter is passed as a parameter
//-- The selector is passed as a parameter
//-- The html element is located in the menu.html file
utils.openDialog("#input-open-project", function (filepath) {

Expand Down Expand Up @@ -347,7 +347,7 @@ angular
alertify.alert(
gettextCatalog.getString("Save submodule"),
gettextCatalog.getString(
'To save your design you need to lock the keylock and \
'To save your design you need to lock the padlock and \
go to top level design.<br/><br/>If you want to export \
this submodule to a file, execute "Save as" command to do it.'
),
Expand Down Expand Up @@ -407,9 +407,9 @@ angular
alertify.confirm(
gettextCatalog.getString("Export submodule"),
gettextCatalog.getString(
'You are editing a submodule, if you save it, you save only \
'You are editing a submodule, if you save it, you\'ll save only \
the submodule (in this situation "save as" works like \
"export module"), Do you like to continue?'
"export module"). Do you want to continue?'
),
function () {
$scope.doSaveProjectAs(localCallback);
Expand Down Expand Up @@ -617,7 +617,7 @@ angular
}

//---------------------------------------------------------------------
//-- CALLBACK FUNCIONTS for the EDIT MENU
//-- CALLBACK FUNCTIONS for the EDIT MENU
//---------------------------------------------------------------------
$scope.undoGraph = function () {
graph.undo();
Expand Down Expand Up @@ -657,6 +657,10 @@ angular
}
};

$scope.duplicateSelected = function () {
graph.duplicateSelected();
};

$scope.removeSelected = function () {
graph.removeSelected();
};
Expand All @@ -677,12 +681,6 @@ angular
showToolBox();
};

/* redundant: patched via $scope - @mgesteiro
function removeSelected() {
project.removeSelected(); // <- this is justa a wrapper of graph.removeSelected()
}
*/

$scope.fitContent = function () {
graph.fitContent();
};
Expand Down Expand Up @@ -711,7 +709,7 @@ angular
form.process(evt);

//-- If there were errors, the form is not closed
//-- Return without clossing
//-- Return without closing
if (evt.cancel) {
return;
}
Expand All @@ -733,7 +731,7 @@ angular
newLogfile.lastIndexOf(separator) + 1
);

//-- If the file is valid..
//-- If the file is valid ...
if (newLogfile === "" || hd.isValidPath(dirLFile)) {

//-- Set the new file
Expand Down Expand Up @@ -844,7 +842,7 @@ angular
let newPythonPath = form.values[0];
let newPipPath = form.values[1];

//-- If there where no changes.. return
//-- If there where no changes ... return
if ( newPythonPath === pythonEnv.python &&
newPipPath === pythonEnv.pip) {
return;
Expand Down Expand Up @@ -907,7 +905,7 @@ angular
//-- Read the new path
let newExternalCollections = form.values[0];

//-- If there where no changes.. return
//-- If there where no changes ... return
if (newExternalCollections === externalCollections) {
return;
}
Expand Down Expand Up @@ -1156,7 +1154,7 @@ angular
// View/System Info Window
//--
$scope.showSystemInfo = function () {
//-- Write the iformation to the log file:
//-- Write the information to the log file:
iceConsole.log("---------------------");
iceConsole.log(" VIEW/System Info");
iceConsole.log("--------------------");
Expand All @@ -1173,8 +1171,8 @@ angular
iceConsole.log("\n\n");

//-- Build the URL with all the parameters to pass to the window
//-- The encodeURIComponent() function the characteres so that the spaces and
//-- other special characteres can be place on the original URL
//-- The encodeURIComponent() function the characters so that the spaces and
//-- other special characters can be place on the original URL
let URL =
`resources/viewers/system/system.html?version=${common.ICESTUDIO_VERSION}` +
`&base_dir=${encodeURIComponent(common.BASE_DIR)}---` +
Expand Down Expand Up @@ -1347,7 +1345,7 @@ angular
alertify.alert(
gettextCatalog.getString("Build"),
gettextCatalog.getString(
"You can only build at top-level design. Inside submodules you only can <strong>Verify</strong>"
"You can only build at the top-level design. Inside submodules, you can only <strong>Verify</strong>"
),
function () { }
);
Expand All @@ -1372,7 +1370,7 @@ angular
alertify.alert(
gettextCatalog.getString("Upload"),
gettextCatalog.getString(
"You can only upload your design at top-level design. Inside submodules you only can <strong>Verify</strong>"
"You can only upload at the top-level design. Inside submodules, you can only <strong>Verify</strong>"
),
function () { }
);
Expand Down Expand Up @@ -1521,7 +1519,7 @@ angular
'who start this project and was the main developer from 2016/Jan/28 to 2019/Oct',
"</p>",
' <p>Thanks to the rest of <a class="action-open-url-external-browser" href="https://github.com/FPGAwars/icestudio">contributors</a></p>',
' <p><span class="copyleft">&copy;</span> <a class="action-open-url-external-browser" href="http://fpgawars.github.io">FPGAwars</a> 2016-2022</p>',
' <p><span class="copyleft">&copy;</span> <a class="action-open-url-external-browser" href="https://fpgawars.github.io">FPGAwars</a> 2016-2022</p>',
'<img src="resources/images/fpgawars-logo.png">',
" </div>",
"</div>",
Expand Down Expand Up @@ -1589,6 +1587,7 @@ angular
shortcuts.method("copySelected", $scope.copySelected);
shortcuts.method("pasteAndCloneSelected", $scope.pasteAndCloneSelected);
shortcuts.method("pasteSelected", $scope.pasteSelected);
shortcuts.method("duplicateSelected", $scope.duplicateSelected);
shortcuts.method("removeSelected", $scope.removeSelected);
shortcuts.method("selectAll", $scope.selectAll);
shortcuts.method("fitContent", $scope.fitContent);
Expand All @@ -1610,7 +1609,6 @@ angular
// -- Show Floating toolbox
shortcuts.method("showToolBox", $scope.showToolBox);

//shortcuts.method("removeSelected", removeSelected); // moved alongside other EDIT menu options
shortcuts.method("back", function () {
if (graph.isEnabled()) {
graph.removeSelected();
Expand Down Expand Up @@ -1821,7 +1819,7 @@ angular
reName = new RegExp(parsedSearch.name, 'i'); // contains + case insensitive (less restrictive)
if (optionCase === true && optionExact === false) { // contains + case sensitive
reName = new RegExp (parsedSearch.name);
} else if (optionCase === false && optionExact === true) { // exact + case insensitive
} else if (optionCase === false && optionExact === true) { // exact + case-insensitive
reName = new RegExp ("\\b"+parsedSearch.name+"\\b", 'i');
} else if (optionCase === true && optionExact === true) { // exact + case sensitive (most restrictive)
reName = new RegExp ("\\b"+parsedSearch.name+"\\b");
Expand Down Expand Up @@ -1944,7 +1942,7 @@ angular
showToolBox(); // close toolbox
});

//-- dragabble toolbox
//-- draggable toolbox
$(document).on("mousedown", "#iceToolbox .title-bar", function () {
mouseDownTB = true;
});
Expand Down
25 changes: 17 additions & 8 deletions app/scripts/services/graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -1320,6 +1320,23 @@ angular.module('icestudio')
}
};

this.duplicateSelected = function() {
if (hasSelection()) {
utils.duplicateSelected(selection, graph, function (object) {
if (object.version === common.VERSION) {
self.appendDesign(object.design, object.dependencies);
}
});
}
};

this.removeSelected = function () {
if (hasSelection()) {
graph.removeCells(selection.models);
selectionView.cancelSelection();
updateWiresOnObstacles();
}
};

this.selectAll = function () {
disableSelected();
Expand All @@ -1336,14 +1353,6 @@ angular.module('icestudio')
return selection && selection.length > 0;
}

this.removeSelected = function () {
if (hasSelection()) {
graph.removeCells(selection.models);
selectionView.cancelSelection();
updateWiresOnObstacles();
}
};

function disableSelected() {
if (hasSelection()) {
selectionView.cancelSelection();
Expand Down
4 changes: 0 additions & 4 deletions app/scripts/services/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -688,10 +688,6 @@ angular.module('icestudio')
return block;
}

this.removeSelected = function () {
graph.removeSelected();
};

this.clear = function () {
project = _default();
graph.clearAll();
Expand Down
Loading