public void StagePath(GitWrapper.ChangeType changeType, string path) { if (changeType == GitWrapper.ChangeType.Deleted) { GitWrapper.RemovePath(path); } else { GitWrapper.StagePath(path); } isDirty = true; }
public Color ColorForChangeType(GitWrapper.ChangeType status) { Color c = Color.red; switch (status) { case GitWrapper.ChangeType.Modified: c = GitStyles.ModifiedColor; break; case GitWrapper.ChangeType.Added: c = GitStyles.AddedColor; break; case GitWrapper.ChangeType.Deleted: c = GitStyles.DeletedColor; break; case GitWrapper.ChangeType.Renamed: c = GitStyles.RenamedColor; break; case GitWrapper.ChangeType.Copied: c = GitStyles.CopiedColor; break; case GitWrapper.ChangeType.Untracked: c = GitStyles.UntrackedColor; break; default: Debug.Log("Should not have gotten this status: " + status); break; } return(c); }
public void UnstagePath(GitWrapper.ChangeType changeType, string path) { GitWrapper.UnstagePath(path); isDirty = true; }
protected bool ShowFile(ListView state, string path, GitWrapper.ChangeType status, WholeFileCommand cmd) { Event current = Event.current; bool isChanged = false; bool isSelected = state.selection.IsSelected(path); GUIStyle style = isSelected ? (panelHasFocus && state.hasFocus ? GitStyles.FileLabelSelected : GitStyles.FileLabelSelectedUnfocused) : GitStyles.FileLabel; GUIContent tmp = null; if (!iconCache.ContainsKey(path)) { tmp = new GUIContent() { image = AssetDatabase.GetCachedIcon(path), text = null }; if (tmp.image == null) { tmp.image = DEFAULT_FILE_ICON; } iconCache[path] = tmp; } tmp = (GUIContent)iconCache[path]; GUILayout.BeginHorizontal(); GUILayout.Label(tmp, style, ICON_WIDTH, ITEM_HEIGHT); Rect iconPosition = GUILayoutUtility.GetLastRect(); Color c = GUI.contentColor; GUI.contentColor = ColorForChangeType(status); Rect labelPosition = EditorGUILayout.BeginVertical(style, MAX_ITEM_HEIGHT); GUILayout.FlexibleSpace(); GUILayout.Label(path, style); GUILayout.Space(ITEM_BASELINE); EditorGUILayout.EndVertical(); GUI.contentColor = c; GUILayout.EndHorizontal(); if (current.type == EventType.MouseDown) { if (iconPosition.Contains(current.mousePosition)) { isChanged = true; cmd(status, path); state.selection.Unselect(path); } else if (labelPosition.Contains(current.mousePosition)) { isChanged = true; isSelected = !isSelected; bool addToSelection = false, rangeSelection = false; if (Event.current.command && Application.platform == RuntimePlatform.OSXEditor) { addToSelection = true; } else if (Event.current.control && Application.platform == RuntimePlatform.WindowsEditor) { addToSelection = true; } if (Event.current.shift) { rangeSelection = true; } if (!addToSelection && !rangeSelection) { state.selection.Clear(); } state.selection.Set(path, isSelected); // TODO: For range selection we need the list of files, index of last selection, etc. } } return(isChanged); }