Multiline cursor with skipping lines - eclipse

I know Toggle block selection but sometimes I want to skip a line.
int number1;
boolean exist1;
int number2;
boolean exist2;
int number3;
boolean exist3;
I want to change prefix of the number only. I can use replace but prefer something like multiline cursor. I need it like this:
int number1;
int number2;
int number3;
boolean exist1;
boolean exist2;
boolean exist3;

It's not possible to have multiple cursors in Eclipse.
To rearrange lines move them with ALT + UP or ALT + DOWN. Eclipse's block selection mode is sufficient for most cases where you have to change block-arranged statements and you can easily change pre- or postfixes this way.
A handy extension is "AnyEdit" that allows sorting or converting all selected lines.

It's possible, you can use ALT + click.

Related

flutter TexView - Insert values to raw strings

I'm trying to get the flutter package flutter_tex (Link) working.
It renders fine, but I am not able to put my own values into the formula.
Example (factorB is the variables name):
String second = r"<br> $$x={\sqrt{factorB}}$$";
Result:
I also tried the $-operator before the variable like in a dart string, but because a raw string is needed, this doesn't work.
Is there a way to implement variable values in a raw string with this package?
It is not strictly necessary to use a raw string. Doing so just makes it more convenient to type all the back slashs and brackets required in LaTeX code.
You could always work with regular string, this just makes it more incovenient to produce correct LaTeX. Instead, I would suggest manually replacing the placeholder:
int number = 42;
String latex = r"<br> $$x={\sqrt{factorB}}$$";
latex = latex.replaceAll("factorB", number.toString());
If you would like to support more advanced interpolation via expressions,
I would recommend placing all of that logic inside the replace method. This here is an example
int factorB = 17;
int factorB = 1;
String latex = r"exprA(x${exprB}$exprC)²exprD";
latex = latex.replaceAll("exprA", 42);
latex = latex.replaceAll("exprB", factorB >= 0 ? "+" : "");
latex = latex.replaceAll("exprC", factorC >= 0 ? "+" : "");
latex = latex.replaceAll("exprD", 33);

Converting numbers into timestamps (inserting colons at specific places)

I'm using AutoHotkey for this as the code is the most understandable to me. So I have a document with numbers and text, for example like this
120344 text text text
234000 text text
and the desired output is
12:03:44 text text text
23:40:00 text text
I'm sure StrReplace can be used to insert the colons in, but I'm not sure how to specify the position of the colons or ask AHK to 'find' specific strings of 6 digit numbers. Before, I would have highlighted the text I want to apply StrReplace to and then press a hotkey, but I was wondering if there is a more efficient way to do this that doesn't need my interaction. Even just pointing to the relevant functions I would need to look into to do this would be helpful! Thanks so much, I'm still very new to programming.
hfontanez's answer was very helpful in figuring out that for this problem, I had to use a loop and substring function. I'm sure there are much less messy ways to write this code, but this is the final version of what worked for my purposes:
Loop, read, C:\[location of input file]
{
{ If A_LoopReadLine = ;
Continue ; this part is to ignore the blank lines in the file
}
{
one := A_LoopReadLine
x := SubStr(one, 1, 2)
y := SubStr(one, 3, 2)
z := SubStr(one, 5)
two := x . ":" . y . ":" . z
FileAppend, %two%`r`n, C:\[location of output file]
}
}
return
Assuming that the "timestamp" component is always 6 characters long and always at the beginning of the string, this solution should work just fine.
String test = "012345 test test test";
test = test.substring(0, 2) + ":" + test.substring(2, 4) + ":" + test.substring(4, test.length());
This outputs 01:23:45 test test test
Why? Because you are temporarily creating a String object that it's two characters long and then you insert the colon before taking the next pair. Lastly, you append the rest of the String and assign it to whichever String variable you want. Remember, the substring method doesn't modify the String object you are calling the method on. This method returns a "new" String object. Therefore, the variable test is unmodified until the assignment operation kicks in at the end.
Alternatively, you can use a StringBuilder and append each component like this:
StringBuilder sbuff = new StringBuilder();
sbuff.append(test.substring(0,2));
sbuff.append(":");
sbuff.append(test.substring(2,4));
sbuff.append(":");
sbuff.append(test.substring(4,test.length()));
test = sbuff.toString();
You could also use a "fancy" loop to do this, but I think for something this simple, looping is just overkill. Oh, I almost forgot, this should work with both of your test strings because after the last colon insert, the code takes the substring from index position 4 all the way to the end of the string indiscriminately.

