首页 \ 问答 \ 包重新开发(package development without restarting)

包重新开发(package development without restarting)

我开发像这样的Sublime 3软件包:

import sublime, sublime_plugin

class RelativeCommand(sublime_plugin.TextCommand):
    def run(self, edit):
        self.view.insert(edit, 0, "Hello World")

我需要在每次编辑后重新加载sublime以查看更改工作的结果。

如何在不退出sublime并重新打开的情况下获取插件中的工作更改?

我相信这是可能的,因为例如sublime在编辑键映射时无需重新加载就可以动态更改。

Update1:当我在更改文件后按保存时,我在控制台中收到消息:

Writing file /Users/maks/Library/Application Support/Sublime Text 3/Packages/relative/relative.py with encoding UTF-8 (atomic)
reloading plugin relative.relative

Update2:我使用符号链接在Dropbox文件夹中存储PackagesInstalled Packages

Update3:我的操作系统是OS X version 10.8.5


I develop Sublime 3 packages like this:

import sublime, sublime_plugin

class RelativeCommand(sublime_plugin.TextCommand):
    def run(self, edit):
        self.view.insert(edit, 0, "Hello World")

I need to reload sublime after every editing in it to see result of changing in work.

How to get working changes in plugin without exiting the sublime and reopening it?

I believe that it is possible, because for example sublime get changes on the fly without reloading when you edit key mappings.

Update1 : When I press save after changing file, I got message in console:

Writing file /Users/maks/Library/Application Support/Sublime Text 3/Packages/relative/relative.py with encoding UTF-8 (atomic)
reloading plugin relative.relative

Update2 : I am using symlinks to store Packages and Installed Packages in Dropbox folder.

Update3: My os is OS X version 10.8.5


原文:https://stackoverflow.com/questions/19501323
更新时间:2023-09-04 15:09

最满意答案

您使用错误的逻辑来绘制线,如果您调用invalidate()您将请求调用draw() ,这将重置您的画布。

试试这个版本的课程:

public class BreakDownBar extends View {
    private List<Point> points = new ArrayList<>();
    private Path path = new Path();
    private Paint p = new Paint();

    public BreakDownBar(Context context) {
        super(context);
        p.setStrokeWidth(5);
        p.setStyle(Paint.Style.STROKE);
        p.setColor(Color.BLACK);
    }

    public void addPoint(Point point) {
        points.add(point);
        //this will request a call to draw(canvas) method
        invalidate();
    }

    @Override
    public void draw(Canvas canvas) {
        super.draw(canvas);
        //move to the first point in the list
        path.moveTo(points.get(0).getX(), points.get(0).getY());
        for (int i = 1; i < points.size(); i++) {
            path.lineTo(points.get(i).getX(), points.get(i).getY());
        }
        canvas.drawPath(path, p);
    }
}

然后在你的代码中你可以做到

BreakDownBar bar = new BreakDownBar(context);
bar.addPoint(new Point(100f, 200f))
bar.addPoint(new Point(200f, 300f))
bar.addPoint(new Point(400f, 200f))

如果这对您有用,请告诉我。


You are using a bad logic to draw the line, if you call invalidate() you will request a call to draw() and this will reset your canvas.

Try with this version of your class:

public class BreakDownBar extends View {
    private List<Point> points = new ArrayList<>();
    private Path path = new Path();
    private Paint p = new Paint();

    public BreakDownBar(Context context) {
        super(context);
        p.setStrokeWidth(5);
        p.setStyle(Paint.Style.STROKE);
        p.setColor(Color.BLACK);
    }

    public void addPoint(Point point) {
        points.add(point);
        //this will request a call to draw(canvas) method
        invalidate();
    }

    @Override
    public void draw(Canvas canvas) {
        super.draw(canvas);
        //move to the first point in the list
        path.moveTo(points.get(0).getX(), points.get(0).getY());
        for (int i = 1; i < points.size(); i++) {
            path.lineTo(points.get(i).getX(), points.get(i).getY());
        }
        canvas.drawPath(path, p);
    }
}

Then in your code you can simply do

