Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Move gedit2geany out of tree (separate project).

  • Loading branch information...
commit 53c69ffc95d3e2ccb9084f9775cde7e62f714d3d 1 parent 03eeff0
Matthew Brush authored
View
182 gedit2geany/gedit2geany.py
@@ -1,182 +0,0 @@
-#!/usr/bin/env python
-
-import os
-import sys
-from lxml import etree
-
-GEDIT_INPUT = "github.xml"
-GEANY_TEMPLATE = "template.conf"
-
-# maps style names from Gedit to Geany names
-_MAPPING = {
- # Editor styles
- "text": "default",
- "selection": "selection",
- "cursor": "caret",
- "current-line": "current_line",
- "line-numbers": "margin_line_number",
- "bracket-match": "brace_good",
- "bracket-mismatch": "brace_bad",
- "def:error": "error",
-
- # Programming styles
- "def:comment": "comment",
- "def:number": "number",
- "def:string": "string",
- "def:type": "type",
- "def:function": "function",
- "def:keyword": "keyword",
- "def:builtin": "keyword_2",
- "def:identifier": "label", #?
- "def:preprocessor": "preprocessor",
- "def:complex": "regex",
- "def:operator": "operator",
- "def:statement": "decorator", #?
- "def:constant": "other", #?
-
- # Markup-type languages
- "xml:tag": "tag",
- "xml:attribute-name": "attribute",
-
- # Diff
- "diff:added-line": "line_added",
- "diff:changed-line": "line_changed",
- "diff:removed-line": "line_removed",
-}
-
-COLORS = {}
-STYLES = {}
-
-tree = etree.parse(open(GEDIT_INPUT, "r"))
-
-root = tree.getroot()
-
-def hex_to_int(hexstr):
- if len(hexstr.strip()) == 0:
- return ""
- if hexstr.startswith("#"):
- hexstr = hexstr[1:]
- if hexstr.startswith("0x"):
- hexstr = hexstr[2:]
- if len(hexstr) == 3:
- hexstr = "%c%c%c%c%c%c" % (hexstr[0], hexstr[0],
- hexstr[1], hexstr[1],
- hexstr[2], hexstr[2])
- if len(hexstr) > 6:
- sys.stderr.write("Truncated 0x%s to 0x%s\n" % (hexstr, hexstr[:6]))
- hexstr = hexstr[:6]
- return "0x%s" % hexstr
-
-INFO = {}
-if root.get("_name", False):
- INFO["name"] = root.get("_name")
-
-# Read Gedit theme into dict
-for child in root:
- if child.tag == "color":
- if child.get("name", False):
- COLORS[child.get("name")] = child.get("value", "")
- elif child.tag == "style" and child.get("name", "") in _MAPPING:
- if child.get("name", False) and child.get("name") in _MAPPING:
- fg = child.get("foreground", "")
- bg = child.get("background", "")
- if fg in COLORS: fg = COLORS[fg]
- if bg in COLORS: bg = COLORS[bg]
- if not fg.startswith("#"): fg = ""
- if not bg.startswith("#"): bg = ""
- bold = child.get("bold", "")
- italic = child.get("italic", "")
- style = "%s;%s;%s;%s" % (hex_to_int(fg), hex_to_int(bg), bold, italic)
- STYLES[_MAPPING[child.get("name")]] = style
- elif child.tag == "author":
- INFO["author"] = child.text
- elif child.tag == "description":
- INFO["description"] = child.text
-
-op_file = "%s.conf" % os.path.splitext(os.path.basename(GEDIT_INPUT))[0]
-with open(op_file, "w") as op:
-
- op.write("[theme_info]\n")
- for key, value in sorted(INFO.items()):
- op.write("%s=%s\n" % (key, value))
- op.write("\n[named_styles]\n")
- for key, value in sorted(STYLES.items()):
- op.write("%s=%s\n" % (key, value))
- op.write("\n")
-
- op.write("margin_folding=margin_margin_line_number\n")
- op.write("fold_symbol_highlight=%s\n" % STYLES["margin_line_number"].split(";")[1])
-
- # make indent guide and white space bg color but bit lighter
- bg_color = int(STYLES.get("default", "0x000000").split(";")[1], base=16)
- bg_blue = bg_color & 255
- bg_green = (bg_color >> 8) & 255
- bg_red = (bg_color >> 16) & 255
- #bg_inc = 0xff - 0xc0 # tweak me
- bg_inc = 10
-
- bg_lighter = "0x%02X%02X%02X" % (int(bg_red + bg_inc),
- int(bg_green + bg_inc),
- int(bg_blue + bg_inc))
-
- bg_even_lighter = "0x%02x%02x%02x" % (bg_red + (bg_inc*2),
- bg_green + (bg_inc*2),
- bg_blue + (bg_inc*2))
- bg_lighter_still = "0x%02x%02x%02x" % (bg_red + (bg_inc*3),
- bg_green + (bg_inc*3),
- bg_blue + (bg_inc*3))
-
- op.write("indent_guide=%s;%s\n" % (bg_lighter,
- STYLES["default"].split(";")[1]))
- op.write("white_space=indent_guide\n")
-
- op.write("comment_doc=comment\n")
- op.write("comment_line=comment\n")
- op.write("comment_line_doc=comment_doc\n")
- op.write("comment_doc_keyword=comment_doc,bold\n")
- op.write("comment_doc_keyword_error=comment_doc,italic\n")
-
- op.write("number_1=number\n")
- op.write("number_2=number_1\n")
-
- op.write("class=type\n")
-
- op.write("parameter=function\n")
-
- op.write("keyword_1=keyword\n")
- op.write("keyword_2=keyword_1\n")
- op.write("keyword_3=keyword_1\n")
- op.write("keyword_4=keyword_1\n")
-
-
-
- op.write("\n")
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
View
43 gedit2geany/github.conf
@@ -1,43 +0,0 @@
-[theme_info]
-author=Felipe Mesquita
-description=A clone of the Github theme for Gedit.
-name=Github
-
-[named_styles]
-attribute=0x000000;;;
-brace_bad=;0x000000;true;
-brace_good=;0x000000;;
-caret=0x000000;;;
-comment=0x999988;;;true
-current_line=;0xF8F8FF;;
-decorator=0x0F8787;;;
-default=0x000000;0xF8F8FF;;
-error=0x000000;;true;
-keyword=0x000000;;true;
-keyword_2=0x000000;;true;
-label=0x0086b3;;;
-margin_line_number=0x000000;0xF8F8FF;;
-number=0x009999;;;
-other=0x0F8787;;;
-preprocessor=0x000000;;;
-string=0xDD1144;;;
-type=0x445588;;true;
-
-margin_folding=margin_margin_line_number
-fold_symbol_highlight=0xF8F8FF
-indent_guide=0x102102109;0xF8F8FF
-white_space=indent_guide
-comment_doc=comment
-comment_line=comment
-comment_line_doc=comment_doc
-comment_doc_keyword=comment_doc,bold
-comment_doc_keyword_error=comment_doc,italic
-number_1=number
-number_2=number_1
-class=type
-parameter=function
-keyword_1=keyword
-keyword_2=keyword_1
-keyword_3=keyword_1
-keyword_4=keyword_1
-
View
110 gedit2geany/github.xml
@@ -1,110 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- Copyright (C) 2009 Felipe Mesquita <fmesquitacunha@gmail.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-
--->
-<style-scheme id="github" _name="Github" version="1.0">
- <author>Felipe Mesquita</author>
- <description>A clone of the Github theme for Gedit.</description>
-
-<!-- Colors -->
-
- <color name="background" value="#F8F8FF"/>
- <color name="caret" value="#000000"/>
- <color name="foreground" value="#000000"/>
- <color name="highlight" value="#00000012"/>
- <color name="comment" value="#999988"/>
- <color name="keyword" value="#000000"/>
- <color name="function" value="#990000"/>
- <color name="class" value="#445588"/>
- <color name="number" value="#009999"/>
- <color name="variable" value="#008080"/>
- <color name="constant" value="#0F8787"/>
- <color name="constant2" value="#0F8787"/>
- <color name="string" value="#DD1144"/>
- <color name="symbol" value="#AA2C8C"/>
- <color name="identifier" value="#0086b3"/>
-
-<!-- Global Settings -->
-
- <style name="text" foreground="foreground" background="background"/>
- <style name="cursor" foreground="foreground"/>
- <style name="current-line" background="background"/>
- <style name="line-numbers" foreground="foreground" background="background"/>
-
-<!-- Bracket Matching -->
- <style name="bracket-match" background="highlight"/>
- <style name="bracket-mismatch" background="highlight" bold="true"/>
- <style name="search-match" foreground="foreground" background="caret"/>
-
-<!-- Comments -->
- <style name="def:comment" foreground="comment" italic="true"/>
- <style name="def:shebang" foreground="comment" italic="true"/>
- <style name="def:doc-comment-element" foreground="comment" bold="true"/>
-
-<!-- Constants and Variables-->
- <style name="def:constant" foreground="constant"/>
- <style name="def:string" foreground="string"/>
- <style name="def:special-char" foreground="string"/>
- <style name="def:special-constant" foreground="constant" bold="true"/>
- <style name="def:boolean" foreground="constant"/>
- <style name="def:number" foreground="number"/>
- <style name="def:floating-point" foreground="number"/>
- <style name="def:keyword" foreground="keyword" bold="true"/>
- <style name="def:builtin" foreground="foreground" bold="true"/>
- <style name="def:variable" foreground="variable"/>
-
-<!-- Identifiers -->
- <style name="def:identifier" foreground="identifier"/>
-
-<!-- Statements -->
- <style name="def:statement" foreground="constant"/>
-
-<!-- Types -->
- <style name="def:type" foreground="class" bold="true"/>
-
-<!-- Others -->
- <style name="def:error" foreground="highlight" bold="true"/>
- <style name="def:note" foreground="highlight" bold="true"/>
- <style name="def:net-address-in-comment" foreground="variable" italic="false" underline="true"/>
- <style name="def:preprocessor" foreground="highlight"/>
-
-<!-- Unknown? -->
- <style name="def:specials" background="identifier"/>
-
-<!-- C Styles -->
- <style name="c:preprocessor" map-to="def:special-char"/>
-
-<!-- Diff Styles -->
- <style name="diff:ignore" foreground="highlight"/>
-
-<!-- Ruby Styles -->
- <style name="ruby:module-handler" foreground="identifier"/>
- <style name="ruby:symbol" foreground="symbol"/>
- <style name="ruby:regex" foreground="number"/>
- <style name="ruby:function" foreground="function"/>
-
-<!-- SH Styles -->
- <style name="sh:others" map-to="text"/>
-
-<!-- XML Styles -->
- <style name="xml:attribute-name" foreground="keyword"/>
- <style name="xml:element-name" foreground="keyword"/>
-
-</style-scheme>
View
94 gedit2geany/template.conf
@@ -1,94 +0,0 @@
-[theme_info]
-name=
-description=
-version=
-author=
-url=
-
-[named_styles]
-
-default=0x000000;0xffffff;false;false
-error=0xffffff;0xff0000
-
-# Editor styles
-#-------------------------------------------------------------------------------
-
-selection=0x000000;0xc0c0c0;false;false
-current_line=0x000000;0xf0f0f0;true
-brace_good=0x0000ff;0xFFFFFF;true
-brace_good=0x000000;0x008B8B;true
-brace_bad=0x000000;0x6A5ACD;true
-margin_line_number=0x000000;0xd0d0d0
-margin_folding=margin_line_number
-fold_symbol_highlight=0xffffff
-indent_guide=0xc0c0c0
-white_space=indent_guide
-caret=0x000000;0x000000;false
-marker_line=0x000000;0xffff00
-marker_search=0x000000;0x0000f0
-marker_mark=0x000000;0xb8f4b8
-call_tips=0xc0c0c0;0xffffff
-
-# Programming languages
-#-------------------------------------------------------------------------------
-
-comment=0x0000FF
-comment_doc=comment
-comment_line=comment
-comment_line_doc=comment_doc
-comment_doc_keyword=comment_doc,bold
-comment_doc_keyword_error=comment_doc,italic
-
-number=0x137E10
-number_1=number
-number_2=number_1
-
-type=0x2E8B57;;true
-class=type
-function=default
-parameter=function
-
-keyword=0x008A8C;;true
-keyword_1=keyword
-keyword_2=keyword_1
-keyword_3=keyword_1
-keyword_4=keyword_1
-
-identifier=default
-identifier_1=identifier
-identifier_2=identifier_1
-identifier_3=identifier_1
-identifier_4=identifier_1
-
-string=0xFF00FF
-string_1=string
-string_2=string_1
-string_eol=string_1,italic
-character=string_1
-backtick=string_2
-here_doc=string_2
-
-label=default,bold
-preprocessor=0xA020F0
-regex=number_1
-operator=default
-decorator=string_1,bold
-other=default
-
-# Markup-type languages
-#-------------------------------------------------------------------------------
-
-tag=
-tag_unknown=tag
-tag_end=tag
-attribute=
-attribute_unknown=attribute
-value=string_1
-entity=default
-
-# Diff
-#-------------------------------------------------------------------------------
-
-line_added=0x008B8B
-line_removed=0x6A5ACD
-line_changed=preprocessor
Please sign in to comment.
Something went wrong with that request. Please try again.