When looking at the Atom APIs for a package that I'm writing, it said that you use the Cursor class to access cursor information. I'm trying to get the cursor buffer position, so I tried using getBufferPosition(). The entire line of code was:
cursorRow = atom.workspace.getActiveTextEditor().Cursor.getBufferPosition()[0]
to get just the row. However, it keeps throwing this error:
Uncaught TypeError: Cannot read property 'getBufferPosition' of undefined
This is all in CoffeeScript, by the way. I can't figure out what I'm doing wrong, because the APIs say that getBufferPosition is a method of the Cursor class, so that should work. What am I doing wrong? Or is there a better way to figure this out?
Thanks in advance!
You can use the getCursorBufferPosition of TextEditor, i.e.
cursorPosition = atom.workspace.getActiveTextEditor().getCursorBufferPosition()
The error you're seeing is telling you that there is no property named Cursor on the text editor. There may well be a getBufferPosition defined on the Cursor class, but you're not calling it on an instance of Cursor, but on undefined.
Related
From MATLAB I am calling a Python function that creates and returns a Python object MyPyObj created by me with some attribute. The object is correctly returned however some attribute is missing and when I try to access them in MATLAB, a No appropriate method, property, or field error is returned. Does someone know why this happens?
Have you already tried this:
commandStr = 'python /Users/myName/pathToScript/sqr.py 2';
[status, commandOut] = system(commandStr);
if status==0
fprintf('squared result is %d\n',str2num(commandOut));
end
I managed to solve the problem following this post. Basically I needed to use
py.getattr(myPyObj, 'name_of_the_hidden_attribute')
However I am still not able to understand why myPyObj.name_of_the_hidden_attribute throws an error. I want to provide also this link in case my solution does not fix the problem for other users.
If for example you have acquired a object of type handleplot with expression like below:
handle = plot(t,functoin1 , t , function2 ) ;
Now handle will be an array that contains two elements, handle(1) and handle(2). Now suppose you want to change some properties of one of these objects, like set a LineWidth, change the Color, or the like.
Is there any way in which you can activate auto-completion or suggestions when you type handle(1). (note the memebership operator .)? I am looking for the automatic suggestions that MATLAB provides for member functions in a combobox near the blinking cursor, similar to the way other IDEs provide this feature:
MATLAB's objects support tab completion. After typing handle(1). simply hit tab and you will receive a list of available methods and properties of the graphics object.
If you want more help on a method, you will also get a popup dialog of the method and the accepted input arguments.
If you want to programmatically get a list of properties of an object, you can use properties
properties(t)
If you want a listing of all properties and their values, just use get
get(t)
i use this method ...
for example i'm writing a program in matlab editor and when im want to know the properties of an object just stop coding and run the program , know it's have my object (for example handle) and know i can write the properties(handle) in command window to know the exact properties of handle . as Suever says .
So I have a class in an #file being referenced by a file in the root directory. a couple of the methods in the # file are in separate m files as function. It seems at times. but when I try and set a breakpoint in any of the methods I get an error "cannot enable breakpoints because of syntax error. Error using ==>dbstop. cannot find function C:/../methodname.m" I run the file anyways. It gives an error "No appropriate method, property, or field methodName for class className". But when I type in "methods(classname)" my method name is clearly listed there. I have a constructor:
function obj = ClassName(input) % constructor
obj.Input = input;
end
This is being registered and I can access all of my property values. My function definitions pass in "obj" as the first argument. There doesn't seem to be any indication of a syntax error and even though the method is clearly being recognized, it doesn't seem to be recognized at runtime. so really 2 different problems but I imagine they are linked. has anyone else had a similar issue? one of the function definitions looks like
function result = MethodName(obj,var1,var2)
....
end
Thanks a ton in advance guys. it's a pretty vague issue. Is there any other information I can provide that would help? matlab version is R2009a.
I want to integrate code completion feature to CodeMirror based xml editor. It basically parses the schema of the xml file and provide code completion according to schema and its structure. But there is something i could not manage to do. For example, when the cursor is moved to a location which is inside and xml tag, code completion must behave accordingly. It should aware of that the cursor is inside the tag, etc. How can i do that?
I think XML parser of the code mirror may give a clue about semantic position of the cursor location with some alteration. Is that possible?
Or is there any generic way to analyze cursor location and behave accordingly?
Thanks in advance.
If you use CodeMirror 2, there's a getTokenAt method that allows you to analyse the parser state at a given position. You can see this being used to autocomplete local JavaScript variables in http://codemirror.net/2/demo/complete.html . For the XML parser, you can inspect the context property of the state, which is a linked list of objects, each containing a tagName property and a prev property linking to the context above it.
I'm working on a Perl module and whenever I call the skip() method I wrote in the following way:
$cursor->skip(4);
I get:
Undefined subroutine &MyModule::Cursor::skip called at t/tester.pl line 24.
(in cleanup) invalid object at t/tester.pl line 24.
When I call it like:
MyModule::Cursor::skip($cursor, 4);
Perl finds it!
Oddly, if I name "skip" anything else ("skipper", "hello"), this syntax works:
$cursor->skipper(4);
I thought maybe skip() was a "secret" reserved key word or something, but I've also got methods named sort() and next() (which I know are reserved), and those work fine.
I'd really like to name this method "skip." Does anyone know why Perl can't find it?
skip() is exported from Test::More, which you might have loaded since your executable is named t/tester.pl.
What does ref($cursor) yield you? It should be a blessed MyModule::Cursor object, but the "invalid object" error might be suggesting the object was not constructed properly.
EDIT: perldiag gives another clue: "in cleanup" signifies that a problem was encountered by the object's destructor. Assuming you don't already have a destructor in the object, create a MyModule::Cursor::DESTROY method that Data::Dumps the object to see what it looks like at this time.
A concise snippet of example code that exhibits this behaviour would be very helpful.
Without actual code, it's difficult to debug this.
Do you use MyModule::Cursor in your test code? When you replaced skip with skipper, were you calling it in exactly the same way from your test module? Are you able to use skip from a throw-away (one-liner or very short script)?
Where I'm going with this is looking for an error in your test code, rather than the module.
UPDATE: You're not doing something like declaring methods on MyModule::Cursor in two different files, are you? The error message you're getting tells me it has a blessed reference to an object of type MyModule::Cursor, so it knows about the class; but then it can't find the definition of skip. Do you happen to declare part of MyModule::Cursor in one file, and skip in another, and your test module isn't including the second file? Or do you have a syntax error somewhere around your definition of skip -- a missing semi-colon or unpaired curly brace? (But then again, why would MyModule::Cursor::skip work where $cursor->skip does not?)