BreakDownBar bar = new BreakDownBar(context);
bar.addPoint(new Point(100f, 200f))
bar.addPoint(new Point(200f, 300f))
bar.addPoint(new Point(400f, 200f))

Let me know if this works for you.

相关问答

更多
  • 更新:完整示例发布在GitHub上https://github.com/jselbie/xkcdclock 每次触摸事件时,抓住触摸点的x,y坐标并计算相对于位图中心的旋转角度。 使用该值确定旋转要绘制的位图的量。 首先,让我们假设一个逻辑坐标系,其中上面元素的中心点位于x,y空间中的(0,0)。 因此,任何触摸点相对于中心的角度(以度为单位)可以如下计算: double ComputeAngle(float x, float y) { final double RADS_TO_DEGREES = ...
  • newsList为null ,因为您从不为其赋值。 如果要避免NullPointerException ,请不要在newsList上调用add() ,直到为newsList分配了值(例如, newsList=new ArrayList>(); )。 newsList is null, because you never assign a value to it. If you want to avoid a NullPointerException, do n ...
  • 您无法在Canvas上撤消drawPath。 从文档 : 通过画布,您的绘图实际上是在基础位图上执行的,该位图放置在窗口中。 正如您所说,您需要一个备份Bitmap来保存当前Bitmap的状态,然后再绘制它,例如使用Memento模式 。 当内存有限时,请查看位图编辑器的快速撤消/重做? 和位图编辑器应用程序的快速撤消工具 (最后一个目标iPhone,但基本的想法是相同的) 另一种减少内存消耗的方法可能是保存您想要在画布上绘制的对象的状态,并根据需要绘制它们(当您需要显示部分或完整结果时)。 You can ...
  • 您使用错误的逻辑来绘制线,如果您调用invalidate()您将请求调用draw() ,这将重置您的画布。 试试这个版本的课程: public class BreakDownBar extends View { private List points = new ArrayList<>(); private Path path = new Path(); private Paint p = new Paint(); public BreakDownBar(Co ...
  • 我能行。 从WKT读LatLong并添加到Array private LatLng[] GetPolygonPoints(String polygonWkt) { Bundle bundle = getIntent().getExtras(); wkt = bundle.getString("wkt"); ArrayList points = new ArrayList(); Pattern p = Pattern.compile("(\\d ...
  • 请试试这个..希望它对你有用。 canvas.drawPath(path, currentPaint); canvas.drawCircle(x1, y1, 8, currentPaint); canvas.drawCircle(x2, y2, 8, currentPaint); canvas.drawCircle(x3, y3, 8, currentPaint); canvas.drawCircle(x4, y4, 8, currentPaint); 使用此代码获取此输出... Please try t ...
  • 尝试这个: link_to 'Add', [:new, params[:controller].singularize] 在内部, Rails会将[:new, params[:controller].singularize]转换为对[:new, params[:controller].singularize]的调用(例如,如果控制器posts则[:new, params[:controller].singularize]生成像new_post_path这样的路径助手)。 大多数(如果不是全部的话)期望路径 ...
  • 设置一个方法来改变DrawLine类中的paint实例,并通过按钮的onClick方法调用它 public void changeColor(int color) { paint.setColor(color); } Set a method to change paint instance inside DrawLine class and invoke it from the onClick method of the button public void changeColor(int co ...
  • 类Paint具有方法setTypeface ,可以传递一个Typeface 。 代码例子: paint.setTypeface(Typeface.DEFAULT_BOLD); 所以如果你想改变文本的一部分,可以通过改变字体逐个绘制。 另外,你可以尝试使用像 c 这样的HTML代码 the class Paint has method setTypeface , you can pass a Typeface. code exmaple: paint.setTypeface(Typeface. ...
  • 我不确定你在做什么。 但请牢记以下内容 不要长期保持对上下文活动的引用(对活动的引用应该与活动本身具有相同的生命周期)。 http://www.curious-creature.org/2008/12/18/avoid-memory-leaks-on-android/ 你可以这样做 例: new MyClass(ActivityName.this); class MyClass { Context mContext; public MyClass(Context context ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。