I would like to activate only certain lines for editing. To do this, the other lines should be lightly grayed out. Does anyone have any idea how I can do this? So far I have only found a workaround (see the code below) that does not have the other lines grayed out and can also be selected with [Ctrl] + [A]. The danger is then that the removal works.
this.editor.layoutOverlayWidget()
this.editor.onDidChangeCursorPosition((e) => {
if (e.position.lineNumber < 3 || e.position.lineNumber > 3) {
this.editor.setPosition({
lineNumber: 3,
column: 1
});
}
});
Related
I'm new to android programming, and there isn't so much documentation about SpaceNavigationView.
I want to hide the centerButton and to keep the space given to it.
Here is the menu :
I want to hide the button "sos"
Here is my code :
if (settingsProfils.sos == 1) {
space.setSpaceBackgroundColor(ContextCompat.getColor(getActivity().getApplicationContext(), R.color.gris));
space.setCentreButtonIcon(R.drawable.sos);
space.setActiveCentreButtonIconColor(getResources().getColor(R.color.white));
space.setInActiveCentreButtonIconColor(getResources().getColor(R.color.white));
space.setCentreButtonColor(ContextCompat.getColor(getActivity().getApplicationContext(), R.color.coral_pink));
space.setFont(type);
space.hideCenterButton(1);
} else {
space.setSpaceBackgroundColor(ContextCompat.getColor(getActivity().getApplicationContext(), R.color.gris));
space.setCentreButtonIcon(R.drawable.sos);
space.setActiveCentreButtonIconColor(getResources().getColor(R.color.white));
space.setInActiveCentreButtonIconColor(getResources().getColor(R.color.white));
space.setCentreButtonColor(ContextCompat.getColor(getActivity().getApplicationContext(), R.color.gris));
space.hideCenterButton(0);
}
and this is the result :
The problem is that I want to keep the space given to the button so that the other items in the menu stay in their positions (I mean they can't move).
I solved this by adding :
CentreButton centreButton = space.getCentreButton();
centreButton.setVisibility(INVISIBLE);
And modify the last line in else block by :
space.hideCenterButton(1);
I'm trying to set new formatting for me. Because of this problem.
Before auto format.
After auto format.
I checked Idea Settings. But seems there are not too many settings for Dart. I have removed all the setting with line merging. But above issue still exist. For example. This setting, which should work, but it doesn't.
Any suggestion?
End each line you don't want to be affected by formatting with "//":
[1, 2, 3]
.map((a) => 0) //
.map((a) => 1); //
var x = [
0, 1, 2, //
3, 4, 5 //
];
I have this problem too
My solution is "Select the range I want to auto format and click Ctrl+Alt+L"...
I have given up auto format all...
I want to create a textarea where users can select a part of a text, and I will react according to their selection. So I need to
1) get the start and end positions of the selection text
2) get the position of the focus, if it is in the textarea and there is no selection
It seems that the functions to do so are different from an explorer to another. So could anyone tell me what is the approach to do that in Office Add-in?
I have tried the following 2 ways (ie, select a part of the text in myTextarea, click on button, and then debug the code), they don't seem to be the right functions.
(function() {
"use strict";
Office.initialize = function(reason) {
$(document).ready(function() {
app.initialize();
$('#button').click(showSelection);
});
};
function showSelection() {
// way 1
console.log(document.selection); // undefined
document.getElementById("myTextarea").focus();
var sel = document.selection.createRange(); // Uncaught TypeError: Cannot read property 'createRange' of undefined
selectedText = sel.text;
// way 2
console.log(document.getElementById("myTextarea").selectionstart); // undefined
console.log(document.getElementById("myTextarea").selectionend); // undefined
}
})();
Additionally, it would be great if one could also tell me how to realise the follows by code:
1) select a part of a text, from a start and end positions
2) set the focus at a certain position of the textarea
Edit 1:
I just tried window.getSelection() within my Excel add-in:
function showselection() {
var a = window.getSelection();
var b = window.getSelection().toString();
var c = window.getSelection().getRangeAt(0);
}
After selecting a text in the textarea, and clicking on button, I debugged step by step: the first line made a a = Selection {anchorNode: null, anchorOffset: 0, focusNode: null, focusOffset: 0, is ...; the second line returned "", the third line got an error Home.js:19 Uncaught IndexSizeError: Failed to execute 'getRangeAt' on 'Selection': 0 is not a valid index. It looks like the selection has not been successfully caught...
Here is JSBin without Excel add-in frame, which returns almost same results as above.
Use JQuery.
For instance, the following two lines get the caret position:
function showselection() {
console.log($('#myTextarea')[0].selectionStart);
console.log($('#myTextarea')[0].selectionEnd);
}
There are some plug-ins:
https://github.com/localhost/jquery-fieldselection
http://madapaja.github.io/jquery.selection/
The second one has several short samples with buttons (where we may lose selection). You could either use their API, or look into their code to see which JQuery functions they call.
If the desired selection is just the selected text in the HTML page (and not the user's selection in Excel/Word), then there are some good stackoverflow answers about accessing that selection.
One of the key features of the JavaScript APIs for Office is that they follow an asynchronous model (the code you've written above for showSelection() appears to be synchronous). I'd recommend reading the Excel and Word JS API overview pages to get a feel for how they work. As an example, here's how you'd get the text from a selection:
Word.run(function (context) {
var myRange = context.document.getSelection();
context.load(myRange, 'text');
return context.sync().then(function () {
log("Selection contents: " + myRange.text);
});
})
Then for the other specifics of your question please clarify as requested in my comment. Thanks!
-Michael (PM for Office add-ins)
In Sublime text, by selecting multiple lines, or Ctrl+clicking multiple lines, I can edit all of them at the same time. What I would like, is that the numbers in those rows would be different; increase with each line.
Currently, for example, I would select 6 lines, press Ctrl+Shift+L to get multiple cursors on each of them, then write for example article > h1 { font-weight:normal; }, and what comes out is:
article > h1 { font-weight:normal; }
article > h1 { font-weight:normal; }
article > h1 { font-weight:normal; }
article > h1 { font-weight:normal; }
article > h1 { font-weight:normal; }
article > h1 { font-weight:normal; }
And from here, if I want this to apply to all elements from h1 through h6, I will edit each line manually to change the number.
So my question is, can Sublime Text output an increasing number in each line in this scenario? Or is there another, easier way of changing them manually after they had all been set to 1's?
There are several packages that help you to insert number sequence, including Text Pastry, Insert Nums and so on.
If you use Text Pastry for example, you can achieve what you want by:
Select 6 lines.
Type article > h.
Press ctrl/cmd+alt+n to open the Text Pastry command line.
Enter 1 and press enter.
Type { font-weight:normal; }.
Step 3 and 4 will insert a sequence 1, 2, ... into your current selections.
My question is exactly opposite of this question. So what I'm trying is I'm trying to find a way to lose focus on a cell after user selects an item from the autocomplete combobox in that cell.
$input.autocomplete({
delay: 0,
minLength: 0,
source: args.column.options,
select: function (event, ui) {
$input.val(ui.item.label);
grid.getEditController().commitCurrentEdit();
return false;
}
});
I used this code to lose focus indirectly after finishing with editing. It works fine, however, the cell stays selected somehow.
grid.getEditController().commitCurrentEdit();
I also tried the code below to lose focus but it throws error everytime when I run the code.
grid.setActiveCell();
grid.setSelectedRows(-1);
After selecting an item from the autocomplete combobox, I want the grid to lose focus and select nothing on the viewport of the grid.
Thanks for your answers in advance.
Try calling grid.resetActiveCell().
There was a commit made to the master branch last week that might address your issue: Fix keyboard focus getting trapped when cell has tabbable elements.
You can achieve it as follows,
if (grid.getActiveCell()) {
var row = grid.getActiveCell().row;
var cell = grid.getActiveCell().cell;
grid.gotoCell(row, cell, false);
}