Skip to content

Commit

Permalink
View.ScoreSelector. Export constants to python api.
Browse files Browse the repository at this point in the history
  • Loading branch information
quarnster committed Apr 17, 2013
1 parent 2b3ecc8 commit e478969
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 49 deletions.
42 changes: 42 additions & 0 deletions backend/sublime/sublime_manual.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"lime/3rdparty/libs/gopy/lib"
"lime/backend"
"lime/backend/render"
"os"
"strings"
"time"
Expand Down Expand Up @@ -141,6 +142,42 @@ func init() {
{"OnQueryContextGlue", &_onQueryContextGlueClass},
{"ViewEventGlue", &_viewEventGlueClass},
}
type constant struct {
name string
constant int
}
constants := []constant{
{"OP_EQUAL", int(backend.OpEqual)},
{"OP_NOT_EQUAL", int(backend.OpNotEqual)},
{"OP_REGEX_MATCH", int(backend.OpRegexMatch)},
{"OP_NOT_REGEX_MATCH", int(backend.OpNotRegexMatch)},
{"OP_REGEX_CONTAINS", int(backend.OpRegexContains)},
{"OP_NOT_REGEX_CONTAINS", int(backend.OpNotRegexContains)},
{"INHIBIT_WORD_COMPLETIONS", 0},
{"INHIBIT_EXPLICIT_COMPLETIONS", 0},
{"LITERAL", 0},
{"IGNORECASE", 0},
{"CLASS_WORD_START", 0},
{"CLASS_WORD_END", 0},
{"CLASS_PUNCTUATION_START", 0},
{"CLASS_PUNCTUATION_END", 0},
{"CLASS_SUB_WORD_START", 0},
{"CLASS_SUB_WORD_END", 0},
{"CLASS_LINE_START", 0},
{"CLASS_LINE_END", 0},
{"CLASS_EMPTY_LINE", 0},
{"DRAW_EMPTY", int(render.DRAW_EMPTY)},
{"HIDE_ON_MINIMAP", int(render.HIDE_ON_MINIMAP)},
{"DRAW_EMPTY_AS_OVERWRITE", int(render.DRAW_EMPTY_AS_OVERWRITE)},
{"DRAW_NO_FILL", int(render.DRAW_NO_FILL)},
{"DRAW_NO_OUTLINE", int(render.DRAW_NO_OUTLINE)},
{"DRAW_SOLID_UNDERLINE", int(render.DRAW_SOLID_UNDERLINE)},
{"DRAW_STIPPLED_UNDERLINE", int(render.DRAW_STIPPLED_UNDERLINE)},
{"DRAW_SQUIGGLY_UNDERLINE", int(render.DRAW_SQUIGGLY_UNDERLINE)},
{"PERSISTENT", int(render.PERSISTENT)},
{"HIDDEN", int(render.HIDDEN)},
}