How to efficiently move the keyboard cursor

public class Hello2{
public staic int sum(int n, int m)
{
return n + m; // here is cursor
}
//I want move to cursor here
}
I want to move down the cursor under bracket
Is there a efficient way to move down the brackets rather than the arrow keys on the keyboard?
ctrl + n move cursor to next line
enter line feed
enter line feed
here you are 😃

Prevent word wrap in GUI text

I have a MATLAB GUI that allows a user to load a configuration file. I then want the filename to be displayed in a static text field. My problem is that the string is too long for my text field and wraps around. I want the text to display as much of the string as it can without wrapping, prioritizing the end of the string.
For example, if I have a filename 'C:\folders\more\folders\thisismylongfilename.txt', I am currently seeing
C:\folders\more\folders\thisism
ylongfilename.txt
If I use an edit text rather than a static text, I see C:\folders\more\folders\thisism
I would like my text field to display olders\thisismylongfilename.txt, or maybe ...ers\thisismylongfilename.txt. The missing portion can either be "displayed" but outside the visible box, or something I can remove before displaying. I would just need to know how much of the string to remove.
How can I properly display my long string in a fixed width text box?
One way to accomplish this would be read the length of your textbox and shorten the string before you display it.
myString = 'path/to/file/file.txt';
set(handles.textbox,'Units', 'Characters'); %set units to characters for convenience
pos = get(handles.textbox,'Position'); %get the position info
maxLength = floor(pos(3)); %extract the length of the box
if length(myString) > maxLength % cut beginning if string is too long
newStart = length(myString) - maxLength + 1;
displayString = myString(newStart:end);
else
displayString = myString;
end
set(handles.textbox,'String', displayString);

maskedEditColumn datagridview how to use class? is it what i need?

I am trying to mask user's input in a datagridview column and i found this ready class Masked edit column Class that adds a 'mask edit column' option in the column types list. When i select this column type a mask field is being added in the list of column properties. I tried to do my job by adding some mask elements in this 'Mask' field, but when I run the code it didnt restrict me from adding other characters. I re-opened the 'edit columns menu' and I saw that the 'Mask' field was empty.
I want the text cell to accept 20 chars maximum and only: 1.Capital Letters(English & Greek), 2.these three chars(.,-), 3.Numbers 0-9
So as a first test i used only this mask(>????????????????????) but it didnt work as it didnt convert my characters to Uppercase and accepted more than 20 chars when i end the cell edit.
i am not sure the way to go is the Masked Text Box way. i have made many projects on vb and i used to use a loop in the textChanged event of a text box to restrict characters entry. the loop is this : (but i cant use it now in the valueChanged event cause it seems that 'value' doesn't have a selectionStart property.)
Dim charactersDisallowed As String = "!##$%^&*()+=|}{][:;?/><.,~""
Dim theText As String = txtCopies.Text
Dim Letter As String
Dim SelectionIndex As Integer = txtCopies.SelectionStart
Dim Change As Integer
For x As Integer = 0 To txtCopies.Text.Length - 1
Letter = txtCopies.Text.Substring(x, 1)
If charactersDisallowed.Contains(Letter) Then
theText = theText.Replace(Letter, String.Empty)
Change = 1
End If
Next
txtCopies.Text = theText
txtCopies.Select(SelectionIndex - Change, 0)
So,
Is a masked text cell what i need? and if yes( Why is this mask box not keeping the mask i enter? And how can i use this class to do my job?)
What can i alternately do to restrict some characters in a column's cells? (I will then convert to Uppercase on cellEndEdit)
I finally did it by removing the unwanted characters on cellvaluechanged event, which seems that is being raised when I end the cell's edit by for example hitting "Enter".