line-column | Node module to convert efficiently index | Runtime Evironment library
kandi X-RAY | line-column Summary
kandi X-RAY | line-column Summary
Node module to convert efficiently index to/from line-column in a string.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of line-column
line-column Key Features
line-column Examples and Code Snippets
Community Discussions
Trending Discussions on line-column
QUESTION
I can't get fread
in the data.table
package to handle new lines (\n) as intended. They comes out as "\n" rather than a new line (head
show "\\n" instead of "\n"). According to this post below I understand that fread
should be able to handle this situation:
fread and a quoted multi-line column value
I have tried quoting ("string") the values column with the same result. Is there a simple solution or parameter that I have missed? Should they be escaped somehow? Here is an example illustrating the problem, as well as my implementation:
[Edit:] Some clarification, so you don't need to read the code to follow. The content of the strings.txt is shown in the code comment below # strings.txt
. The file is a tab separated text file with four columns and three rows plus a header row. The first entry in the file, strMsg1
, is identical to strAsIntended
. However, fread
adds an additional backslash to \n when reading from the file, which makes the new line character into a literal \n. How can this be avoided? I just need to be able to code new lines into my strings. Hope that was understandable.
ANSWER
Answered 2020-May-16 at 14:19You are misinterpreting what fread
is doing. Your input file contains a backslash followed by n
, and that's what the string from fread
contains. However, when you print a string containing a backslash, it is doubled. (Use cat()
to print it if you don't want this.) Your strAsIntended
variable doesn't contain a backslash, it contains a single newline character, which is displayed as \n
when printed.
If you want to convert the \n
in your input file into a newline character, used gsub
or another substitution function. For example,
QUESTION
What would be the right file_regex
to capture Cargo / Rustc's error messages in a Sublime Text 3 build system? I'm asking specifically about relatively recent cargo/rustc versions (it seems that the older versions used a somewhat more easily parsable single-line error output format).
Example output of cargo build
on a broken hello-world project (default code autogenerated by cargo new --bin broken
, with one double quote removed to create an error message):
ANSWER
Answered 2018-Nov-13 at 20:38The TL;DR version of the answer is that unfortunately I think the only way to get Sublime to recognize the error output in your question is to either make the tool generate output in a different format (either directly or by way of some filter app that sits in the middle) or by creating your own custom build target for your build that can recognize this error output (but it would only work for inline errors, see below).
BackgroundBuild systems in Sublime Text have two regular expressions that can be applied to try and match error output/build results, file_regex
and line_regex
. Both are applied to the results of the build in the output panel in order to obtain the list of build results.
file_regex
is the "general purpose" regex for matching build results, and should contain anywhere from 2 to 4 capture groups that capture the appropriate data. The capture groups (used in order) are filename
, line
, column
, message
.
line_regex
is used in cases where the information about location of the error is on a different line than the error message/location. Here the captures are in the order line
, column
, message
and you can use anywhere from 1 to 3 of them.
In both cases the captures are used in the order given above, which can necessitate having empty capture groups to make sure things line up as expected.
In normal use you just use file_regex
and nothing else, and that captures the results for you. If you also use line_regex
, then internally Sublime matches on line_regex
instead, and then if it finds a match, it looks backwards through the result output for the first line that matches file_regex
, and combines the results from the captures together.
Inherently this means that there are some restrictions placed on the sort of results that Sublime can capture; the file name has to appear prior to the other information about the error in order for it to be captured.
Massaging the outputIn your example above, the error is displayed first and the location for the error is displayed second, so inherently there's no way to correctly associate the two regular expression matches together.
The most common way around this is to modify the output of the tool in order to rework it into a format that Sublime can detect with the above regular expressions.
For example you might change your build so that it executes your command and pipes the result to another shell script or program that can alter the information on the fly as it goes through. Another example would be to alter your build so that it invokes a script/batch file that executes the tool and does the output alteration internally, so that the final output matches what Sublime expects.
Custom build targetsAlthough there's no way to use the regex system to match your build output fully, if you're primarily interested in inline build errors being displayed, there is some recourse if you want to get your hands dirty with a little Sublime plugin development. In this case you need to know a bit of Python. There is documentation on custom build targets as well as the Sublime API available.
Internally, when you run a build, Sublime gathers the information from the sublime-build
file, expands any variables in it, and then invokes the exec
internal command to actually perform the build providing the keys in the sublime-build
as arguments (some, such as selector
, are not provided because Sublime handles that for you), and it's the exec
command that sets the file_regex
and line_regex
settings into the output buffer.
From here, the applied settings are used by the Sublime core directly to perform navigation on build results, such as by clicking on the results to open the file, or using the navigation commands to go to the next and previous errors.
However, it's the exec
command that is responsible for using those same results to show you the inline build errors, so it's possible to still get inline error messages working, although result navigation can only take you to the location in the file.
One of the keys that you can provide in a sublime-build
file is target
, which specifies the command that should execute the build; this defaults to exec
if not given.
By creating your own custom command that mimics what exec
does and using it in the target
directive of your sublime-build
, you can hook into the build process to capture the appropriate data.
The exec
command is stored in Default/exec.py
, which you can view by using the View Package File
command from the command palette.
As a minimal example, the following plugin defines a new command named cargo_exec
which exactly mimics what the exec
command does. The call to self.output_view.find_all_results_with_text()
is the API call that makes the Sublime core return all of the error information from the build output view, which is used to set up the phantoms used for inline build errors.
By modifying that code to examine the contents of the buffer and use your custom knowledge of what errors look like, the remainder of the code in the core exec
command will display the inline errors for you.
QUESTION
So I've been searching for like 40 minutes now without success, and "C-x" being obscure to most search engines, that didn't help at all. I've used tmux in combination with in-console emacs a few weeks ago and all worked fine. Then I didn't for some time and now I'm back on this configuration after customising my tmux a bit -- I wanted a totally distraction free environment for work, and tmux TTY seemed like a good place for that. Problem is now when I input C-x emacs doesn't pick it up anymore, which, you can guess, is very annoying. I don't really know why it won't work, and I'm sure as hell I didn't set anything to overlap with this command. Edit of course it works outside of tmux. So it must be a conflict with it but why ? and how to solve it without remapping emacs' commands ?
On a side note, I've read it's not possible to have 256 colour mode in TTY, is there really no way ? :/
Edit : About the 256 colors TTY, I've seen a few posts advising to use fbterm or some other terminal but all the ones cited were outdated. Is there really no other way ? Also I've been trying to have unicode characters working there but the answers were either the same as for 256 colours or configurations that didn't work on current version of Fedora 28.
Here is my .tmux.conf
...ANSWER
Answered 2018-Nov-13 at 00:06I unbinded C-x and it didn't work so I left the unbind sitting in my conf. Now that I have booted on a new session and came back on the question it works fine. Case closed.
QUESTION
I am trying to plot data from a Pandas dataframe that is created by importing data from a CSV. However in the plot not every label is displayed along the x-axis, the plot only shows 5 labels along the x-axis.
I have a total of 22 textbased labels, which are all supposed to be shown along the x-axis as tickmarks/labels. These labels correspond to the entries in the column in the dataframe with the name Category.
For each Line in the Line column of the dataframe a separate line in the plot is created. And the Amount columns in the dataframe contains the y-values.
I am sure there is a easy tweak for this, trying ax.set_xticks(np.arange(len(21))
and
plt.xticks( arange(21) )
did not function, maybe because the labels are textbased, not numbers?
EDIT 2
I had some trouble with the initial code after changing computer with another software setup. Now I got another version of the code and CSV that I got to run without problems that actually plots a graph. Now back to the initial problem, as can be seen from the attached picture only a few of the categories (gts, jma, yja, lre, fgg) are displayed as labels along the x-axis (I want all 22 categories to be displayed along the x-axis in full text):
Here is the code that I used for plotting that doesn't display all x-labels:
...ANSWER
Answered 2018-Mar-09 at 23:18You are looking for xticks, Matplotlib automagicly picks the xticks that will be displayed to keep things simple and nice looking. This works fine when you are dealing with time series or numeric x axis's. But not so well in your case.
What you need to do is find out what the co-ordinates at the begining and end of the plot are and use those numbers to manually position your x-ticks. You can get this info by calling plt.xticks(). Which gives you a numpy array of (cordinates, xtick labels)
QUESTION
Please tell me if it is possible after the deserialization of the XML file to get line numbers, from which values for specific properties were taken. Or are there other ways? I need to get the line numbers in the file where errors occurred (there are paths to tags with errors, for example yml_catalog/offers/offer[ 1 ]/price)
I have here such a model, in which there are values from tags:
...ANSWER
Answered 2018-Mar-01 at 14:07This can be done via LINQ. If you want to get information about a node with a number and a position, you should use the XmlDocument method instead of the SelectNode method, use XPathSelectElement, and bring it to the interface IXmlLineInfo
QUESTION
I'm working on a program that creates several pdf docs and puts different text in the same location in them. Text should be placed in a particular area and if it doesn't fit it in width it should wrap. It also has a custom font and may be differently aligned in that area. It should be Vertically aligned to Top because when the area is laid out for three lines and I has only one, it should appear on the top. Finally, I need to preserve leading on the level of font-size.
It is important to be precise in text positioning (e.g. I need an upper left corner of "H" from "Hello world" to appear definitely at 0, 100).
Now, I'm using
...ANSWER
Answered 2017-Sep-22 at 21:31This is a font-specific problem. iText guesses information about font glyphs, namely the bboxes incorrectly.
There is a quick and dirty method to adjust this behavior. You can create a custom renderer for text and adjust the calculated positions in it. An example of such a class would be as follows:
QUESTION
I use below code to highlight characters longer than 78.
...ANSWER
Answered 2017-Jun-30 at 22:09Just customize the whitespace-line
face.
QUESTION
I can't set Emacs to work with Javascript. I want Emacs makes auto indent, when I press "{" and "}". When I write code on C, it works very well. When I press "}" the parenthesis tooks its place. I'd like to see something like this:
But I get this:
I don't understand why parenthesis remain in place.
Could you tell me, what should I do to make it right, please?
I think, I need to add something to my .emacs file, aren't I?
Here is my .emacs:
...ANSWER
Answered 2017-Jun-08 at 10:26Try js2-mode. That has better style and indentation. BTW you should probably not write everything in the .emacs like this. The file structure could be something like
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install line-column
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page