for _, cl := range classes {
c, err := cl.c.Create()
if err != nil {
Expand All @@ -150,6 +187,11 @@ func init() {
panic(err)
}
}
for _, c := range constants {
if err := m.AddIntConstant(c.name, c.constant); err != nil {
panic(err)
}
}
py.AddToPath("../../backend/packages/")
py.AddToPath("../../3rdparty/bundles/")
py.AddToPath("../../backend/sublime/")
Expand Down
7 changes: 0 additions & 7 deletions backend/sublime/sublime_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@
import sys
import importlib

sublime.OP_EQUAL = 0
sublime.OP_NOT_EQUAL = 1
sublime.OP_REGEX_MATCH = 2
sublime.OP_NOT_REGEX_MATCH = 3
sublime.OP_REGEX_CONTAINS = 4
sublime.OP_NOT_REGEX_CONTAINS = 5

class Command(object):
def is_enabled(self, args=None):
return True
Expand Down
2 changes: 1 addition & 1 deletion backend/sublime/sublime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func TestSublime(t *testing.T) {
t.Error(err)
} else {
ty := item.Type()
line := fmt.Sprintf("%s%-30s: %s\n", indent, v2, ty)
line := fmt.Sprintf("%s%s\n", indent, v2)
buf.WriteString(line)
if ty == py.TypeType {
f(indent+"\t", item, buf)
Expand Down
106 changes: 65 additions & 41 deletions backend/sublime/testdata/api.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ApplicationCommandGlue : <class 'type'>
ApplicationCommandGlue
__class__
__delattr__
__dir__
Expand All @@ -21,7 +21,23 @@ ApplicationCommandGlue : <class 'type'>
__sizeof__
__str__
__subclasshook__
Edit : <class 'type'>
CLASS_EMPTY_LINE
CLASS_LINE_END
CLASS_LINE_START
CLASS_PUNCTUATION_END
CLASS_PUNCTUATION_START
CLASS_SUB_WORD_END
CLASS_SUB_WORD_START
CLASS_WORD_END
CLASS_WORD_START
DRAW_EMPTY
DRAW_EMPTY_AS_OVERWRITE
DRAW_NO_FILL
DRAW_NO_OUTLINE
DRAW_SOLID_UNDERLINE
DRAW_SQUIGGLY_UNDERLINE
DRAW_STIPPLED_UNDERLINE
Edit
__class__
__delattr__
__dir__
Expand All @@ -44,13 +60,19 @@ Edit : <class 'type'>
__sizeof__
__str__
__subclasshook__
OP_EQUAL : <class 'int'>
OP_NOT_EQUAL : <class 'int'>
OP_NOT_REGEX_CONTAINS : <class 'int'>
OP_NOT_REGEX_MATCH : <class 'int'>
OP_REGEX_CONTAINS : <class 'int'>
OP_REGEX_MATCH : <class 'int'>
OnQueryContextGlue : <class 'type'>
HIDDEN
HIDE_ON_MINIMAP
IGNORECASE
INHIBIT_EXPLICIT_COMPLETIONS
INHIBIT_WORD_COMPLETIONS
LITERAL
OP_EQUAL
OP_NOT_EQUAL
OP_NOT_REGEX_CONTAINS
OP_NOT_REGEX_MATCH
OP_REGEX_CONTAINS
OP_REGEX_MATCH
OnQueryContextGlue
__class__
__delattr__
__dir__
Expand All @@ -73,7 +95,8 @@ OnQueryContextGlue : <class 'type'>
__sizeof__
__str__
__subclasshook__
Region : <class 'type'>
PERSISTENT
Region
__class__
__delattr__
__dir__
Expand Down Expand Up @@ -108,7 +131,7 @@ Region : <class 'type'>
intersection
intersects
size
RegionSet : <class 'type'>
RegionSet
__class__
__delattr__
__dir__
Expand Down Expand Up @@ -139,7 +162,7 @@ RegionSet : <class 'type'>
contains
regions
substract
Settings : <class 'type'>
Settings
__class__
__delattr__
__dir__
Expand Down Expand Up @@ -169,7 +192,7 @@ Settings : <class 'type'>
has
id
set
TextCommandGlue : <class 'type'>
TextCommandGlue
__class__
__delattr__
__dir__
Expand All @@ -192,7 +215,7 @@ TextCommandGlue : <class 'type'>
__sizeof__
__str__
__subclasshook__
View : <class 'type'>
View
__class__
__delattr__
__dir__
Expand Down Expand Up @@ -239,6 +262,7 @@ View : <class 'type'>
rowcol
run_command
scope_name
score_selector
sel
set_name
set_overwrite_status
Expand All @@ -251,7 +275,7 @@ View : <class 'type'>
visible_region
window
word
ViewEventGlue : <class 'type'>
ViewEventGlue
__class__
__delattr__
__dir__
Expand All @@ -274,7 +298,7 @@ ViewEventGlue : <class 'type'>
__sizeof__
__str__
__subclasshook__
Window : <class 'type'>
Window
__class__
__delattr__
__dir__
Expand Down Expand Up @@ -304,7 +328,7 @@ Window : <class 'type'>
run_command
settings
views
WindowCommandGlue : <class 'type'>
WindowCommandGlue
__class__
__delattr__
__dir__
Expand All @@ -327,27 +351,27 @@ WindowCommandGlue : <class 'type'>
__sizeof__
__str__
__subclasshook__
__doc__ : <class 'NoneType'>
__name__ : <class 'str'>
__package__ : <class 'NoneType'>
active_window : <class 'builtin_function_or_method'>
arch : <class 'builtin_function_or_method'>
console : <class 'builtin_function_or_method'>
error_message : <class 'builtin_function_or_method'>
get_clipboard : <class 'builtin_function_or_method'>
log_commands : <class 'builtin_function_or_method'>
log_input : <class 'builtin_function_or_method'>
message_dialog : <class 'builtin_function_or_method'>
new_window : <class 'builtin_function_or_method'>
ok_cancel_dialog : <class 'builtin_function_or_method'>
packages_path : <class 'builtin_function_or_method'>
platform : <class 'builtin_function_or_method'>
register : <class 'builtin_function_or_method'>
run_command : <class 'builtin_function_or_method'>
set_clipboard : <class 'builtin_function_or_method'>
set_timeout : <class 'builtin_function_or_method'>
settings : <class 'builtin_function_or_method'>
status_message : <class 'builtin_function_or_method'>
test_window : <class 'sublime.Window'>
unregister : <class 'builtin_function_or_method'>
version : <class 'builtin_function_or_method'>
__doc__
__name__
__package__
active_window
arch
console
error_message
get_clipboard
log_commands
log_input
message_dialog
new_window
ok_cancel_dialog
packages_path
platform
register
run_command
set_clipboard
set_timeout
settings
status_message
test_window
unregister
version
7 changes: 7 additions & 0 deletions backend/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,13 @@ func (v *View) ScopeName(point int) string {
return v.lastScopeName
}

func (v *View) ScoreSelector(point int, selector string) int {
if sn := v.ScopeName(point); len(sn) > 0 {
return 1 + strings.Index(sn, selector)
}
return 0
}

func (v *View) CommandHistory(idx int, modifying_only bool) (name string, args Args, count int) {
// TODO: merge history when possible
if i := v.undoStack.index(idx, modifying_only); i != -1 {
Expand Down

0 comments on commit e478969

Please sign in to comment.